|
|
|
@ -448,7 +448,7 @@ const char *kCFStreamVarName = "grpc_cfstream"; |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
NSString *hostAndPath = [NSString stringWithFormat:@"%@/%@", host, path]; |
|
|
|
|
@synchronized (callFlags) { |
|
|
|
|
@synchronized(callFlags) { |
|
|
|
|
switch (callSafety) { |
|
|
|
|
case GRPCCallSafetyDefault: |
|
|
|
|
callFlags[hostAndPath] = @0; |
|
|
|
@ -468,7 +468,7 @@ const char *kCFStreamVarName = "grpc_cfstream"; |
|
|
|
|
+ (uint32_t)callFlagsForHost:(NSString *)host path:(NSString *)path { |
|
|
|
|
NSString *hostAndPath = [NSString stringWithFormat:@"%@/%@", host, path]; |
|
|
|
|
uint32_t flags = 0; |
|
|
|
|
@synchronized (callFlags) { |
|
|
|
|
@synchronized(callFlags) { |
|
|
|
|
flags = [callFlags[hostAndPath] intValue]; |
|
|
|
|
} |
|
|
|
|
return flags; |
|
|
|
@ -529,7 +529,7 @@ const char *kCFStreamVarName = "grpc_cfstream"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
- (void)setResponseDispatchQueue:(dispatch_queue_t)queue { |
|
|
|
|
@synchronized (self) { |
|
|
|
|
@synchronized(self) { |
|
|
|
|
if (_state != GRXWriterStateNotStarted) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
@ -562,7 +562,7 @@ const char *kCFStreamVarName = "grpc_cfstream"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
- (void)cancel { |
|
|
|
|
@synchronized (self) { |
|
|
|
|
@synchronized(self) { |
|
|
|
|
if (_state == GRXWriterStateFinished) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
@ -636,7 +636,7 @@ const char *kCFStreamVarName = "grpc_cfstream"; |
|
|
|
|
// don't want to throw, because the app shouldn't crash for a behavior |
|
|
|
|
// that's on the hands of any server to have. Instead we finish and ask |
|
|
|
|
// the server to cancel. |
|
|
|
|
@synchronized (strongSelf) { |
|
|
|
|
@synchronized(strongSelf) { |
|
|
|
|
[strongSelf |
|
|
|
|
finishWithError:[NSError errorWithDomain:kGRPCErrorDomain |
|
|
|
|
code:GRPCErrorCodeResourceExhausted |
|
|
|
@ -648,7 +648,7 @@ const char *kCFStreamVarName = "grpc_cfstream"; |
|
|
|
|
[strongSelf->_wrappedCall cancel]; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
@synchronized (strongSelf) { |
|
|
|
|
@synchronized(strongSelf) { |
|
|
|
|
[strongSelf->_responseWriteable enqueueValue:data |
|
|
|
|
completionHandler:^{ |
|
|
|
|
[strongSelf startNextRead]; |
|
|
|
@ -689,7 +689,8 @@ const char *kCFStreamVarName = "grpc_cfstream"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// TODO(jcanizales): Add error handlers for async failures |
|
|
|
|
GRPCOpSendMetadata *op = [[GRPCOpSendMetadata alloc] initWithMetadata:headers |
|
|
|
|
GRPCOpSendMetadata *op = [[GRPCOpSendMetadata alloc] |
|
|
|
|
initWithMetadata:headers |
|
|
|
|
flags:callSafetyFlags |
|
|
|
|
handler:nil]; // No clean-up needed after SEND_INITIAL_METADATA |
|
|
|
|
dispatch_async(_callQueue, ^{ |
|
|
|
@ -731,7 +732,7 @@ const char *kCFStreamVarName = "grpc_cfstream"; |
|
|
|
|
- (void)writeValue:(id)value { |
|
|
|
|
NSAssert([value isKindOfClass:[NSData class]], @"value must be of type NSData"); |
|
|
|
|
|
|
|
|
|
@synchronized (self) { |
|
|
|
|
@synchronized(self) { |
|
|
|
|
if (_state == GRXWriterStateFinished) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
@ -825,7 +826,7 @@ const char *kCFStreamVarName = "grpc_cfstream"; |
|
|
|
|
|
|
|
|
|
// Lock acquired inside startWithWriteable: |
|
|
|
|
- (void)startCallWithWriteable:(id<GRXWriteable>)writeable { |
|
|
|
|
@synchronized (self) { |
|
|
|
|
@synchronized(self) { |
|
|
|
|
if (_state == GRXWriterStateFinished) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
@ -869,10 +870,10 @@ const char *kCFStreamVarName = "grpc_cfstream"; |
|
|
|
|
_state = GRXWriterStateStarted; |
|
|
|
|
|
|
|
|
|
// Create a retain cycle so that this instance lives until the RPC finishes (or is cancelled). |
|
|
|
|
// This makes RPCs in which the call isn't externally retained possible (as long as it is started |
|
|
|
|
// before being autoreleased). |
|
|
|
|
// Care is taken not to retain self strongly in any of the blocks used in this implementation, so |
|
|
|
|
// that the life of the instance is determined by this retain cycle. |
|
|
|
|
// This makes RPCs in which the call isn't externally retained possible (as long as it is |
|
|
|
|
// started before being autoreleased). Care is taken not to retain self strongly in any of the |
|
|
|
|
// blocks used in this implementation, so that the life of the instance is determined by this |
|
|
|
|
// retain cycle. |
|
|
|
|
_retainSelf = self; |
|
|
|
|
|
|
|
|
|
if (_callOptions == nil) { |
|
|
|
@ -961,7 +962,7 @@ const char *kCFStreamVarName = "grpc_cfstream"; |
|
|
|
|
// Retain because connectivity manager only keeps weak reference to GRPCCall. |
|
|
|
|
__strong GRPCCall *strongSelf = self; |
|
|
|
|
if (strongSelf) { |
|
|
|
|
@synchronized (strongSelf) { |
|
|
|
|
@synchronized(strongSelf) { |
|
|
|
|
[_wrappedCall cancel]; |
|
|
|
|
[strongSelf |
|
|
|
|
finishWithError:[NSError errorWithDomain:kGRPCErrorDomain |
|
|
|
|