Handle GRPCCall2:start: twice

pull/16190/head
Muxi Yan 6 years ago
parent efa359b02b
commit eab498bef4
  1. 2
      src/objective-c/GRPCClient/GRPCCall.h
  2. 6
      src/objective-c/GRPCClient/GRPCCall.m

@ -235,7 +235,7 @@ extern id const kGRPCTrailersKey;
responseHandler:(id<GRPCResponseHandler>)responseHandler;
/**
* Starts the call. Can only be called once.
* Starts the call. This function should only be called once; additional calls will be discarded.
*/
- (void)start;

@ -92,6 +92,7 @@ const char *kCFStreamVarName = "grpc_cfstream";
BOOL _initialMetadataPublished;
GRXBufferedPipe *_pipe;
dispatch_queue_t _dispatchQueue;
bool _started;
}
- (instancetype)initWithRequestOptions:(GRPCRequestOptions *)requestOptions
@ -108,6 +109,7 @@ const char *kCFStreamVarName = "grpc_cfstream";
_initialMetadataPublished = NO;
_pipe = [GRXBufferedPipe pipe];
_dispatchQueue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL);
_started = NO;
}
return self;
@ -120,6 +122,10 @@ const char *kCFStreamVarName = "grpc_cfstream";
- (void)start {
dispatch_async(_dispatchQueue, ^{
if (self->_started) {
return;
}
self->_started = YES;
if (!self->_callOptions) {
self->_callOptions = [[GRPCCallOptions alloc] init];
}

Loading…
Cancel
Save