1
1

libssh2_channel_read_ex() must return 0 when closed

If the channel is already at EOF or even closed at the end of the
libssh2_channel_read_ex() function and there's no data to return,
we need to signal that back. We may have gotten that info while
draining the incoming transport layer until EAGAIN so we must not
be fooled by that return code.
Этот коммит содержится в:
Daniel Stenberg 2009-09-16 23:46:30 +02:00
родитель 906a7d8866
Коммит c2375dbfa4

Просмотреть файл

@ -1828,8 +1828,15 @@ ssize_t _libssh2_channel_read(LIBSSH2_CHANNEL *channel, int stream_id,
if (!bytes_read) {
channel->read_state = libssh2_NB_state_idle;
/* if the transport layer said EAGAIN then we say so as well */
return (rc == PACKET_EAGAIN)?rc:0;
/* If the channel is already at EOF or even closed, we need to signal
that back. We may have gotten that info while draining the incoming
transport layer until EAGAIN so we must not be fooled by that
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 == PACKET_EAGAIN)?rc:0;
}
else
/* make sure we remain in the created state to focus on emptying the