fix some threading issues

pull/16190/head
Muxi Yan 6 years ago
parent 515941ae18
commit d635d9f9f9
  1. 18
      src/objective-c/GRPCClient/GRPCCall.m

@ -468,7 +468,9 @@ const char *kCFStreamVarName = "grpc_cfstream";
- (void)cancelCall { - (void)cancelCall {
// Can be called from any thread, any number of times. // Can be called from any thread, any number of times.
[_wrappedCall cancel]; @synchronized (self) {
[_wrappedCall cancel];
}
} }
- (void)cancel { - (void)cancel {
@ -730,17 +732,21 @@ const char *kCFStreamVarName = "grpc_cfstream";
_responseWriteable = _responseWriteable =
[[GRXConcurrentWriteable alloc] initWithWriteable:writeable dispatchQueue:_responseQueue]; [[GRXConcurrentWriteable alloc] initWithWriteable:writeable dispatchQueue:_responseQueue];
_wrappedCall = [[GRPCWrappedCall alloc] initWithHost:_host path:_path callOptions:_callOptions]; GRPCWrappedCall *wrappedCall = [[GRPCWrappedCall alloc] initWithHost:_host path:_path callOptions:_callOptions];
if (_wrappedCall == nil) { if (wrappedCall == nil) {
[self maybeFinishWithError:[NSError errorWithDomain:kGRPCErrorDomain [self maybeFinishWithError:[NSError errorWithDomain:kGRPCErrorDomain
code:GRPCErrorCodeUnavailable code:GRPCErrorCodeUnavailable
userInfo:@{ userInfo:@{
NSLocalizedDescriptionKey : NSLocalizedDescriptionKey :
@"Failed to create call or channel." @"Failed to create call or channel."
}]]; }]];
return; return;
} }
@synchronized (self) {
_wrappedCall = wrappedCall;
}
[self sendHeaders]; [self sendHeaders];
[self invokeCall]; [self invokeCall];

Loading…
Cancel
Save