From 831940a73194fa5d24419fa3f0a08e1ce3a41958 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Tue, 24 Oct 2017 11:05:51 -0700 Subject: [PATCH] Fix some tsan problems in gRPC ObjC --- src/objective-c/GRPCClient/GRPCCall.m | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m index d6c3a3c165a..f1f7b5d08d2 100644 --- a/src/objective-c/GRPCClient/GRPCCall.m +++ b/src/objective-c/GRPCClient/GRPCCall.m @@ -244,9 +244,12 @@ static NSString * const kBearerPrefix = @"Bearer "; // method. // TODO(jcanizales): Rename to readResponseIfNotPaused. - (void)startNextRead { - if (self.state == GRXWriterStatePaused) { - return; + @synchronized(self) { + if (self.state == GRXWriterStatePaused) { + return; + } } + __weak GRPCCall *weakSelf = self; __weak GRXConcurrentWriteable *weakWriteable = _responseWriteable;