diff options
author | 2018-11-06 16:43:58 -0800 | |
---|---|---|
committer | 2018-11-06 16:43:58 -0800 | |
commit | d635d9f9f98bc374c0b3502bbcc8f707c27d7038 (patch) | |
tree | 0341bf85ee147d027edcede0c527db14129c72fc /src/objective-c/GRPCClient | |
parent | 515941ae1899ca125e8da77c3031d3f0471488ff (diff) |
fix some threading issues
Diffstat (limited to 'src/objective-c/GRPCClient')
-rw-r--r-- | src/objective-c/GRPCClient/GRPCCall.m | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m index c10fe7c134..b3bddf08a0 100644 --- a/src/objective-c/GRPCClient/GRPCCall.m +++ b/src/objective-c/GRPCClient/GRPCCall.m @@ -468,7 +468,9 @@ const char *kCFStreamVarName = "grpc_cfstream"; - (void)cancelCall { // Can be called from any thread, any number of times. - [_wrappedCall cancel]; + @synchronized (self) { + [_wrappedCall cancel]; + } } - (void)cancel { @@ -730,17 +732,21 @@ const char *kCFStreamVarName = "grpc_cfstream"; _responseWriteable = [[GRXConcurrentWriteable alloc] initWithWriteable:writeable dispatchQueue:_responseQueue]; - _wrappedCall = [[GRPCWrappedCall alloc] initWithHost:_host path:_path callOptions:_callOptions]; - if (_wrappedCall == nil) { + GRPCWrappedCall *wrappedCall = [[GRPCWrappedCall alloc] initWithHost:_host path:_path callOptions:_callOptions]; + if (wrappedCall == nil) { [self maybeFinishWithError:[NSError errorWithDomain:kGRPCErrorDomain code:GRPCErrorCodeUnavailable userInfo:@{ - NSLocalizedDescriptionKey : - @"Failed to create call or channel." - }]]; + NSLocalizedDescriptionKey : + @"Failed to create call or channel." + }]]; return; } + @synchronized (self) { + _wrappedCall = wrappedCall; + } + [self sendHeaders]; [self invokeCall]; |