Bug fix and better log

reviewable/pr15069/r1
Muxi Yan 7 years ago
parent 03e04b13f4
commit b5f6c1bc46
  1. 26
      src/core/lib/iomgr/tcp_cfstream.cc
  2. 8
      src/core/lib/iomgr/tcp_cfstream_sync.cc

@ -166,10 +166,15 @@ static void ReadAction(void* arg, grpc_error* error) {
if (read_size == -1) {
grpc_slice_buffer_reset_and_unref_internal(tcp->read_slices);
CFErrorRef stream_error = CFReadStreamCopyError(tcp->read_stream);
CallReadCB(tcp, TCPAnnotateError(GRPC_ERROR_CREATE_FROM_CFERROR(
stream_error, "Read error"),
tcp));
CFRelease(stream_error);
if (stream_error != nullptr) {
error = TCPAnnotateError(GRPC_ERROR_CREATE_FROM_CFERROR(
stream_error, "Read error"),
tcp);
CFRelease(stream_error);
} else {
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Read error");
}
CallReadCB(tcp, error);
TCP_UNREF(tcp, "read");
} else if (read_size == 0) {
grpc_slice_buffer_reset_and_unref_internal(tcp->read_slices);
@ -203,10 +208,15 @@ static void WriteAction(void* arg, grpc_error* error) {
if (write_size == -1) {
grpc_slice_buffer_reset_and_unref_internal(tcp->write_slices);
CFErrorRef stream_error = CFWriteStreamCopyError(tcp->write_stream);
CallWriteCB(tcp, TCPAnnotateError(GRPC_ERROR_CREATE_FROM_CFERROR(
stream_error, "write failed."),
tcp));
CFRelease(stream_error);
if (stream_error != nullptr) {
error = TCPAnnotateError(GRPC_ERROR_CREATE_FROM_CFERROR(
stream_error, "write failed."),
tcp);
CFRelease(stream_error);
} else {
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("write failed.");
}
CallWriteCB(tcp, error);
TCP_UNREF(tcp, "write");
} else {
if (write_size < GRPC_SLICE_LENGTH(slice)) {

@ -57,8 +57,8 @@ void CFStreamSync::ReadCallback(CFReadStreamRef stream, CFStreamEventType type,
^{
grpc_core::ExecCtx exec_ctx;
if (grpc_tcp_trace.enabled()) {
gpr_log(GPR_DEBUG, "TCP ReadCallback (%p, %lu, %p)",
stream, type, client_callback_info);
gpr_log(GPR_DEBUG, "TCP ReadCallback (%p, %p, %lu, %p)",
sync, stream, type, client_callback_info);
}
switch (type) {
case kCFStreamEventOpenCompleted:
@ -88,8 +88,8 @@ void CFStreamSync::WriteCallback(CFWriteStreamRef stream,
^{
grpc_core::ExecCtx exec_ctx;
if (grpc_tcp_trace.enabled()) {
gpr_log(GPR_DEBUG, "TCP WriteCallback (%p, %lu, %p)",
stream, type, clientCallBackInfo);
gpr_log(GPR_DEBUG, "TCP WriteCallback (%p, %p, %lu, %p)",
sync, stream, type, clientCallBackInfo);
}
switch (type) {
case kCFStreamEventOpenCompleted:

Loading…
Cancel
Save