mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-04 12:20:42 +09:00
poll: Drop all events except POLLOUT when called recursively
The FD locking was modified in30b5a2e33bbut 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> (cherry picked from commitf86bec735b)
This commit is contained in:
committed by
Andreas Schneider
parent
57b92b18d6
commit
4b935d0785
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user