aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Muxi Yan <mxyan@google.com>2018-06-11 14:24:25 -0700
committerGravatar Muxi Yan <mxyan@google.com>2018-06-11 15:51:59 -0700
commit7174ed5ded78b61307785d4f3e4ecbdcea6a3f83 (patch)
tree415d6b56cb340b4905a7dfae335c4794f14ffdc2
parent3137d59be9e476157de78016ab3f23a7d340d78f (diff)
Backport #15714 to v1.13.x
-rw-r--r--src/core/lib/iomgr/cfstream_handle.cc4
-rw-r--r--src/core/lib/iomgr/tcp_client_cfstream.cc14
-rw-r--r--src/objective-c/tests/GRPCClientTests.m3
3 files changed, 12 insertions, 9 deletions
diff --git a/src/core/lib/iomgr/cfstream_handle.cc b/src/core/lib/iomgr/cfstream_handle.cc
index 30f4e65632..827fd24831 100644
--- a/src/core/lib/iomgr/cfstream_handle.cc
+++ b/src/core/lib/iomgr/cfstream_handle.cc
@@ -116,7 +116,9 @@ CFStreamHandle::CFStreamHandle(CFReadStreamRef read_stream,
open_event_.InitEvent();
read_event_.InitEvent();
write_event_.InitEvent();
- CFStreamClientContext ctx = {0, static_cast<void*>(this), nil, nil, nil};
+ CFStreamClientContext ctx = {0, static_cast<void*>(this),
+ CFStreamHandle::Retain, CFStreamHandle::Release,
+ nil};
CFReadStreamSetClient(
read_stream,
kCFStreamEventOpenCompleted | kCFStreamEventHasBytesAvailable |
diff --git a/src/core/lib/iomgr/tcp_client_cfstream.cc b/src/core/lib/iomgr/tcp_client_cfstream.cc
index ffed3bbef6..5acea91792 100644
--- a/src/core/lib/iomgr/tcp_client_cfstream.cc
+++ b/src/core/lib/iomgr/tcp_client_cfstream.cc
@@ -52,7 +52,7 @@ typedef struct CFStreamConnect {
CFReadStreamRef read_stream;
CFWriteStreamRef write_stream;
- CFStreamHandle* stream_sync;
+ CFStreamHandle* stream_handle;
grpc_timer alarm;
grpc_closure on_alarm;
@@ -71,7 +71,7 @@ typedef struct CFStreamConnect {
static void CFStreamConnectCleanup(CFStreamConnect* connect) {
grpc_resource_quota_unref_internal(connect->resource_quota);
- CFSTREAM_HANDLE_UNREF(connect->stream_sync, "async connect clean up");
+ CFSTREAM_HANDLE_UNREF(connect->stream_handle, "async connect clean up");
CFRelease(connect->read_stream);
CFRelease(connect->write_stream);
gpr_mu_destroy(&connect->mu);
@@ -131,7 +131,7 @@ static void OnOpen(void* arg, grpc_error* error) {
if (error == GRPC_ERROR_NONE) {
*endpoint = grpc_cfstream_endpoint_create(
connect->read_stream, connect->write_stream, connect->addr_name,
- connect->resource_quota, connect->stream_sync);
+ connect->resource_quota, connect->stream_handle);
}
} else {
GRPC_ERROR_REF(error);
@@ -170,8 +170,8 @@ static void CFStreamClientConnect(grpc_closure* closure, grpc_endpoint** ep,
gpr_mu_init(&connect->mu);
if (grpc_tcp_trace.enabled()) {
- gpr_log(GPR_DEBUG, "CLIENT_CONNECT: %s: asynchronously connecting",
- connect->addr_name);
+ gpr_log(GPR_DEBUG, "CLIENT_CONNECT: %p, %s: asynchronously connecting",
+ connect, connect->addr_name);
}
grpc_resource_quota* resource_quota = grpc_resource_quota_create(NULL);
@@ -197,11 +197,11 @@ static void CFStreamClientConnect(grpc_closure* closure, grpc_endpoint** ep,
CFRelease(host);
connect->read_stream = read_stream;
connect->write_stream = write_stream;
- connect->stream_sync =
+ connect->stream_handle =
CFStreamHandle::CreateStreamHandle(read_stream, write_stream);
GRPC_CLOSURE_INIT(&connect->on_open, OnOpen, static_cast<void*>(connect),
grpc_schedule_on_exec_ctx);
- connect->stream_sync->NotifyOnOpen(&connect->on_open);
+ connect->stream_handle->NotifyOnOpen(&connect->on_open);
GRPC_CLOSURE_INIT(&connect->on_alarm, OnAlarm, connect,
grpc_schedule_on_exec_ctx);
gpr_mu_lock(&connect->mu);
diff --git a/src/objective-c/tests/GRPCClientTests.m b/src/objective-c/tests/GRPCClientTests.m
index 5cd0231db7..d9186561c3 100644
--- a/src/objective-c/tests/GRPCClientTests.m
+++ b/src/objective-c/tests/GRPCClientTests.m
@@ -525,7 +525,8 @@ static GRPCProtoMethod *kFullDuplexCallMethod;
- (void)testErrorCode {
int port = [self findFreePort];
NSString *const kDummyAddress = [NSString stringWithFormat:@"localhost:%d", port];
- __weak XCTestExpectation *completion = [self expectationWithDescription:@"Empty RPC completed."];
+ __weak XCTestExpectation *completion =
+ [self expectationWithDescription:@"Received correct error code."];
GRPCCall *call = [[GRPCCall alloc] initWithHost:kDummyAddress
path:kEmptyCallMethod.HTTPPath