Subject: Re: libssh2 master 30e2881 sftp_read: use a state variable to avoid bad writes

Re: libssh2 master 30e2881 sftp_read: use a state variable to avoid bad writes

From: Alexander Lamaison <swish_at_lammy.co.uk>
Date: Fri, 16 Sep 2011 23:17:06 +0100

On 16 September 2011 21:07, <libssh2_at_git.stuge.se> wrote:
> - Log -----------------------------------------------------------------
> commit 30e28817f2b7d834447ab5cb1ec920c11181a52d
> Author: Daniel Stenberg <daniel_at_haxx.se>
> Commit: Daniel Stenberg <daniel_at_haxx.se>
>
>    sftp_read: use a state variable to avoid bad writes
>
>    When a channel_write call has gotten an EAGAIN back, we try harder to
>    continue the same write in the subsequent invoke.
>
> diff --git a/src/sftp.c b/src/sftp.c
> index 45e0439..357b87b 100644
> --- a/src/sftp.c
> +++ b/src/sftp.c
...
> @@ -1207,11 +1215,14 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HANDLE * handle, char *buffer,
>             rc = _libssh2_channel_write(channel, 0,
>                                         &chunk->packet[chunk->sent],
>                                         chunk->lefttosend);
> +            sftp->read_state = libssh2_NB_state_idle;
>             if(rc < 0) {
>                 if(rc != LIBSSH2_ERROR_EAGAIN)
>                     /* error */
>                     return rc;
>                 eagain++;
> +                fprintf(stderr, "bing\n");
> +                sftp->read_state = libssh2_NB_state_sent;
>                 break;
>             }

Did you really mean to include fprintf(stderr, "bing\n") here?

Alex

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2011-09-17