Subject: No block direction in _libssh2_wait_socket?

No block direction in _libssh2_wait_socket?

From: Evan M <>
Date: Thu, 15 Jul 2021 23:00:01 -0400

Hi all,

I am trying to understand the following code from _libssh2_wait_socket:

    /* figure out what to wait for */
    dir = libssh2_session_block_directions(session);

    if(!dir) {
        _libssh2_debug(session, LIBSSH2_TRACE_SOCKET,
                       "Nothing to wait for in wait_socket");
        /* To avoid that we hang below just because there's nothing set to
           wait for, we timeout on 1 second to also avoid busy-looping
           during this condition */
        ms_to_next = 1000;

Presumably we only arrive at this point if a call has already returned
EAGAIN, so I would expect that libssh2_session_block_directions never
returns 0 here. Are there any normal situations where this could occur
other than a bug in the library? I'm writing an asynchronous wrapper
over libssh2; what is the recommended way to deal with this condition
in a non-blocking context? Should I simply try again in 1 second like
_libssh2_wait_socket does?

Thanks for any help and suggestions.


Evan Mesterhazy
Received on 2021-07-16