Fixed bug in cronet_transport where completed ops were not removed from storage

pull/20464/head
Prashant Jaikumar 5 years ago
parent 04495e5488
commit 4bb7731d5b
  1. 9
      src/core/ext/transport/cronet/transport/cronet_transport.cc
  2. 3
      src/objective-c/tests/ConfigureCronet.h
  3. 6
      src/objective-c/tests/ConfigureCronet.m
  4. 2
      src/objective-c/tests/CronetTests/CoreCronetEnd2EndTests.mm
  5. 2
      src/objective-c/tests/CronetTests/CronetUnitTests.mm
  6. 2
      src/objective-c/tests/CronetTests/InteropTestsRemoteWithCronet.m
  7. 2
      src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m
  8. 38
      src/objective-c/tests/PerfTests/PerfTests.m
  9. 2
      src/objective-c/tests/PerfTests/PerfTestsCronet.m

@ -1348,22 +1348,27 @@ static enum e_op_result execute_stream_op(struct op_and_state* oas) {
stream_state->cancel_error = stream_state->cancel_error =
GRPC_ERROR_REF(stream_op->payload->cancel_stream.cancel_error); GRPC_ERROR_REF(stream_op->payload->cancel_stream.cancel_error);
} }
} else if (stream_op->on_complete && } else if (op_can_be_run(stream_op, s, &oas->state, OP_ON_COMPLETE)) {
op_can_be_run(stream_op, s, &oas->state, OP_ON_COMPLETE)) {
CRONET_LOG(GPR_DEBUG, "running: %p OP_ON_COMPLETE", oas); CRONET_LOG(GPR_DEBUG, "running: %p OP_ON_COMPLETE", oas);
if (stream_state->state_op_done[OP_CANCEL_ERROR]) { if (stream_state->state_op_done[OP_CANCEL_ERROR]) {
if (stream_op->on_complete) {
GRPC_CLOSURE_SCHED(stream_op->on_complete, GRPC_CLOSURE_SCHED(stream_op->on_complete,
GRPC_ERROR_REF(stream_state->cancel_error)); GRPC_ERROR_REF(stream_state->cancel_error));
}
} else if (stream_state->state_callback_received[OP_FAILED]) { } else if (stream_state->state_callback_received[OP_FAILED]) {
if (stream_op->on_complete) {
GRPC_CLOSURE_SCHED( GRPC_CLOSURE_SCHED(
stream_op->on_complete, stream_op->on_complete,
make_error_with_desc(GRPC_STATUS_UNAVAILABLE, "Unavailable.")); make_error_with_desc(GRPC_STATUS_UNAVAILABLE, "Unavailable."));
}
} else { } else {
/* All actions in this stream_op are complete. Call the on_complete /* All actions in this stream_op are complete. Call the on_complete
* callback * callback
*/ */
if (stream_op->on_complete) {
GRPC_CLOSURE_SCHED(stream_op->on_complete, GRPC_ERROR_NONE); GRPC_CLOSURE_SCHED(stream_op->on_complete, GRPC_ERROR_NONE);
} }
}
oas->state.state_op_done[OP_ON_COMPLETE] = true; oas->state.state_op_done[OP_ON_COMPLETE] = true;
oas->done = true; oas->done = true;
/* reset any send message state, only if this ON_COMPLETE is about a send. /* reset any send message state, only if this ON_COMPLETE is about a send.

@ -15,6 +15,7 @@
* limitations under the License. * limitations under the License.
* *
*/ */
#include <stdbool.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -23,7 +24,7 @@ extern "C" {
/** /**
* Enable Cronet for once. * Enable Cronet for once.
*/ */
void configureCronet(void); void configureCronet(bool enable_netlog);
#ifdef __cplusplus #ifdef __cplusplus
} }

@ -19,7 +19,7 @@
#import "ConfigureCronet.h" #import "ConfigureCronet.h"
#import <Cronet/Cronet.h> #import <Cronet/Cronet.h>
void configureCronet(void) { void configureCronet(bool enable_netlog) {
static dispatch_once_t configureCronet; static dispatch_once_t configureCronet;
dispatch_once(&configureCronet, ^{ dispatch_once(&configureCronet, ^{
NSLog(@"configureCronet()"); NSLog(@"configureCronet()");
@ -29,7 +29,9 @@ void configureCronet(void) {
NSURL *url = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory NSURL *url = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory
inDomains:NSUserDomainMask] lastObject]; inDomains:NSUserDomainMask] lastObject];
NSLog(@"Documents directory: %@", url); NSLog(@"Documents directory: %@", url);
[Cronet start]; if (enable_netlog) {
[Cronet startNetLogToFile:@"cronet_netlog.json" logBytes:YES]; [Cronet startNetLogToFile:@"cronet_netlog.json" logBytes:YES];
}
[Cronet start];
}); });
} }

@ -177,7 +177,7 @@ static char *roots_filename;
grpc_init(); grpc_init();
configureCronet(); configureCronet(/*enable_netlog=*/false);
} }
// The tearDown() function is run after all test cases finish running // The tearDown() function is run after all test cases finish running

@ -64,7 +64,7 @@ static void drain_cq(grpc_completion_queue *cq) {
grpc_test_init(1, argv); grpc_test_init(1, argv);
grpc_init(); grpc_init();
configureCronet(); configureCronet(/*enable_netlog=*/false);
init_ssl(); init_ssl();
} }

@ -42,7 +42,7 @@ static int32_t kRemoteInteropServerOverhead = 12;
@implementation InteropTestsRemoteWithCronet @implementation InteropTestsRemoteWithCronet
+ (void)setUp { + (void)setUp {
configureCronet(); configureCronet(/*enable_netlog=*/false);
[GRPCCall useCronetWithEngine:[Cronet getGlobalEngine]]; [GRPCCall useCronetWithEngine:[Cronet getGlobalEngine]];
[super setUp]; [super setUp];

@ -85,7 +85,7 @@ dispatch_once_t initCronet;
self.continueAfterFailure = NO; self.continueAfterFailure = NO;
_remoteService = [RMTTestService serviceWithHost:kRemoteSSLHost callOptions:nil]; _remoteService = [RMTTestService serviceWithHost:kRemoteSSLHost callOptions:nil];
configureCronet(); configureCronet(/*enable_netlog=*/false);
// Default stack with remote host // Default stack with remote host
GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init];

@ -143,8 +143,8 @@ extern const char *kCFStreamVarName;
messageCallback:^(id message) { messageCallback:^(id message) {
int indexCopy; int indexCopy;
@synchronized(self) { @synchronized(self) {
index += 1;
indexCopy = index; indexCopy = index;
index += 1;
} }
if (indexCopy < numMessages) { if (indexCopy < numMessages) {
[call writeMessage:request]; [call writeMessage:request];
@ -181,7 +181,7 @@ extern const char *kCFStreamVarName;
[self pingPongV2APIWithRequest:request numMessages:1000 options:options]; [self pingPongV2APIWithRequest:request numMessages:1000 options:options];
[self measureBlock:^{ [self measureBlock:^{
[self pingPongV2APIWithRequest:request numMessages:10000 options:options]; [self pingPongV2APIWithRequest:request numMessages:1000 options:options];
}]; }];
} }
@ -198,7 +198,7 @@ extern const char *kCFStreamVarName;
[self pingPongV2APIWithRequest:request numMessages:1000 options:options]; [self pingPongV2APIWithRequest:request numMessages:1000 options:options];
[self measureBlock:^{ [self measureBlock:^{
[self pingPongV2APIWithRequest:request numMessages:10000 options:options]; [self pingPongV2APIWithRequest:request numMessages:1000 options:options];
}]; }];
} }
@ -215,7 +215,7 @@ extern const char *kCFStreamVarName;
[self pingPongV2APIWithRequest:request numMessages:1000 options:options]; [self pingPongV2APIWithRequest:request numMessages:1000 options:options];
[self measureBlock:^{ [self measureBlock:^{
[self pingPongV2APIWithRequest:request numMessages:10000 options:options]; [self pingPongV2APIWithRequest:request numMessages:1000 options:options];
}]; }];
} }
@ -254,7 +254,7 @@ extern const char *kCFStreamVarName;
id request = [RMTStreamingOutputCallRequest messageWithPayloadSize:@1 requestedResponseSize:@1]; id request = [RMTStreamingOutputCallRequest messageWithPayloadSize:@1 requestedResponseSize:@1];
[self pingPongV1APIWithRequest:request numMessages:1000]; [self pingPongV1APIWithRequest:request numMessages:1000];
[self measureBlock:^{ [self measureBlock:^{
[self pingPongV1APIWithRequest:request numMessages:10000]; [self pingPongV1APIWithRequest:request numMessages:1000];
}]; }];
} }
@ -298,7 +298,7 @@ extern const char *kCFStreamVarName;
[self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil];
} }
- (void)testUnaryRPC { - (void)test1MBUnaryRPC {
// Workaround Apple CFStream bug // Workaround Apple CFStream bug
if ([self isUsingCFStream]) { if ([self isUsingCFStream]) {
return; return;
@ -329,6 +329,32 @@ extern const char *kCFStreamVarName;
}]; }];
} }
- (void)test1KBUnaryRPC {
RMTSimpleRequest *request = [RMTSimpleRequest message];
request.responseSize = 1024;
request.payload.body = [NSMutableData dataWithLength:1024];
GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init];
options.transport = [[self class] transport];
options.PEMRootCertificates = [[self class] PEMRootCertificates];
options.hostNameOverride = [[self class] hostNameOverride];
// warm up
[self unaryRPCsWithServices:@[ self->_service ]
request:request
callsPerService:1000
maxOutstandingCalls:100
callOptions:options];
[self measureBlock:^{
[self unaryRPCsWithServices:@[ self->_service ]
request:request
callsPerService:1000
maxOutstandingCalls:100
callOptions:options];
}];
}
- (void)testMultipleChannels { - (void)testMultipleChannels {
NSString *port = [[[self class] host] componentsSeparatedByString:@":"][1]; NSString *port = [[[self class] host] componentsSeparatedByString:@":"][1];
int kNumAddrs = 10; int kNumAddrs = 10;

@ -42,7 +42,7 @@ static int32_t kRemoteInteropServerOverhead = 12;
@implementation PerfTestsCronet @implementation PerfTestsCronet
+ (void)setUp { + (void)setUp {
configureCronet(); configureCronet(/*enable_netlog=*/false);
[GRPCCall useCronetWithEngine:[Cronet getGlobalEngine]]; [GRPCCall useCronetWithEngine:[Cronet getGlobalEngine]];
[super setUp]; [super setUp];

Loading…
Cancel
Save