diff mbox

[ovs-dev,1/2] windows, python: create a different event for sockets

Message ID 1503673364-3166-1-git-send-email-abalutoiu@cloudbasesolutions.com
State Accepted
Headers show

Commit Message

Alin Balutoiu Aug. 25, 2017, 3:02 p.m. UTC
At the moment the sockets on Windows use the same events
that are being created for the pipes.

This is not correct because they should be different events.

This patch introduces a new event which should be used for sockets.
The new event needs to be set on automatic reset with its initial
state not signaled.

Signed-off-by: Alin Balutoiu <abalutoiu@cloudbasesolutions.com>
Co-authored-by: Alin Gabriel Serdean <aserdean@ovn.org>
Signed-off-by: Alin Gabriel Serdean <aserdean@ovn.org>
---
 python/ovs/stream.py | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

Comments

Alin-Gabriel Serdean Aug. 29, 2017, 9:09 a.m. UTC | #1
CC: Russell Bryant <russell@ovn.org>; Lance Richardson <lrichard@redhat.com>

Can you please take a look?

Tested-by: Alin Gabriel Serdean <aserdean@ovn.org>

> -----Original Message-----
> From: ovs-dev-bounces@openvswitch.org [mailto:ovs-dev-
> bounces@openvswitch.org] On Behalf Of Alin Balutoiu
> Sent: Friday, August 25, 2017 6:03 PM
> To: dev@openvswitch.org
> Cc: Alin Gabriel Serdean <aserdean@ovn.org>
> Subject: [ovs-dev] [PATCH 1/2] windows, python: create a different event
> for sockets
> 
> At the moment the sockets on Windows use the same events that are being
> created for the pipes.
> 
> This is not correct because they should be different events.
> 
> This patch introduces a new event which should be used for sockets.
> The new event needs to be set on automatic reset with its initial state
not
> signaled.
> 
> Signed-off-by: Alin Balutoiu <abalutoiu@cloudbasesolutions.com>
> Co-authored-by: Alin Gabriel Serdean <aserdean@ovn.org>
> Signed-off-by: Alin Gabriel Serdean <aserdean@ovn.org>
> ---
>  python/ovs/stream.py | 19 +++++++++++--------
>  1 file changed, 11 insertions(+), 8 deletions(-)
> 
> diff --git a/python/ovs/stream.py b/python/ovs/stream.py index
> 717ea18..9d0536d 100644
> --- a/python/ovs/stream.py
> +++ b/python/ovs/stream.py
> @@ -102,10 +102,6 @@ class Stream(object):
>          self.socket = socket
>          self.pipe = pipe
>          if sys.platform == 'win32':
> -            self._read = pywintypes.OVERLAPPED()
> -            self._read.hEvent = winutils.get_new_event()
> -            self._write = pywintypes.OVERLAPPED()
> -            self._write.hEvent = winutils.get_new_event()
>              if pipe is not None:
>                  # Flag to check if fd is a server HANDLE.  In the case of
a
>                  # server handle we have to issue a disconnect before
closing @@ -
> 114,6 +110,13 @@ class Stream(object):
>                  suffix = name.split(":", 1)[1]
>                  suffix = ovs.util.abs_file_name(ovs.dirs.RUNDIR, suffix)
>                  self._pipename = winutils.get_pipe_name(suffix)
> +                self._read = pywintypes.OVERLAPPED()
> +                self._read.hEvent = winutils.get_new_event()
> +                self._write = pywintypes.OVERLAPPED()
> +                self._write.hEvent = winutils.get_new_event()
> +            else:
> +                self._wevent = winutils.get_new_event(bManualReset=False,
> +
> + bInitialState=False)
> 
>          self.name = name
>          if status == errno.EAGAIN:
> @@ -459,24 +462,24 @@ class Stream(object):
>                                win32file.FD_CLOSE)
>                  try:
>                      win32file.WSAEventSelect(self.socket,
> -                                             self._read.hEvent,
> +                                             self._wevent,
>                                               read_flags)
>                  except pywintypes.error as e:
>                      vlog.err("failed to associate events with socket: %s"
>                               % e.strerror)
> -                poller.fd_wait(self._read.hEvent, ovs.poller.POLLIN)
> +                poller.fd_wait(self._wevent, ovs.poller.POLLIN)
>              else:
>                  write_flags = (win32file.FD_WRITE |
>                                 win32file.FD_CONNECT |
>                                 win32file.FD_CLOSE)
>                  try:
>                      win32file.WSAEventSelect(self.socket,
> -                                             self._write.hEvent,
> +                                             self._wevent,
>                                               write_flags)
>                  except pywintypes.error as e:
>                      vlog.err("failed to associate events with socket: %s"
>                               % e.strerror)
> -                poller.fd_wait(self._write.hEvent, ovs.poller.POLLOUT)
> +                poller.fd_wait(self._wevent, ovs.poller.POLLOUT)
>          else:
>              if wait == Stream.W_RECV:
>                  if self._read:
> --
> 2.10.0.windows.1
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
Russell Bryant Sept. 5, 2017, 6:52 p.m. UTC | #2
Acked-by: Russell Bryant <russell@ovn.org>

On Tue, Aug 29, 2017 at 5:09 AM,  <aserdean@ovn.org> wrote:
> CC: Russell Bryant <russell@ovn.org>; Lance Richardson <lrichard@redhat.com>
>
> Can you please take a look?
>
> Tested-by: Alin Gabriel Serdean <aserdean@ovn.org>
>
>> -----Original Message-----
>> From: ovs-dev-bounces@openvswitch.org [mailto:ovs-dev-
>> bounces@openvswitch.org] On Behalf Of Alin Balutoiu
>> Sent: Friday, August 25, 2017 6:03 PM
>> To: dev@openvswitch.org
>> Cc: Alin Gabriel Serdean <aserdean@ovn.org>
>> Subject: [ovs-dev] [PATCH 1/2] windows, python: create a different event
>> for sockets
>>
>> At the moment the sockets on Windows use the same events that are being
>> created for the pipes.
>>
>> This is not correct because they should be different events.
>>
>> This patch introduces a new event which should be used for sockets.
>> The new event needs to be set on automatic reset with its initial state
> not
>> signaled.
>>
>> Signed-off-by: Alin Balutoiu <abalutoiu@cloudbasesolutions.com>
>> Co-authored-by: Alin Gabriel Serdean <aserdean@ovn.org>
>> Signed-off-by: Alin Gabriel Serdean <aserdean@ovn.org>
>> ---
>>  python/ovs/stream.py | 19 +++++++++++--------
>>  1 file changed, 11 insertions(+), 8 deletions(-)
>>
>> diff --git a/python/ovs/stream.py b/python/ovs/stream.py index
>> 717ea18..9d0536d 100644
>> --- a/python/ovs/stream.py
>> +++ b/python/ovs/stream.py
>> @@ -102,10 +102,6 @@ class Stream(object):
>>          self.socket = socket
>>          self.pipe = pipe
>>          if sys.platform == 'win32':
>> -            self._read = pywintypes.OVERLAPPED()
>> -            self._read.hEvent = winutils.get_new_event()
>> -            self._write = pywintypes.OVERLAPPED()
>> -            self._write.hEvent = winutils.get_new_event()
>>              if pipe is not None:
>>                  # Flag to check if fd is a server HANDLE.  In the case of
> a
>>                  # server handle we have to issue a disconnect before
> closing @@ -
>> 114,6 +110,13 @@ class Stream(object):
>>                  suffix = name.split(":", 1)[1]
>>                  suffix = ovs.util.abs_file_name(ovs.dirs.RUNDIR, suffix)
>>                  self._pipename = winutils.get_pipe_name(suffix)
>> +                self._read = pywintypes.OVERLAPPED()
>> +                self._read.hEvent = winutils.get_new_event()
>> +                self._write = pywintypes.OVERLAPPED()
>> +                self._write.hEvent = winutils.get_new_event()
>> +            else:
>> +                self._wevent = winutils.get_new_event(bManualReset=False,
>> +
>> + bInitialState=False)
>>
>>          self.name = name
>>          if status == errno.EAGAIN:
>> @@ -459,24 +462,24 @@ class Stream(object):
>>                                win32file.FD_CLOSE)
>>                  try:
>>                      win32file.WSAEventSelect(self.socket,
>> -                                             self._read.hEvent,
>> +                                             self._wevent,
>>                                               read_flags)
>>                  except pywintypes.error as e:
>>                      vlog.err("failed to associate events with socket: %s"
>>                               % e.strerror)
>> -                poller.fd_wait(self._read.hEvent, ovs.poller.POLLIN)
>> +                poller.fd_wait(self._wevent, ovs.poller.POLLIN)
>>              else:
>>                  write_flags = (win32file.FD_WRITE |
>>                                 win32file.FD_CONNECT |
>>                                 win32file.FD_CLOSE)
>>                  try:
>>                      win32file.WSAEventSelect(self.socket,
>> -                                             self._write.hEvent,
>> +                                             self._wevent,
>>                                               write_flags)
>>                  except pywintypes.error as e:
>>                      vlog.err("failed to associate events with socket: %s"
>>                               % e.strerror)
>> -                poller.fd_wait(self._write.hEvent, ovs.poller.POLLOUT)
>> +                poller.fd_wait(self._wevent, ovs.poller.POLLOUT)
>>          else:
>>              if wait == Stream.W_RECV:
>>                  if self._read:
>> --
>> 2.10.0.windows.1
>> _______________________________________________
>> dev mailing list
>> dev@openvswitch.org
>> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>
Alin-Gabriel Serdean Sept. 12, 2017, 10:09 p.m. UTC | #3
Thanks Russell and Alin!

I applied the series on master, branch-2.8 and branch-2.7.

Alin.

> -----Original Message-----
> From: ovs-dev-bounces@openvswitch.org [mailto:ovs-dev-
> bounces@openvswitch.org] On Behalf Of Russell Bryant
> Sent: Tuesday, September 5, 2017 9:53 PM
> To: aserdean@ovn.org
> Cc: ovs dev <dev@openvswitch.org>
> Subject: Re: [ovs-dev] [PATCH 1/2] windows, python: create a different
> event for sockets
> 
> Acked-by: Russell Bryant <russell@ovn.org>
> 
> On Tue, Aug 29, 2017 at 5:09 AM,  <aserdean@ovn.org> wrote:
> > CC: Russell Bryant <russell@ovn.org>; Lance Richardson
> > <lrichard@redhat.com>
> >
> > Can you please take a look?
> >
> > Tested-by: Alin Gabriel Serdean <aserdean@ovn.org>
> >
> >> -----Original Message-----
> >> From: ovs-dev-bounces@openvswitch.org [mailto:ovs-dev-
> >> bounces@openvswitch.org] On Behalf Of Alin Balutoiu
> >> Sent: Friday, August 25, 2017 6:03 PM
> >> To: dev@openvswitch.org
> >> Cc: Alin Gabriel Serdean <aserdean@ovn.org>
> >> Subject: [ovs-dev] [PATCH 1/2] windows, python: create a different
> >> event for sockets
> >>
> >> At the moment the sockets on Windows use the same events that are
> >> being created for the pipes.
> >>
> >> This is not correct because they should be different events.
> >>
> >> This patch introduces a new event which should be used for sockets.
> >> The new event needs to be set on automatic reset with its initial
> >> state
> > not
> >> signaled.
> >>
> >> Signed-off-by: Alin Balutoiu <abalutoiu@cloudbasesolutions.com>
> >> Co-authored-by: Alin Gabriel Serdean <aserdean@ovn.org>
> >> Signed-off-by: Alin Gabriel Serdean <aserdean@ovn.org>
diff mbox

Patch

diff --git a/python/ovs/stream.py b/python/ovs/stream.py
index 717ea18..9d0536d 100644
--- a/python/ovs/stream.py
+++ b/python/ovs/stream.py
@@ -102,10 +102,6 @@  class Stream(object):
         self.socket = socket
         self.pipe = pipe
         if sys.platform == 'win32':
-            self._read = pywintypes.OVERLAPPED()
-            self._read.hEvent = winutils.get_new_event()
-            self._write = pywintypes.OVERLAPPED()
-            self._write.hEvent = winutils.get_new_event()
             if pipe is not None:
                 # Flag to check if fd is a server HANDLE.  In the case of a
                 # server handle we have to issue a disconnect before closing
@@ -114,6 +110,13 @@  class Stream(object):
                 suffix = name.split(":", 1)[1]
                 suffix = ovs.util.abs_file_name(ovs.dirs.RUNDIR, suffix)
                 self._pipename = winutils.get_pipe_name(suffix)
+                self._read = pywintypes.OVERLAPPED()
+                self._read.hEvent = winutils.get_new_event()
+                self._write = pywintypes.OVERLAPPED()
+                self._write.hEvent = winutils.get_new_event()
+            else:
+                self._wevent = winutils.get_new_event(bManualReset=False,
+                                                      bInitialState=False)
 
         self.name = name
         if status == errno.EAGAIN:
@@ -459,24 +462,24 @@  class Stream(object):
                               win32file.FD_CLOSE)
                 try:
                     win32file.WSAEventSelect(self.socket,
-                                             self._read.hEvent,
+                                             self._wevent,
                                              read_flags)
                 except pywintypes.error as e:
                     vlog.err("failed to associate events with socket: %s"
                              % e.strerror)
-                poller.fd_wait(self._read.hEvent, ovs.poller.POLLIN)
+                poller.fd_wait(self._wevent, ovs.poller.POLLIN)
             else:
                 write_flags = (win32file.FD_WRITE |
                                win32file.FD_CONNECT |
                                win32file.FD_CLOSE)
                 try:
                     win32file.WSAEventSelect(self.socket,
-                                             self._write.hEvent,
+                                             self._wevent,
                                              write_flags)
                 except pywintypes.error as e:
                     vlog.err("failed to associate events with socket: %s"
                              % e.strerror)
-                poller.fd_wait(self._write.hEvent, ovs.poller.POLLOUT)
+                poller.fd_wait(self._wevent, ovs.poller.POLLOUT)
         else:
             if wait == Stream.W_RECV:
                 if self._read: