mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 22:35:15 +00:00
socket-util: Avoid using SO_ERROR.
ESX doesn't implement it, and there's another approach that should work everywhere, so drop back to that. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
This commit is contained in:
@@ -221,6 +221,7 @@ get_socket_error(int fd)
|
|||||||
int
|
int
|
||||||
check_connection_completion(int fd)
|
check_connection_completion(int fd)
|
||||||
{
|
{
|
||||||
|
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 10);
|
||||||
struct pollfd pfd;
|
struct pollfd pfd;
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
@@ -230,9 +231,17 @@ check_connection_completion(int fd)
|
|||||||
retval = poll(&pfd, 1, 0);
|
retval = poll(&pfd, 1, 0);
|
||||||
} while (retval < 0 && errno == EINTR);
|
} while (retval < 0 && errno == EINTR);
|
||||||
if (retval == 1) {
|
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) {
|
} else if (retval < 0) {
|
||||||
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 10);
|
|
||||||
VLOG_ERR_RL(&rl, "poll: %s", strerror(errno));
|
VLOG_ERR_RL(&rl, "poll: %s", strerror(errno));
|
||||||
return errno;
|
return errno;
|
||||||
} else {
|
} else {
|
||||||
|
@@ -78,8 +78,22 @@ def make_unix_socket(style, nonblock, bind_path, connect_path):
|
|||||||
def check_connection_completion(sock):
|
def check_connection_completion(sock):
|
||||||
p = ovs.poller.SelectPoll()
|
p = ovs.poller.SelectPoll()
|
||||||
p.register(sock, ovs.poller.POLLOUT)
|
p.register(sock, ovs.poller.POLLOUT)
|
||||||
if len(p.poll(0)) == 1:
|
pfds = p.poll(0)
|
||||||
return get_socket_error(sock)
|
if len(pfds) == 1:
|
||||||
|
revents = pfds[0][1]
|
||||||
|
if revents & ovs.poller.POLLERR:
|
||||||
|
try:
|
||||||
|
# The following should raise an exception.
|
||||||
|
socket.send("\0", socket.MSG_DONTWAIT)
|
||||||
|
|
||||||
|
# (Here's where we end up if it didn't.)
|
||||||
|
# XXX rate-limit
|
||||||
|
vlog.err("poll return POLLERR but send succeeded")
|
||||||
|
return errno.EPROTO
|
||||||
|
except socket.error, e:
|
||||||
|
return get_exception_errno(e)
|
||||||
|
else:
|
||||||
|
return 0
|
||||||
else:
|
else:
|
||||||
return errno.EAGAIN
|
return errno.EAGAIN
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user