|
|
@ -146,7 +146,12 @@ static void on_writable(grpc_exec_ctx *exec_ctx, void *acp, grpc_error *error) { |
|
|
|
grpc_timer_cancel(exec_ctx, &ac->alarm); |
|
|
|
grpc_timer_cancel(exec_ctx, &ac->alarm); |
|
|
|
|
|
|
|
|
|
|
|
gpr_mu_lock(&ac->mu); |
|
|
|
gpr_mu_lock(&ac->mu); |
|
|
|
if (error == GRPC_ERROR_NONE) { |
|
|
|
if (error != GRPC_ERROR_NONE) { |
|
|
|
|
|
|
|
error = |
|
|
|
|
|
|
|
grpc_error_set_str(error, GRPC_ERROR_STR_OS_ERROR, "Timeout occurred"); |
|
|
|
|
|
|
|
goto finish; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
do { |
|
|
|
do { |
|
|
|
so_error_size = sizeof(so_error); |
|
|
|
so_error_size = sizeof(so_error); |
|
|
|
err = getsockopt(grpc_fd_wrapped_fd(fd), SOL_SOCKET, SO_ERROR, &so_error, |
|
|
|
err = getsockopt(grpc_fd_wrapped_fd(fd), SOL_SOCKET, SO_ERROR, &so_error, |
|
|
@ -155,8 +160,15 @@ static void on_writable(grpc_exec_ctx *exec_ctx, void *acp, grpc_error *error) { |
|
|
|
if (err < 0) { |
|
|
|
if (err < 0) { |
|
|
|
error = GRPC_OS_ERROR(errno, "getsockopt"); |
|
|
|
error = GRPC_OS_ERROR(errno, "getsockopt"); |
|
|
|
goto finish; |
|
|
|
goto finish; |
|
|
|
} else if (so_error != 0) { |
|
|
|
} |
|
|
|
if (so_error == ENOBUFS) { |
|
|
|
|
|
|
|
|
|
|
|
switch (so_error) { |
|
|
|
|
|
|
|
case 0: |
|
|
|
|
|
|
|
grpc_pollset_set_del_fd(exec_ctx, ac->interested_parties, fd); |
|
|
|
|
|
|
|
*ep = grpc_tcp_create(fd, GRPC_TCP_DEFAULT_READ_SLICE_SIZE, ac->addr_str); |
|
|
|
|
|
|
|
fd = NULL; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case ENOBUFS: |
|
|
|
/* We will get one of these errors if we have run out of
|
|
|
|
/* We will get one of these errors if we have run out of
|
|
|
|
memory in the kernel for the data structures allocated |
|
|
|
memory in the kernel for the data structures allocated |
|
|
|
when you connect a socket. If this happens it is very |
|
|
|
when you connect a socket. If this happens it is very |
|
|
@ -175,32 +187,16 @@ static void on_writable(grpc_exec_ctx *exec_ctx, void *acp, grpc_error *error) { |
|
|
|
gpr_mu_unlock(&ac->mu); |
|
|
|
gpr_mu_unlock(&ac->mu); |
|
|
|
grpc_fd_notify_on_write(exec_ctx, fd, &ac->write_closure); |
|
|
|
grpc_fd_notify_on_write(exec_ctx, fd, &ac->write_closure); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} else { |
|
|
|
|
|
|
|
switch (so_error) { |
|
|
|
|
|
|
|
case ECONNREFUSED: |
|
|
|
case ECONNREFUSED: |
|
|
|
error = grpc_error_set_int(error, GRPC_ERROR_INT_ERRNO, errno); |
|
|
|
/* This error shouldn't happen for anything other than connect(). */ |
|
|
|
error = grpc_error_set_str(error, GRPC_ERROR_STR_OS_ERROR, |
|
|
|
error = GRPC_OS_ERROR(so_error, "connect"); |
|
|
|
"Connection refused"); |
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
default: |
|
|
|
default: |
|
|
|
error = GRPC_OS_ERROR(errno, "getsockopt(SO_ERROR)"); |
|
|
|
/* We don't really know which syscall triggered the problem here,
|
|
|
|
|
|
|
|
so punt by reporting getsockopt(). */ |
|
|
|
|
|
|
|
error = GRPC_OS_ERROR(so_error, "getsockopt(SO_ERROR)"); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
goto finish; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
grpc_pollset_set_del_fd(exec_ctx, ac->interested_parties, fd); |
|
|
|
|
|
|
|
*ep = grpc_tcp_create(fd, GRPC_TCP_DEFAULT_READ_SLICE_SIZE, ac->addr_str); |
|
|
|
|
|
|
|
fd = NULL; |
|
|
|
|
|
|
|
goto finish; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
error = |
|
|
|
|
|
|
|
grpc_error_set_str(error, GRPC_ERROR_STR_OS_ERROR, "Timeout occurred"); |
|
|
|
|
|
|
|
goto finish; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GPR_UNREACHABLE_CODE(return ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
finish: |
|
|
|
finish: |
|
|
|
if (fd != NULL) { |
|
|
|
if (fd != NULL) { |
|
|
|