Page MenuHomePhabricator

Opening sftp fails in non-blocking mode
Open, Needs TriagePublic


If a session is set into non-blocking mode, trying to initialize a new sftp session using sftp_new will always fail. The SFTP subsystem should support async operations same as everything else.

The reason it fails is obvious (in sftp.c:150):

if (ssh_channel_open_session(sftp->channel)) {
    goto error;

if (ssh_channel_request_sftp(sftp->channel)) {
    goto error;

Both ssh_channel_open_session and ssh_channel_request_sftp can return SSH_AGAIN which is not handled at all in the above section. I think these parts of the initialization should be moved out of sftp_new and into sftp_init or some other function. Or alternatively sftp_new should be callable multiple times, same as most other functions.

Event Timeline