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: Thu, 14 Feb 2019 19:35:51 +0000

I added some more logging in to the case for DISCONNECT state like these:

      if(sshc->ssh_session) {
        DEBUGF(infof(data, "Entering libssh2_session_disconnect\n"));
        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"));
      }

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 😊

Thank you,
Ketul

From: Daniel Stenberg <daniel_at_haxx.se>
Sent: Thursday, February 14, 2019 11:26 AM
To: 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

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

> I am facing a hang followed by SIGABRT when trying to upload a file using
> sftp protocol.

SIGABRT ? That's highly unexpected. What's causing that? Can you strace and
figure out?

> With the same setup, occasionally the transfer gets hung at
> curl_multi_remove_handle. Upon enabling the CURLOPT_VERBOSE option I found
> that the curl get hung at "SFTP 0x1c739e8 state change from
> SSH_SFTP_SHUTDOWN to SSH_SESSION_DISCONNECT".

That log would be this line:

https://github.com/curl/curl/blob/539d17b0de923b9a122f551fddac2a82ed95d9b2/lib/ssh.c#L2340<https://github.com/curl/curl/blob/539d17b0de923b9a122f551fddac2a82ed95d9b2/lib/ssh.c#L2340>

It would then move on to the case for the DISCONNECT state:

https://github.com/curl/curl/blob/539d17b0de923b9a122f551fddac2a82ed95d9b2/lib/ssh.c#L2568<https://github.com/curl/curl/blob/539d17b0de923b9a122f551fddac2a82ed95d9b2/lib/ssh.c#L2568>

Given your description, it sounds as if one of those calls to libssh2 then
gets stuck. Maybe you can add more logging around those invokes to figure out
if that is indeed the case.

If it is indeed a libssh2 function that blocks, then I'm afraid the problem is
most likely in libssh2 and not in curl itself... but even if so, just being
able to identify that would be a step forward. Then we can just skip into that
library and figure out why it hangs there!

--

/ 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-14