[PATCH v2 4/6] server: Remove the socket from the polling loop if it was aborted.
Zebediah Figura
zfigura at codeweavers.com
Mon Jul 26 11:53:45 CDT 2021
Don't use rd_shutdown and wr_shutdown to determine this. On the one hand, it's
possible to have pending asyncs even if rd_shutdown && wr_shutdown, which will
be cheerfully completed upon receiving data. On the other hand, RST doesn't
cause WSAESHUTDOWN, but rather WSAECONNRESET.
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
---
server/sock.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/server/sock.c b/server/sock.c
index 2d2aa733565..2660cf2dee0 100644
--- a/server/sock.c
+++ b/server/sock.c
@@ -215,6 +215,7 @@ struct sock
unsigned int wr_shutdown : 1; /* is the write end shut down? */
unsigned int wr_shutdown_pending : 1; /* is a write shutdown pending? */
unsigned int hangup : 1; /* has the read end received a hangup? */
+ unsigned int aborted : 1; /* did we get a POLLERR or irregular POLLHUP? */
unsigned int nonblocking : 1; /* is the socket nonblocking? */
unsigned int bound : 1; /* is the socket bound? */
};
@@ -1079,8 +1080,7 @@ static void sock_poll_event( struct fd *fd, int event )
}
else if (event & (POLLHUP | POLLERR))
{
- sock->rd_shutdown = 1;
- sock->wr_shutdown = 1;
+ sock->aborted = 1;
if (debug_level)
fprintf( stderr, "socket %p aborted by error %d, event %#x\n", sock, error, event );
@@ -1175,6 +1175,9 @@ static int sock_get_poll_events( struct fd *fd )
return -1;
}
+ if (sock->aborted)
+ return -1;
+
if (sock->accept_recv_req)
{
ev |= POLLIN;
@@ -1403,6 +1406,7 @@ static struct sock *create_socket(void)
sock->wr_shutdown = 0;
sock->wr_shutdown_pending = 0;
sock->hangup = 0;
+ sock->aborted = 0;
sock->nonblocking = 0;
sock->bound = 0;
sock->rcvbuf = 0;
--
2.30.2
More information about the wine-devel
mailing list