Subject: No block direction in _libssh2_wait_socket?

No block direction in _libssh2_wait_socket?

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

Hi all,

I am trying to understand the following code from _libssh2_wait_socket:
https://github.com/libssh2/libssh2/blob/a88a727c2a1840f979b34f12bcce3d55dcd7ea6e/src/session.c#L598-L607

    /* 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.

Best,
Evan

-- 
Evan Mesterhazy
etm2131_at_columbia.edu
_______________________________________________
libssh2-devel https://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2021-07-16