diff options
author | Ilya Maximets <i.maximets@samsung.com> | 2018-12-21 16:09:50 +0300 |
---|---|---|
committer | Ben Pfaff <blp@ovn.org> | 2018-12-24 11:50:43 -0800 |
commit | cfef5ae8f0e3954b829a60df702ffea4cd02d4d6 (patch) | |
tree | 71e5c98b68577650101666a5e5460cf8a53d5cd5 /lib | |
parent | 05aec0e5a7a444e7506ea8ec1584a70151956952 (diff) | |
download | openvswitch-cfef5ae8f0e3954b829a60df702ffea4cd02d4d6.tar.gz |
socket-util: Report POLLHUP as an error while connection completion checking.
Otherwise failed non-blocking connection could be reported as
connected. This causes errors in all following operations with the
socket.
At least this is true on FreeBSD, where POLLHUP could be set without
POLLERR.
For example, stream_open_block() tests fails with the following error
reporting successful connection to the 'WRONG_PORT':
./ovsdb-idl.at:1817:
$PYTHON2 $srcdir/test-stream.py tcp:127.0.0.1:$WRONG_PORT
stdout:
./ovsdb-idl.at:1817: exit code was 0, expected 1
2399. ovsdb-idl.at:1817: FAILED (ovsdb-idl.at:1817)
Also added new tests to track this issue in C library:
'Check Stream open block - C - tcp'
'Check Stream open block - C - tcp6'
CC: Numan Siddique <nusiddiq@redhat.com>
Fixes: c1aa16d191d2 ("ovs python: ovs.stream.open_block() returns success even if the remote is unreachable")
Fixes: d6cedfd9d29d ("socket-util: Avoid using SO_ERROR.")
Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/socket-util.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/socket-util.c b/lib/socket-util.c index 8d18e043d..09daa3c90 100644 --- a/lib/socket-util.c +++ b/lib/socket-util.c @@ -285,7 +285,7 @@ check_connection_completion(int fd) } #endif if (retval == 1) { - if (pfd.revents & POLLERR) { + if (pfd.revents & (POLLERR | POLLHUP)) { ssize_t n = send(fd, "", 1, 0); if (n < 0) { return sock_errno(); |