curl / Mailing Lists / curl-library / Single Mail

curl-library

RE: sftp upload request hangs with a high latency server using multi interface

From: Ketul Barot via curl-library <curl-library_at_cool.haxx.se>
Date: Fri, 15 Feb 2019 20:21:20 +0000

Since, it is repeatedly printing the log this means that libssh2_session_disconnect function is returning LIBSSH2_ERROR_EAGAIN every time *_disconnect function is called.

Is it something like *_disconnect is waiting for all the data to be flushed out before disconnecting the session.

If that is the case can we implement some kind of timeout inside *_disconnect function such that if it is not able to flush the data out for some reason just disconnect the session. I am not sure if this is doable just thinking it out loud.

Thank you for the help.
-Ketul

From: curl-library <curl-library-bounces_at_cool.haxx.se> On Behalf Of Ketul Barot via curl-library
Sent: Friday, February 15, 2019 11:20 AM
To: Daniel Stenberg <daniel_at_haxx.se>; Ketul Barot via curl-library <curl-library_at_cool.haxx.se>
Cc: Ketul Barot <kbarot_at_parallelwireless.com>
Subject: RE: sftp upload request hangs with a high latency server using multi interface

I added the timeout function call and it is not working. Meaning, it is not timing out after 2 Sec. I believe part of the reason is that the case SSH_SESSION_DISCONNECT is called repeatedly and so the timeout function is getting called every time.

if(sshc->ssh_session) {
        DEBUGF(infof(data, "Entering libssh2_session_disconnect\n"));
        libssh2_session_set_timeout(sshc->ssh_session, 2L);
        rc = libssh2_session_disconnect(sshc->ssh_session, "Shutdown");
        if(rc == LIBSSH2_ERROR_EAGAIN) {
          break;
        }
        if(rc < 0) {
          char *err_msg = NULL;
          (void)libssh2_session_last_error(sshc->ssh_session,
                                           &err_msg, NULL, 0);
          infof(data, "Failed to disconnect libssh2 session: %d %s\n",
                rc, err_msg);
        }
        DEBUGF(infof(data, "libssh2_session_disconnect done\n"));
      }

I still have the extra logging enabled and it just prints the “Entering libssh2_session_disconnect” repeatedly when it is hung.

Thanks,
ketul


From: Daniel Stenberg <daniel_at_haxx.se<mailto:daniel_at_haxx.se>>
Sent: Thursday, February 14, 2019 5:54 PM
To: Ketul Barot via curl-library <curl-library_at_cool.haxx.se<mailto:curl-library_at_cool.haxx.se>>
Cc: Ketul Barot <kbarot_at_parallelwireless.com<mailto:kbarot_at_parallelwireless.com>>
Subject: RE: sftp upload request hangs with a high latency server using multi interface

On Thu, 14 Feb 2019, Ketul Barot via curl-library wrote:

> Just 1 log before it calls libssh2_session_disconnect and 1 after the
> function call. I am seeing that whenever it hangs it doesn’t print both the
> logs it only prints the 1st which is “Entering libssh2_session_disconnect”
> so definitely the transfer is getting hang in libssh2_session_disconnect.
>
> Any further debugging would greatly help 😊

Try adding a call to *set_timeout() just before we call
libssh2_session_disconnect() to instruct libssh2 to give up the waiting after
2 seconds. Like this:

diff --git a/lib/ssh.c b/lib/ssh.c
index 8c68adcc1..a5f69ac08 100644
--- a/lib/ssh.c
+++ b/lib/ssh.c
@@ -2583,10 +2583,11 @@ static CURLcode ssh_statemach_act(struct connectdata
*conn, bool *block)
}
sshc->ssh_channel = NULL;
}

if(sshc->ssh_session) {
+ libssh2_session_set_timeout(sshc->ssh_session, 2L);
rc = libssh2_session_disconnect(sshc->ssh_session, "Shutdown");
if(rc == LIBSSH2_ERROR_EAGAIN) {
break;
}
if(rc < 0) {




--

/ daniel.haxx.se<http://daniel.haxx.se>

-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2019-02-15