summaryrefslogtreecommitdiff
path: root/lib/ssh.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2019-03-04 16:17:10 +0100
committerDaniel Stenberg <daniel@haxx.se>2019-03-04 16:17:10 +0100
commitd9af8f2c9f345617b4290a7d1f8338ec7fa5c299 (patch)
tree1b39fc148ba88f51a3a76a4f71b73021a1566638 /lib/ssh.c
parent2591a491aa7cc736dc1751b7b1a4502eac5edf9e (diff)
downloadcurl-d9af8f2c9f345617b4290a7d1f8338ec7fa5c299.tar.gz
ssh: loop the state machine if not done and not blockingbagder/ssh-loop-statemachine
If the state machine isn't complete, didn't fail and it didn't return due to blocking it can just as well loop again. This addresses the problem with SFTP directory listings where we would otherwise return back to the parent and as the multi state machine doesn't have any code for using CURLM_CALL_MULTI_PERFORM for as long the doing phase isn't complete, it would return out when in reality there was more data to deal with. Fixes #3506
Diffstat (limited to 'lib/ssh.c')
-rw-r--r--lib/ssh.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/ssh.c b/lib/ssh.c
index b35831269..46f52eceb 100644
--- a/lib/ssh.c
+++ b/lib/ssh.c
@@ -81,11 +81,11 @@
#include "multiif.h"
#include "select.h"
#include "warnless.h"
+#include "curl_path.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
-#include "curl_path.h"
#include "memdebug.h"
#if LIBSSH2_VERSION_NUM >= 0x010206
@@ -2789,9 +2789,12 @@ static CURLcode ssh_multi_statemach(struct connectdata *conn, bool *done)
CURLcode result = CURLE_OK;
bool block; /* we store the status and use that to provide a ssh_getsock()
implementation */
-
- result = ssh_statemach_act(conn, &block);
- *done = (sshc->state == SSH_STOP) ? TRUE : FALSE;
+ do {
+ result = ssh_statemach_act(conn, &block);
+ *done = (sshc->state == SSH_STOP) ? TRUE : FALSE;
+ /* if there's no error, it isn't done and it didn't EWOULDBLOCK, then
+ try again */
+ } while(!result && !*done && !block);
ssh_block2waitfor(conn, block);
return result;