forked from openvswitch/ovs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ovs python: ovs.stream.open_block() returns success even if the remot…
…e 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 <[email protected]> Signed-off-by: Numan Siddique <[email protected]> Signed-off-by: Ben Pfaff <[email protected]> Acked-by: Mark Michelson <[email protected]>
- Loading branch information
1 parent
44a629b
commit c1aa16d
Showing
6 changed files
with
94 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Copyright (c) 2018, Red Hat Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at: | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import sys | ||
|
||
import ovs.stream | ||
|
||
|
||
def main(argv): | ||
remote = argv[1] | ||
err, stream = ovs.stream.Stream.open_block( | ||
ovs.stream.Stream.open(remote)) | ||
|
||
if err or stream is None: | ||
sys.exit(1) | ||
|
||
sys.exit(0) | ||
|
||
|
||
if __name__ == '__main__': | ||
main(sys.argv) |