]> git.proxmox.com Git - mirror_ovs.git/commit - tests/ovsdb-idl.at
ovs python: ovs.stream.open_block() returns success even if the remote is unreachable
authorNuman Siddique <nusiddiq@redhat.com>
Tue, 7 Aug 2018 11:37:58 +0000 (17:07 +0530)
committerBen Pfaff <blp@ovn.org>
Tue, 14 Aug 2018 18:47:12 +0000 (11:47 -0700)
commitc1aa16d191d267d76ce1d1459fe9ed6ab93e1f54
tree1a77d28cf1220e4f4aa5ea053d169dccb5ad9c7c
parent44a629b5b80b4b37f99bc5631dee8bb055940329
ovs python: ovs.stream.open_block() returns success even if the remote is unreachable

The python function ovs.socket_util.check_connection_completion() uses select()
(provided by python) to monitor the socket file descriptor. The select()
returns 1 when the file descriptor becomes ready. For error cases like -
111 (Connection refused) and 113 (No route to host) (POLLERR), ovs.poller._SelectSelect.poll()
expects the exceptfds list to be set by select(). But that is not the case.
As per the select() man page, writefds list will be set for POLLERR.
Please see "Correspondence between select() and poll() notifications" section of select(2)
man page.

Because of this behavior, ovs.socket_util.check_connection_completion() returns success
even if the remote is unreachable or not listening on the port.

This patch fixes this issue by using poll() to check the connection status similar to
the C implementation of check_connection_completion().

A new function 'get_system_poll() is added in ovs/poller.py which returns the
select.poll() object. If select.poll is monkey patched by eventlet/gevent, it
gets the original select.poll() and returns it.

The test cases added in this patch fails without the fix.

Suggested-by: Ben Pfaff <blp@ovn.org>
Signed-off-by: Numan Siddique <nusiddiq@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Mark Michelson <mmichels@redhat.com>
python/ovs/poller.py
python/ovs/socket_util.py
python/ovs/stream.py
tests/automake.mk
tests/ovsdb-idl.at
tests/test-stream.py [new file with mode: 0644]