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

Loading…
Cancel
Save