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-boun...@cool.haxx.se> On Behalf Of Ketul Barot via curl-library Sent: Friday, February 15, 2019 11:20 AM To: Daniel Stenberg <dan...@haxx.se>; Ketul Barot via curl-library <curl-library@cool.haxx.se> Cc: Ketul Barot <kba...@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 <dan...@haxx.se<mailto:dan...@haxx.se>> Sent: Thursday, February 14, 2019 5:54 PM To: Ketul Barot via curl-library <curl-library@cool.haxx.se<mailto:curl-library@cool.haxx.se>> Cc: Ketul Barot <kba...@parallelwireless.com<mailto:kba...@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