[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sftp_write waits infinitely


Hey Guys,

How do I unsubsribe to these emails?

Thanks!
-Chris

On Mon, Mar 21, 2016 at 1:59 PM, Andreas Schneider <asn@xxxxxxxxxxxxxx>
wrote:

> On Thursday 18 February 2016 12:09:38 Jakob Kohl | nowcast GmbH wrote:
> > Hello Andreas,
> >
> > I just tried with the current master from git -> same problem. Program
> will
> > hang infinitely in poll function, when network cable gets unplugged for
> > some minutes. It will still hang, when network cable is plugged again.
> >
> > Then I changed some code parts, so that the poll function is called with
> the
> > user timeout and the ssh_poll function returns -1 if it runs into the
> > timeout. Now when I unplug the target machine during a long running sftp
> > file upload, the upload fails. My code then tries to reconnect the ssh
> > session, that also fails as long as the cable is unplugged. When plugging
> > the cable the connection is established and file transfer starts again.
> > Just like I would expect.
> >
> > Could you (or some other libssh developer) please check my diff: Are
> there
> > any side-effects of my change? Why is ssh_handle_packets_termination
> always
> > called with SSH_TIMEOUT_DEFAULT in the current git master?
>
> Hi Jakob,
>
> I think the patch looks ok, just needs some cleanup. Aris what do you
> think?
>
>
>         -- andreas
>
> > Thanks in advance!
> >
> > Jakob Kohl
> >
> >
> >
> > My diff:
> > diff --git a/src/channels.c b/src/channels.c
> > index ffcb1d5..c0ca4ca 100644
> > --- a/src/channels.c
> > +++ b/src/channels.c
> > @@ -2617,7 +2617,7 @@ static int ssh_channel_read_termination(void *s){
> >   */
> >  int ssh_channel_read(ssh_channel channel, void *dest, uint32_t count,
> int
> > is_stderr) {
> > -    return ssh_channel_read_timeout(channel, dest, count, is_stderr,
> -1);
> > +    return ssh_channel_read_timeout(channel, dest, count, is_stderr,
> > SSH_TIMEOUT_USER); }
> >
> >  /**
> > @@ -2697,9 +2697,9 @@ int ssh_channel_read_timeout(ssh_channel channel,
> >    ctx.buffer = stdbuf;
> >    ctx.count = 1;
> >
> > -  if (timeout < 0) {
> > -      timeout = SSH_TIMEOUT_DEFAULT;
> > -  }
> > +//  if (timeout < 0) {
> > +//      timeout = SSH_TIMEOUT_DEFAULT;
> > +//  }
> >
> >    rc = ssh_handle_packets_termination(session,
> >                                        timeout,
> > diff --git a/src/poll.c b/src/poll.c
> > index 807b0a5..2266fe9 100644
> > --- a/src/poll.c
> > +++ b/src/poll.c
> > @@ -95,7 +95,10 @@ void ssh_poll_cleanup(void) {
> >  }
> >
> >  int ssh_poll(ssh_pollfd_t *fds, nfds_t nfds, int timeout) {
> > -  return poll((struct pollfd *) fds, nfds, timeout);
> > +  int rc = poll((struct pollfd *) fds, nfds, timeout);
> > +  if (rc <= 0)
> > +      return -1;
> > +  return rc;
> >  }
> >
> >  #else /* HAVE_POLL */
>
> --
> Andreas Schneider                   GPG-ID: CC014E3D
> www.cryptomilk.org                asn@xxxxxxxxxxxxxx
>
>

References:
Re: sftp_write waits infinitelyAndreas Schneider <asn@xxxxxxxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org