Subject: Re: not getting all the data with libssh2_channel_exec and libssh2_channel_read

Re: not getting all the data with libssh2_channel_exec and libssh2_channel_read

From: Peter Stuge <peter_at_stuge.se>
Date: Thu, 7 Jan 2010 05:37:16 +0100

Seth Grover wrote:
> Does anyone with particular knowledge of this bug think that it would
> explain the problem I described using 1.1? If so I guess we can just
> leave it at that.

There have been several problems with libssh2 data loss and incorrect
internal state found and fixed since August. The very last such bug
that has been fixed is not available in a release yet, but can be
gotten from git.

> It still does leave the question for me, which is the "correct" way
> to do it?
>
> 1. loop until libssh2_channel_read returns something <= 0 (other than
> LIBSSH2_ERROR_EAGAIN)
> or
> 2. loop until libssh2_channel_eof(channel)?
>
> Both actually seem to work, which is correct?

_channel_read() returning 0 is not neccessarily an error. I consider
this to be a bad property of the API, but currently it is what it is.

_channel_eof() makes the most sense to me, when the channel can
actually be expected to close remotely.

//Peter
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2010-01-07