aboutsummaryrefslogtreecommitdiff
path: root/src/poll.c
AgeCommit message (Collapse)AuthorFilesLines
2023-09-13poll: Avoid passing other events to callbacks when called recursivelyJakub Jelen1-2/+9
Some architectures (s390x) provide different poll events such as POLLHUP in case the remote end closed the connection (and they keep reporting this forever). This is an issue when the user provided callback registering this event as an error and tries to send some reply (for example EOF) using `ssh_channel_send_eof()` which will lead to infinite recursion and sefgaults. This was not solved by the 30b5a2e33bf260062dd31c9c0e98cf9982b08961 because the POLLHUP event is not provided by the poll in events bitfield, but only reported by the poll in revents bit field thus we need to filter these events later on when the poll is recursively. Fixes #202 Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2023-09-13poll: Drop all events except POLLOUT when called recursivelyJakub Jelen1-3/+3
The FD locking was modified in 30b5a2e33bf260062dd31c9c0e98cf9982b08961 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>
2023-03-09poll: Rename lock to lock_cnt and make it unsignedAndreas Schneider1-5/+5
Signed-off-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2023-03-09poll: Change the lock to block only POLLIN eventsJakub Jelen1-6/+22
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-11-02Reformat and initialize pointersJakub Jelen1-1/+1
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-10-12Fix various spelling issues reported by codespellJakub Jelen1-2/+2
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2022-10-04poll.c: Remove dot from documentation group definitionNorbert Pocs1-1/+1
Signed-off-by: Norbert Pocs <npocs@redhat.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-06-23poll: Document errno will be set for ssh_event_dopoll()Andreas Schneider1-1/+2
Signed-off-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-06-09Document poll failuresJakub Jelen1-1/+3
Resolved: https://gitlab.com/libssh/libssh-mirror/-/issues/46 Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-06-09Reformat most of the function headersJakub Jelen1-96/+128
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-05-02Fix multiple spelling and grammar mistakesJunda Ai1-8/+8
Signed-off-by: Junda Ai <aijunda29@gmail.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-10-11emulated poll: polling for nothing should at least get socket errorsAndrew Wiley1-7/+5
Signed-off-by: Andrew Wiley <wiley@outlook.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-02-27ssh_event_dopoll can also return SSH_AGAINTill Wimmer1-0/+1
Signed-off-by: Till Wimmer <g4-lisz@tonarchiv.ch> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-09poll: Return early for timeout and count every reventAndreas Schneider1-1/+5
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-09poll: Do not generate SIGPIPE with recv() in bsd_poll()Andreas Schneider1-1/+6
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-09poll: Improve checks for POLLHUP and POLLERRAndreas Schneider1-14/+55
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-09poll: Zero (read|write|expect)fds in bsd_poll()Andreas Schneider1-0/+3
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-09poll: Reformat bsd_poll()Andreas Schneider1-96/+112
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-09poll: Fix size typeAndreas Schneider1-1/+1
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-09poll: Reformat ssh_poll_ctx_dopoll()Andreas Schneider1-50/+55
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-25socket: Undouble socket fdsSanne Raymaekers1-12/+10
Signed-off-by: Sanne Raymaekers <sraymaek@redhat.com>
2018-08-30poll: Fix size types in ssh_event_free()Andreas Schneider1-1/+1
src/poll.c:1024:9: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow] Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-30poll: Reformat ssh_event_free()Andreas Schneider1-7/+10
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-28Remove vim modelines from all filesAndreas Schneider1-4/+0
If you want modelines use my vim plugin: https://github.com/cryptomilk/git-modeline.vim git config --add vim.modeline "ts=4 sw=4 et" Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-04-10Fix ssh_event_add_session() when session socket has two pollhandlersMeng Tan1-5/+18
Signed-off-by: Meng Tan <mtan@wallix.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-02connector: Implement ssh_connector_except()Aris Adamantiadis1-5/+33
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-02events: Add functions for poll objectsAris Adamantiadis1-0/+27
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-06-24misc: Correctly guard the sys/time.h includeAndreas Schneider1-1/+5
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-04-02poll: Fix compilation with struct ssh_timestampAndreas Schneider1-1/+1
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-02-23Locally restart ssh_poll() upon EINTR.Seb Boving1-1/+7
BUG: https://red.libssh.org/issues/186 Reviewed-by: Aris Adamantiadis <aris@0xbadc0de.be> Signed-off-by: Sebastien Boving <seb@google.com>
2014-01-07src: Update my mail address.Andreas Schneider1-1/+1
2014-01-07update copyright informationAris Adamantiadis1-2/+2
2014-01-05poll: fix poll_handles ownershipsAris Adamantiadis1-5/+27
2013-12-22poll: Correctly free ssh_event_fd_wrapper.Andreas Schneider1-3/+9
This is allocated by ssh_event_add_fd.
2013-11-09poll: Fix realloc in ssh_poll_ctx_resize().Andreas Schneider1-2/+6
2013-10-31poll: fix leak in ssh_poll_ctx_freeJon Simons1-1/+5
Fix a memory leak in 'ssh_poll_ctx_free': issue 'ssh_poll_free' to remove the poll handle from its context and free it. BUG: https://red.libssh.org/issues/128 Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-23cmake: Check for unistd.h.Andreas Schneider1-1/+4
2013-07-13events: don't poll handles busy handling callbacksAris Adamantiadis1-3/+8
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-02-26poll: return error on poll() when pollset is emptyAris Adamantiadis1-1/+1
2012-10-12poll: Fix sizeof in ssh_poll_ctx_resize().Andreas Schneider1-2/+2
sizeof(ssh_poll_handle *) is to be equal to sizeof(ssh_poll_handle), but this is not a portable assumption. Found by Coverity.
2011-09-18priv: Remove crypto.h and add correct includes to src files.Andreas Schneider1-0/+1
2011-09-02poll: resolve use-after-free + inconsistent callbacks callAris Adamantiadis1-18/+3
This code was weird in the first place. I suspect my change will break something else (probably the appcode that needed it). ssh_poll_ctx_free is not a good place to send exception callbacks imho.
2011-08-23poll: Just make the code a bit more readable.Andreas Schneider1-4/+6
Maybe this fixes a cppcheck false positive. (cherry picked from commit 45c1a23769b63e72e895158bcab83aad31d483dd)
2011-08-06channels: Fix checking for fatal errors.rofl0r1-1/+6
We need this that we don't end up in and infinite poll loop.
2011-05-24Introduced ssh_timeout_elapsed functionsAris Adamantiadis1-1/+4
Functions to mesure elapsed time before and after a serie of calls. Introduces a dependancy to clock_gettime() and librt, hope this doesn't break anything. Porting to gettimeofday() should not be too hard.
2011-05-17poll: Removed WSAPoll() support.Oliver Stöneberg1-43/+0
It was causing too many issues and the poll emulation is quite stable.
2011-05-17connect: Set timeout on connectOliver Stöneberg1-3/+1
This also fixes error handling in ssh_poll_ctx_dopoll() and ssh_handle_packets(), so it won't loop forever on an actual timeout.
2011-05-02[event] don't use sessions in event anymoremilo1-14/+0
(cherry picked from commit 89d0fdbbde4cf48e783a8ee7c5907c51a83e207b)
2011-05-02[poll] avoid infinite loop in ssh_poll_ctx_free()milo1-1/+6
(cherry picked from commit eace59d3eaad413fd846d1c8b4c926285f6cd5ab)
2011-04-15poll: Fix poll input events.Andreas Schneider1-2/+2
bug#38