Lock GRPCCall in GRPCAuthorizatioProtocol

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

@ -461,10 +461,12 @@ const char *kCFStreamVarName = "grpc_cfstream";
} }
- (void)cancel { - (void)cancel {
if (!self.isWaitingForToken) { @synchronized (self) {
[self cancelCall]; if (!self.isWaitingForToken) {
} else { [self cancelCall];
self.isWaitingForToken = NO; } else {
self.isWaitingForToken = NO;
}
} }
[self [self
maybeFinishWithError:[NSError maybeFinishWithError:[NSError
@ -779,14 +781,18 @@ const char *kCFStreamVarName = "grpc_cfstream";
_callOptions = callOptions; _callOptions = callOptions;
} }
if (_callOptions.authTokenProvider != nil) { if (_callOptions.authTokenProvider != nil) {
self.isWaitingForToken = YES; @synchronized (self) {
self.isWaitingForToken = YES;
}
[self.tokenProvider getTokenWithHandler:^(NSString *token) { [self.tokenProvider getTokenWithHandler:^(NSString *token) {
if (self.isWaitingForToken) { @synchronized (self) {
if (token) { if (self.isWaitingForToken) {
self->_fetchedOauth2AccessToken = [token copy]; if (token) {
self->_fetchedOauth2AccessToken = [token copy];
}
[self startCallWithWriteable:writeable];
self.isWaitingForToken = NO;
} }
[self startCallWithWriteable:writeable];
self.isWaitingForToken = NO;
} }
}]; }];
} else { } else {

Loading…
Cancel
Save