Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
Slow loading of directory content via SFTP when timeout is set #3506
Directory listing is wery slow when connecting to a SFTP server with CURLOPT_TIMEOUT or -m cmd option. Without a timeout everything works fast.
Tested on my Mac (macos 10.14.2) when connecting to other Mac with curl v7.64.0 (or with daily snapshot 20190129) with following command:
There is some delay for loading of each subdirectory/file.
After some investigation I found that the bug was introduced with changes to lib/ssh.c in commit 1a89099
Noticed the very same problem and for me it works very slow even without any additional arguments just:
In version 7.61.0 that command takes (for a folder with 4 entries) 0.7s and in 7.61.1 (first affected version) it takes 6.7s for a localhost sftp server.
Same for me, 7.61.1 is way slower than version 7.61.0 when doing a simple sftp listing.
It seems curl-7.61.1 does exactly one line of print-out per second as one can see with --trace-time:
So there is somewhere an artificial 1 second delay per printed line! Hope this rings some bells...
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