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:

committed by
Daniel Stenberg

parent
0d60964632
commit
77c48d4e26
13
src/sftp.c
13
src/sftp.c
@@ -1423,9 +1423,16 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HANDLE * handle, char *buffer,
|
|||||||
chunk->lefttosend -= rc;
|
chunk->lefttosend -= rc;
|
||||||
chunk->sent += rc;
|
chunk->sent += rc;
|
||||||
|
|
||||||
if(chunk->lefttosend)
|
if(chunk->lefttosend) {
|
||||||
/* data left to send, get out of loop */
|
/* We still have data left to send for this chunk.
|
||||||
break;
|
* 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 */
|
/* move on to the next chunk with data to send */
|
||||||
|
Reference in New Issue
Block a user