From 2db4863e6e83791f59248c8fb48adae638acf8bc Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 15 Feb 2011 23:21:38 +0100 Subject: [PATCH] _libssh2_channel_read: store last error When the transport layer returns EAGAIN this function didn't call _libssh2_error() which made the last_error not get set. --- src/channel.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/channel.c b/src/channel.c index e0af14c..efb2b48 100644 --- a/src/channel.c +++ b/src/channel.c @@ -1,6 +1,6 @@ /* Copyright (c) 2004-2007 Sara Golemon * Copyright (c) 2005 Mikhail Gusarov - * Copyright (c) 2008-2010 by Daniel Stenberg + * Copyright (c) 2008-2011 by Daniel Stenberg * * All rights reserved. * @@ -1532,6 +1532,7 @@ libssh2_channel_get_exit_signal(LIBSSH2_CHANNEL *channel, * to be adjusted is less than LIBSSH2_CHANNEL_MINADJUST and force is 0 the * adjustment amount will be queued for a later packet. * + * Calls _libssh2_error() ! */ int _libssh2_channel_receive_window_adjust(LIBSSH2_CHANNEL * channel, @@ -1858,9 +1859,11 @@ ssize_t _libssh2_channel_read(LIBSSH2_CHANNEL *channel, int stream_id, return code. */ if(channel->remote.eof || channel->remote.close) return 0; - else - /* if the transport layer said EAGAIN then we say so as well */ - return (rc == LIBSSH2_ERROR_EAGAIN)?rc:0; + else if(rc != LIBSSH2_ERROR_EAGAIN) + return 0; + + /* if the transport layer said EAGAIN then we say so as well */ + return _libssh2_error(session, rc, "would block"); } else /* make sure we remain in the created state to focus on emptying the