Zebediah Figura : server: Separate a poll_single_socket() helper.
Alexandre Julliard
julliard at winehq.org
Tue Jul 6 18:09:35 CDT 2021
Module: wine
Branch: master
Commit: c86ba5d09dc6aff244f051bca5abd43943351438
URL: https://source.winehq.org/git/wine.git/?a=commit;h=c86ba5d09dc6aff244f051bca5abd43943351438
Author: Zebediah Figura <zfigura at codeweavers.com>
Date: Mon Jul 5 19:14:18 2021 -0500
server: Separate a poll_single_socket() helper.
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
server/sock.c | 44 +++++++++++++++++++++++++-------------------
1 file changed, 25 insertions(+), 19 deletions(-)
diff --git a/server/sock.c b/server/sock.c
index 2b5915c87fe..b1cf628abae 100644
--- a/server/sock.c
+++ b/server/sock.c
@@ -2734,6 +2734,29 @@ static int sock_ioctl( struct fd *fd, ioctl_code_t code, struct async *async )
}
}
+static int poll_single_socket( struct sock *sock, int mask )
+{
+ struct pollfd pollfd;
+
+ pollfd.fd = get_unix_fd( sock->fd );
+ pollfd.events = poll_flags_from_afd( sock, mask );
+ if (pollfd.events < 0 || poll( &pollfd, 1, 0 ) < 0)
+ return 0;
+
+ if ((mask & AFD_POLL_HUP) && (pollfd.revents & POLLIN) && sock->type == WS_SOCK_STREAM)
+ {
+ char dummy;
+
+ if (!recv( get_unix_fd( sock->fd ), &dummy, 1, MSG_PEEK ))
+ {
+ pollfd.revents &= ~POLLIN;
+ pollfd.revents |= POLLHUP;
+ }
+ }
+
+ return get_poll_flags( sock, pollfd.revents ) & mask;
+}
+
static int poll_socket( struct sock *poll_sock, struct async *async, timeout_t timeout,
unsigned int count, const struct poll_socket_input *input )
{
@@ -2788,26 +2811,9 @@ static int poll_socket( struct sock *poll_sock, struct async *async, timeout_t t
for (i = 0; i < count; ++i)
{
struct sock *sock = req->sockets[i].sock;
- struct pollfd pollfd;
- int flags;
-
- pollfd.fd = get_unix_fd( sock->fd );
- pollfd.events = poll_flags_from_afd( sock, req->sockets[i].flags );
- if (pollfd.events < 0 || poll( &pollfd, 1, 0 ) < 0) continue;
-
- if ((req->sockets[i].flags & AFD_POLL_HUP) && (pollfd.revents & POLLIN) &&
- sock->type == WS_SOCK_STREAM)
- {
- char dummy;
-
- if (!recv( get_unix_fd( sock->fd ), &dummy, 1, MSG_PEEK ))
- {
- pollfd.revents &= ~POLLIN;
- pollfd.revents |= POLLHUP;
- }
- }
+ int mask = req->sockets[i].flags;
+ int flags = poll_single_socket( sock, mask );
- flags = get_poll_flags( sock, pollfd.revents ) & req->sockets[i].flags;
if (flags)
{
req->iosb->status = STATUS_SUCCESS;
More information about the wine-cvs
mailing list