From 89f77a93a6c96896d90c943bc3e82139114cf58c Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Wed, 26 May 2021 23:36:47 -0500 Subject: [PATCH] server: Mark the socket as cacheable when it is connected, marked listening, or created as connectionless. Signed-off-by: Zebediah Figura Signed-off-by: Alexandre Julliard --- server/sock.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/server/sock.c b/server/sock.c index 3925018c7a5..6e9ef3d9d97 100644 --- a/server/sock.c +++ b/server/sock.c @@ -416,7 +416,6 @@ static int sock_reselect( struct sock *sock ) if (!(sock->state & ~FD_WINE_NONBLOCKING)) return 0; /* ok, it is, attach it to the wineserver's main poll loop */ sock->polling = 1; - allow_fd_caching( sock->fd ); } /* update condition mask */ set_fd_events( sock->fd, ev ); @@ -1358,7 +1357,11 @@ static int init_socket( struct sock *sock, int family, int type, int protocol, u { return -1; } - sock_reselect( sock ); + + /* We can't immediately allow caching for a connection-mode socket, since it + * might be accepted into (changing the underlying fd object.) */ + if (sock->type != WS_SOCK_STREAM) allow_fd_caching( sock->fd ); + return 0; } @@ -1750,6 +1753,9 @@ static int sock_ioctl( struct fd *fd, ioctl_code_t code, struct async *async ) sock->state |= FD_WINE_LISTENING; sock->state &= ~(FD_CONNECT | FD_WINE_CONNECTED); + /* a listening socket can no longer be accepted into */ + allow_fd_caching( sock->fd ); + /* we may already be selecting for FD_ACCEPT */ sock_reselect( sock ); return 0; @@ -1790,6 +1796,9 @@ static int sock_ioctl( struct fd *fd, ioctl_code_t code, struct async *async ) return 0; } + /* a connected or connecting socket can no longer be accepted into */ + allow_fd_caching( sock->fd ); + sock->pending_events &= ~(FD_CONNECT | FD_READ | FD_WRITE); sock->reported_events &= ~(FD_CONNECT | FD_READ | FD_WRITE);