Hi, Henry Ludemann wrote: > Henry Ludemann wrote: >> I've sent a pull request with a proper fix > > Sorry, hold off on this. It's still got issues.
There are several bugs in curl related to sftp upload using the multi interface, two of which I'm comfortable fixing, one that I'm not so sure about. 1. In ssh_statemach_act it doesn't reset the cselect_bits variable. This is required so the curl multi interface will attempt to send immediately, instead of the next 'curl_multi_socket_action' (which will never happen, as ssh isn't waiting on any sockets or timeouts, so there is no reason to call back into curl). This had been fixed for SSH_SFTP_DOWNLOAD_STAT and SSH_SCP_TRANS_INIT, but not SSH_SFTP_UPLOAD_INIT [patch-1] [patch-2]. 2. In Curl_readwrite it should use 'waitfor' when considering if it is ready for calling readwrite_upload [patch-3]. This is required because at the end of the sftp upload we only want to read from the socket, not write to it. This means the 'select_res & CURL_CSELECT_OUT' is always false, as libssh2 indicates that we don't want to write to the socket, only read from it. 3. In Curl_readwrite, we populate the buffer and send it using sftp_send. When this call successfully transfers the data, it resets waitfor to 0 (as the current transfer has succeeded). In readwrite_upload (called from Curl_readwrite) we only clear k->keepon if upload_done is true, which apparently only happens for chunked http uploads. As k->keepon is not cleared, back in Curl_readwrite '*done' is set to false, as keepon is non-zero. This means we never leave CURLM_STATE_PERFORM. I'm not sure of the right way to fix this; any suggestions would be gratefully accepted. I'll keep debugging. Cheers, Henry [patch-1] Patch for the curl cselect_bits variable - https://github.com/asdf1011/curl/commit/9ce5028f4b6e055c2d808d988ceea67e47cb379a [patch-2] Document why we need to reset cselect_bits - https://github.com/asdf1011/curl/commit/fa3eb0497de3c406a50d3acba332d64e911999aa [patch-3] Use 'waitfor' when available to see if we're ready for uploading - https://github.com/asdf1011/curl/commit/7a80514504de1629d8c4d166c595cef3b5b0ed76 ------------------------------------------------------------------- List admin: http://cool.haxx.se/list/listinfo/curl-library Etiquette: http://curl.haxx.se/mail/etiquette.html
