Subject: Re: SFTP issues

Re: SFTP issues

From: Alexander Lamaison <swish_at_lammy.co.uk>
Date: Tue, 7 Feb 2012 15:33:58 +0000

On 7 February 2012 13:45, Peter Stuge <peter_at_stuge.se> wrote:
> Daniel Stenberg wrote:
>> @@ -1218,16 +1218,17 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HANDLE * handle, char *buffer,
>>
>>      while(chunk) {
>>          if(chunk->lefttosend) {
>> +            if(total_read)
>> +                /* since we risk getting EAGAIN below, we return here if there
>> +                   is data available */
>> +                return total_read;
>> +
>>              rc = _libssh2_channel_write(channel, 0,
>>                                          &chunk->packet[chunk->sent],
>>                                          chunk->lefttosend);
>>              if(rc < 0) {
>> -                if(rc != LIBSSH2_ERROR_EAGAIN)
>> -                    /* error */
>> -                    return rc;
>> -                eagain++;
>>                  sftp->read_state = libssh2_NB_state_sent;
>> -                break;
>> +                return rc;
>>              }
>
> It doesn't seem like there is any point in having this loop anymore,
> since libssh2 must return after every call to _channel_write() in any
> case.

Not every call, right? Only when it returns an error.

Though I think it might be a bug setting libssh2_NB_state_sent on
every error case. Shouldn't it only happen for EAGAIN? Otherwise any
channel failure leaves expecting to continue a previous, interrupted,
read rather than starting a new one.

Alex

--
Swish - Easy SFTP for Windows Explorer (http://www.swish-sftp.org)
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2012-02-07