sftp.c: Send at least one read request before reading
This commit ensures that we have sent at least one read request before
we try to read data in sftp_read().
Otherwise sftp_read() would return 0 bytes (indicating EOF) if the
socket is not ready for writing.
diff --git a/src/sftp.c b/src/sftp.c
index d4baab2..f239b4e 100644
--- a/src/sftp.c
+++ b/src/sftp.c
@@ -1423,9 +1423,16 @@
chunk->lefttosend -= rc;
chunk->sent += rc;
- if(chunk->lefttosend)
- /* data left to send, get out of loop */
- break;
+ if(chunk->lefttosend) {
+ /* We still have data left to send for this chunk.
+ * If there is at least one completely sent chunk,
+ * we can get out of this loop and start reading. */
+ if (chunk != _libssh2_list_first(&handle->packet_list)) {
+ break;
+ } else {
+ continue;
+ }
+ }
}
/* move on to the next chunk with data to send */