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.
This commit is contained in:
Jakob Egger 2016-01-13 14:07:40 +01:00 committed by Daniel Stenberg
parent 0d60964632
commit 77c48d4e26

View File

@ -1423,9 +1423,16 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HANDLE * handle, char *buffer,
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 */