From 1507d27be0bbb550ca53ca8215a997a1b31e9017 Mon Sep 17 00:00:00 2001 From: John-Mark Gurney Date: Thu, 22 Oct 2020 05:13:52 +0000 Subject: [PATCH] Squashed 'libssh2/' changes from 6c7769dc..f75f3488 f75f3488 add some debugging for understanding how these flags are set.. 57635ddf disable read ahead algorithm so we don't waste bandwidth.. git-subtree-dir: libssh2 git-subtree-split: f75f3488824d7935d15d75a869783b37fe446927 --- src/sftp.c | 13 +++++-------- src/transport.c | 4 ++++ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/sftp.c b/src/sftp.c index ac7ee01..378974c 100644 --- a/src/sftp.c +++ b/src/sftp.c @@ -1414,12 +1414,9 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HANDLE * handle, char *buffer, /* Number of bytes asked for that haven't been acked yet */ size_t already = (size_t)(filep->offset_sent - filep->offset); - size_t max_read_ahead = buffer_size*4; + size_t max_read_ahead = buffer_size; unsigned long recv_window; - if(max_read_ahead > LIBSSH2_CHANNEL_WINDOW_DEFAULT*4) - max_read_ahead = LIBSSH2_CHANNEL_WINDOW_DEFAULT*4; - /* if the buffer_size passed in now is smaller than what has already been sent, we risk getting count become a very large number */ @@ -1472,8 +1469,8 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HANDLE * handle, char *buffer, uint32_t request_id; uint32_t size = count; - if(size < buffer_size) - size = buffer_size; + //if(size < buffer_size) + // size = buffer_size; if(size > MAX_SFTP_READ_SIZE) size = MAX_SFTP_READ_SIZE; @@ -1576,7 +1573,7 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HANDLE * handle, char *buffer, else { /* we should never reach this point */ return _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL, - "sftp_read() internal error"); + "sftp_read() internal error a"); } } @@ -1722,7 +1719,7 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HANDLE * handle, char *buffer, /* we should never reach this point */ return _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL, - "sftp_read() internal error"); + "sftp_read() internal error b"); } /* libssh2_sftp_read diff --git a/src/transport.c b/src/transport.c index 0723b77..dbee285 100644 --- a/src/transport.c +++ b/src/transport.c @@ -376,6 +376,8 @@ int _libssh2_transport_read(LIBSSH2_SESSION * session) if((nread < 0) && (nread == -EAGAIN)) { session->socket_block_directions |= LIBSSH2_SESSION_BLOCK_INBOUND; + _libssh2_debug(session, LIBSSH2_TRACE_SOCKET, + "setting INBOUND flag, nread: %d", nread); return LIBSSH2_ERROR_EAGAIN; } _libssh2_debug(session, LIBSSH2_TRACE_SOCKET, @@ -411,6 +413,8 @@ int _libssh2_transport_read(LIBSSH2_SESSION * session) check is only done for the initial block since once we have got the start of a block we can in fact deal with fractions */ + _libssh2_debug(session, LIBSSH2_TRACE_SOCKET, + "setting INBOUND flag, numbytes: %d, blocksize: %d", numbytes, blocksize); session->socket_block_directions |= LIBSSH2_SESSION_BLOCK_INBOUND; return LIBSSH2_ERROR_EAGAIN;