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 {
// 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];

Loading…
Cancel
Save