2
0
mirror of https://github.com/openvswitch/ovs synced 2025-09-01 06:45:17 +00:00

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: c1aa16d191 ("ovs python: ovs.stream.open_block() returns success even if the remote is unreachable")
Fixes: d6cedfd9d2 ("socket-util: Avoid using SO_ERROR.")
Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
This commit is contained in:
Ilya Maximets
2018-12-21 16:09:50 +03:00
committed by Ben Pfaff
parent 05aec0e5a7
commit cfef5ae8f0
6 changed files with 70 additions and 2 deletions

View File

@@ -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();