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:
Daniel Stenberg
2011-09-06 23:31:07 +02:00
parent 1ba42ea847
commit 7c9b84d1d1

View File

@@ -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 */
if((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) {