diff options
author | Alin Balutoiu <abalutoiu@cloudbasesolutions.com> | 2017-08-25 15:02:57 +0000 |
---|---|---|
committer | Alin Gabriel Serdean <aserdean@ovn.org> | 2017-09-13 00:38:37 +0300 |
commit | 0024e9e96fcb43f400e69241ee197a58bf668054 (patch) | |
tree | f433b27039fbd2b064322eaac6bbd9268ddfc757 /python | |
parent | fef22d68717ba23705d70dd9fb7d691dfc31f617 (diff) | |
download | openvswitch-0024e9e96fcb43f400e69241ee197a58bf668054.tar.gz |
windows,python: remove unnecessary code
At the moment we have WSAEventSelect in each if branch.
Since the call to the function is similar, we can move
it outside the if branch and create some local variables
which will be passed to WSAEventSelect.
This patch also remove the keyword argument passed when
the event for the connection overlapped structure is created.
The argument is not needed since it does not change the value
from the default one.
Signed-off-by: Alin Balutoiu <abalutoiu@cloudbasesolutions.com>
Signed-off-by: Alin Gabriel Serdean <aserdean@ovn.org>
Acked-by: Alin Gabriel Serdean <aserdean@ovn.org>
Diffstat (limited to 'python')
-rw-r--r-- | python/ovs/stream.py | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/python/ovs/stream.py b/python/ovs/stream.py index 9d0536d12..cb1cdbe8d 100644 --- a/python/ovs/stream.py +++ b/python/ovs/stream.py @@ -457,29 +457,24 @@ class Stream(object): def __wait_windows(self, poller, wait): if self.socket is not None: if wait == Stream.W_RECV: - read_flags = (win32file.FD_READ | - win32file.FD_ACCEPT | - win32file.FD_CLOSE) - try: - win32file.WSAEventSelect(self.socket, - self._wevent, - read_flags) - except pywintypes.error as e: - vlog.err("failed to associate events with socket: %s" - % e.strerror) - poller.fd_wait(self._wevent, ovs.poller.POLLIN) + mask = (win32file.FD_READ | + win32file.FD_ACCEPT | + win32file.FD_CLOSE) + event = ovs.poller.POLLIN else: - write_flags = (win32file.FD_WRITE | - win32file.FD_CONNECT | - win32file.FD_CLOSE) - try: - win32file.WSAEventSelect(self.socket, - self._wevent, - write_flags) - except pywintypes.error as e: - vlog.err("failed to associate events with socket: %s" - % e.strerror) - poller.fd_wait(self._wevent, ovs.poller.POLLOUT) + mask = (win32file.FD_WRITE | + win32file.FD_CONNECT | + win32file.FD_CLOSE) + event = ovs.poller.POLLOUT + + try: + win32file.WSAEventSelect(self.socket, + self._wevent, + mask) + except pywintypes.error as e: + vlog.err("failed to associate events with socket: %s" + % e.strerror) + poller.fd_wait(self._wevent, event) else: if wait == Stream.W_RECV: if self._read: @@ -549,7 +544,7 @@ class PassiveStream(object): self.socket = sock if pipe is not None: self.connect = pywintypes.OVERLAPPED() - self.connect.hEvent = winutils.get_new_event(bManualReset=True) + self.connect.hEvent = winutils.get_new_event() self.connect_pending = False suffix = name.split(":", 1)[1] suffix = ovs.util.abs_file_name(ovs.dirs.RUNDIR, suffix) |