mirror of
https://github.com/libssh2/libssh2.git
synced 2025-11-23 01:22:37 +03:00
sftp_read: added documenting comment
Taken from some recent email conversations I added some descriptions of the logic in sftp_read() to aid readers.
This commit is contained in:
14
src/sftp.c
14
src/sftp.c
@@ -1114,6 +1114,20 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HANDLE * handle, char *buffer,
|
|||||||
been sent, we risk getting count become a very large number */
|
been sent, we risk getting count become a very large number */
|
||||||
if((buffer_size*4) > already)
|
if((buffer_size*4) > already)
|
||||||
count = (buffer_size*4) - already;
|
count = (buffer_size*4) - already;
|
||||||
|
|
||||||
|
/* 'count' is how much more data to ask for, and 'already' is how much
|
||||||
|
data that already has been asked for but not yet returned. So, if
|
||||||
|
'already' is very large it should be perfectly fine to have count
|
||||||
|
set to 0 as then we don't have to ask for more data (right now).
|
||||||
|
|
||||||
|
buffer_size*4 is just picked more or less out of the air. The idea
|
||||||
|
is that when reading SFTP from a remote server, we send away
|
||||||
|
multiple read requests guessing that the client will read more than
|
||||||
|
only this 'buffer_size' amount of memory. So we ask for maximum
|
||||||
|
buffer_size*4 amount of data so that we can return them very fast
|
||||||
|
in subsequent calls.
|
||||||
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while(count > 0) {
|
while(count > 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user