X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fsocket-util.c;h=48f42f195c6b0b45e03a5703c91a3d7490fc9a23;hb=2e1ae2005ed347d2dfebd23fff40c54a1a2a6716;hp=4edf956b555f69beaaabbfd54eefc0837bc615c4;hpb=ce78d135fc990505372e404de977a85841c49c24;p=openvswitch diff --git a/lib/socket-util.c b/lib/socket-util.c index 4edf956b..48f42f19 100644 --- a/lib/socket-util.c +++ b/lib/socket-util.c @@ -205,22 +205,10 @@ lookup_hostname(const char *host_name, struct in_addr *addr) : EINVAL); } -/* Returns the error condition associated with socket 'fd' and resets the - * socket's error status. */ -int -get_socket_error(int fd) -{ - int error; - - if (getsockopt_int(fd, SOL_SOCKET, SO_ERROR, "SO_ERROR", &error)) { - error = errno; - } - return error; -} - int check_connection_completion(int fd) { + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 10); struct pollfd pfd; int retval; @@ -230,9 +218,17 @@ check_connection_completion(int fd) retval = poll(&pfd, 1, 0); } while (retval < 0 && errno == EINTR); if (retval == 1) { - return get_socket_error(fd); + if (pfd.revents & POLLERR) { + ssize_t n = send(fd, "", 1, MSG_DONTWAIT); + if (n < 0) { + return errno; + } else { + VLOG_ERR_RL(&rl, "poll return POLLERR but send succeeded"); + return EPROTO; + } + } + return 0; } else if (retval < 0) { - static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 10); VLOG_ERR_RL(&rl, "poll: %s", strerror(errno)); return errno; } else {