1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-11-26 01:03:15 +03:00

poll: Drop all events except POLLOUT when called recursively

The FD locking was modified in 30b5a2e33b but it
caused some weird issues on s390x in Debian tests, which were getting POLLHUP,
causing infinite recursion while the callback tried to close socket.

Previously, the lock blocked only the POLLIN events as we believed these were
the only events we could get recursively that could cause issues. But it looks
like more sane behavior will be blocking everything but POLLOUT to allow the
buffers to be flushed.

Fixes #202

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
Jakub Jelen
2023-07-04 17:06:11 +02:00
parent 7645892ca2
commit f86bec735b

View File

@@ -698,13 +698,13 @@ int ssh_poll_ctx_dopoll(ssh_poll_ctx ctx, int timeout)
return SSH_ERROR;
}
/* Ignore any pollin events on locked sockets as that means we are called
/* Allow only POLLOUT events on locked sockets as that means we are called
* recursively and we only want process the POLLOUT events here to flush
* output buffer */
for (i = 0; i < ctx->polls_used; i++) {
/* The lock prevents invoking POLLIN events: drop them now */
/* The lock allows only POLLOUT events: drop the rest */
if (ctx->pollptrs[i]->lock_cnt > 0) {
ctx->pollfds[i].events &= ~POLLIN;
ctx->pollfds[i].events &= POLLOUT;
}
}
ssh_timestamp_init(&ts);