From 992de2fbfaa434e3048ccf41a1a8966b05cc170a Mon Sep 17 00:00:00 2001 From: Jakob Egger Date: Wed, 13 Jan 2016 14:59:21 +0100 Subject: [PATCH] sftp.c: Don't return EAGAIN if data was written to buffer --- src/sftp.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/sftp.c b/src/sftp.c index f239b4e..b25415a 100644 --- a/src/sftp.c +++ b/src/sftp.c @@ -1463,6 +1463,13 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HANDLE * handle, char *buffer, rc = sftp_packet_requirev(sftp, 2, read_responses, chunk->request_id, &data, &data_len); + + if (rc==LIBSSH2_ERROR_EAGAIN && bytes_in_buffer != 0) { + /* do not return EAGAIN if we have already + * written data into the buffer */ + return bytes_in_buffer; + } + if (rc < 0) { sftp->read_state = libssh2_NB_state_sent2; return rc;