Merge pull request #15718 from muxi/backport-15714

Backport #15714 to v1.13.x
pull/15765/head
Muxi Yan 7 years ago committed by GitHub
commit 396694f288
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      src/core/lib/iomgr/cfstream_handle.cc
  2. 14
      src/core/lib/iomgr/tcp_client_cfstream.cc
  3. 3
      src/objective-c/tests/GRPCClientTests.m

@ -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 |

@ -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);

@ -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

Loading…
Cancel
Save