On Apr 19, 2007, at 4:56 PM, Daniel Stenberg wrote:
>> My most serious problem is in the bottom while loop in
>> libssh2_sftp_packet_read(). If I get PACKET_EAGAIN from
>> _libssh2_channel_read() to be non-blocking something has to be
>> done with the data that has been read. My first thought was to
>> just call libssh2_sftp_packet_add() with the data and number of
>> bytes that have been received. This crashes nicely, because the
>> header of the packet gives a different length then what is there.
>> My second option is to temporarily store the packet in the
>> _LIBSSH_SFTP structure and use that to allow the bypassing of the
>> top portion of libssh2_sftp_packet_read() and just start reading.
>
> I think you should introduce a state in that structure to start
> with so that you can return out from the function and when called
> again you know where to continue. But also to collect partial reads
> in a temporary buffer until a complete one is received and can be
> "passed on".
>
>> Then the temporary storage would need to be removed in case of
>> other errors, might be hard to get right.
>
> Why? The LIBSSH2_SFTP handle would remain allocated even today
> until properly closed and there wouldn't be any difference if you
> add some more data to it, it would just be more memory that could
> leak. libssh2_sftp_shutdown() could simply be made to free it.
>
> Or am I missing something?
Yes and no. I was more thinking about if there is a partial packet,
and in the process we "error" out of the current packet. Properly
tracking the the next read is new, and not a continue. But,
formalizing it all in a state machine will make it much easier.
>
>> Attached is my code changes as they stand, edited with TAB for
>> indent set a 4 spaces (like the original code in the library).
>
> If you use tabs for indent and have no maximum line lengths, then
> there's no particular fixed width for tabs!
That is just for reference when looking.
Jim
-- /"\ ASCII Ribbon Campaign . \ / - NO HTML/RTF in e-mail . X - NO Word docs in e-mail . / \ ----------------------------------------------------------------- jeh@FreeBSD.org http://www.FreeBSD.org The Power to Serve jim@TheHousleys.Net http://www.TheHousleys.net --------------------------------------------------------------------- In theory there is no difference between theory and practice. In practice there is no similarity. -- From the "I wish I'd said that" archives. ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ libssh2-devel mailing list libssh2-devel_at_lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libssh2-develReceived on 2007-04-19