Lock GRPCCall in GRPCAuthorizatioProtocol

pull/16190/head
Muxi Yan 6 years ago
parent 62693ec1bd
commit 67a4eb6623
  1. 6
      src/objective-c/GRPCClient/GRPCCall.m

@ -461,11 +461,13 @@ const char *kCFStreamVarName = "grpc_cfstream";
}
- (void)cancel {
@synchronized (self) {
if (!self.isWaitingForToken) {
[self cancelCall];
} else {
self.isWaitingForToken = NO;
}
}
[self
maybeFinishWithError:[NSError
errorWithDomain:kGRPCErrorDomain
@ -779,8 +781,11 @@ const char *kCFStreamVarName = "grpc_cfstream";
_callOptions = callOptions;
}
if (_callOptions.authTokenProvider != nil) {
@synchronized (self) {
self.isWaitingForToken = YES;
}
[self.tokenProvider getTokenWithHandler:^(NSString *token) {
@synchronized (self) {
if (self.isWaitingForToken) {
if (token) {
self->_fetchedOauth2AccessToken = [token copy];
@ -788,6 +793,7 @@ const char *kCFStreamVarName = "grpc_cfstream";
[self startCallWithWriteable:writeable];
self.isWaitingForToken = NO;
}
}
}];
} else {
[self startCallWithWriteable:writeable];

Loading…
Cancel
Save