Message ID | 20161216025016.7844-1-aserdean@cloudbasesolutions.com |
---|---|
State | Accepted |
Delegated to: | Guru Shetty |
Headers | show |
On 15 December 2016 at 18:50, Alin Serdean <aserdean@cloudbasesolutions.com> wrote: > Unfortunately, WSAPoll misbehaves on Windows please view detailed behavior > on: https://github.com/openvswitch/ovs-issues/issues/117 > > We replace the WSAPoll with select looking only for errors and write > events. > > Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com> > Reported-at: https://github.com/openvswitch/ovs-issues/issues/117 > Reported-by: Yin Lin <linyi@vmware.com> > Does the select system call in Windows work with named pipes? On that line, did it work with WSAPoll? > --- > lib/socket-util.c | 18 +++++++++++++++++- > 1 file changed, 17 insertions(+), 1 deletion(-) > > diff --git a/lib/socket-util.c b/lib/socket-util.c > index 5a36f3b..2c0f1e6 100644 > --- a/lib/socket-util.c > +++ b/lib/socket-util.c > @@ -253,7 +253,23 @@ check_connection_completion(int fd) > retval = poll(&pfd, 1, 0); > } while (retval < 0 && errno == EINTR); > #else > - retval = WSAPoll(&pfd, 1, 0); > + fd_set wrset, exset; > + FD_ZERO(&wrset); > + FD_ZERO(&exset); > + FD_SET(fd, &exset); > + FD_SET(fd, &wrset); > + pfd.revents = 0; > + struct timeval tv = { 0, 0 }; > + /* WSAPoll is broken on Windows, instead do a select */ > + retval = select(0, NULL, &wrset, &exset, &tv); > + if (retval == 1) { > + if (FD_ISSET(fd, &wrset)) { > + pfd.revents |= pfd.events; > + } > + if (FD_ISSET(fd, &exset)) { > + pfd.revents |= POLLERR; > + } > + } > #endif > if (retval == 1) { > if (pfd.revents & POLLERR) { > -- > 2.10.2.windows.1 > _______________________________________________ > dev mailing list > dev@openvswitch.org > https://mail.openvswitch.org/mailman/listinfo/ovs-dev >
Hi Guru, Sorry for the delayed response. Named pipes do not use WSAPoll, nor will it use select. I ran all the unit tests after I switched from WSAPoll to select and all was green. Isolation testing using select rather than WSAPoll show no increase in CPU consumption. Thanks, Alin. From: Guru Shetty [mailto:guru@ovn.org] Sent: Tuesday, December 20, 2016 7:30 PM To: Alin Serdean <aserdean@cloudbasesolutions.com> Cc: dev@openvswitch.org Subject: Re: [ovs-dev] [PATCH] windows: WSAPoll broken on windows On 15 December 2016 at 18:50, Alin Serdean <aserdean@cloudbasesolutions.com<mailto:aserdean@cloudbasesolutions.com>> wrote: Unfortunately, WSAPoll misbehaves on Windows please view detailed behavior on: https://github.com/openvswitch/ovs-issues/issues/117 We replace the WSAPoll with select looking only for errors and write events. Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com<mailto:aserdean@cloudbasesolutions.com>> Reported-at: https://github.com/openvswitch/ovs-issues/issues/117 Reported-by: Yin Lin <linyi@vmware.com<mailto:linyi@vmware.com>> Does the select system call in Windows work with named pipes? On that line, did it work with WSAPoll?
diff --git a/lib/socket-util.c b/lib/socket-util.c index 5a36f3b..2c0f1e6 100644 --- a/lib/socket-util.c +++ b/lib/socket-util.c @@ -253,7 +253,23 @@ check_connection_completion(int fd) retval = poll(&pfd, 1, 0); } while (retval < 0 && errno == EINTR); #else - retval = WSAPoll(&pfd, 1, 0); + fd_set wrset, exset; + FD_ZERO(&wrset); + FD_ZERO(&exset); + FD_SET(fd, &exset); + FD_SET(fd, &wrset); + pfd.revents = 0; + struct timeval tv = { 0, 0 }; + /* WSAPoll is broken on Windows, instead do a select */ + retval = select(0, NULL, &wrset, &exset, &tv); + if (retval == 1) { + if (FD_ISSET(fd, &wrset)) { + pfd.revents |= pfd.events; + } + if (FD_ISSET(fd, &exset)) { + pfd.revents |= POLLERR; + } + } #endif if (retval == 1) { if (pfd.revents & POLLERR) {
Unfortunately, WSAPoll misbehaves on Windows please view detailed behavior on: https://github.com/openvswitch/ovs-issues/issues/117 We replace the WSAPoll with select looking only for errors and write events. Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com> Reported-at: https://github.com/openvswitch/ovs-issues/issues/117 Reported-by: Yin Lin <linyi@vmware.com> --- lib/socket-util.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)