simon-git: putty (master): Simon Tatham

Commits to Tartarus hosted VCS tartarus-commits at lists.tartarus.org
Tue Feb 25 21:38:33 GMT 2020


TL;DR:
  3a633bed Fix a deadlock in SFTP upload.

Repository:     https://git.tartarus.org/simon/putty.git
On the web:     https://git.tartarus.org/?p=simon/putty.git
Branch updated: master
Committer:      Simon Tatham <anakin at pobox.com>
Date:           2020-02-25 21:38:33

commit 3a633bed3505b15bb65d4709315a8c29b6497fe8
web diff https://git.tartarus.org/?p=simon/putty.git;a=commitdiff;h=3a633bed3505b15bb65d4709315a8c29b6497fe8;hp=aba52744e44019bb2e3a30dd03e2cd1a9bf675ea
Author: Simon Tatham <anakin at pobox.com>
Date:   Tue Feb 25 21:27:34 2020 +0000

    Fix a deadlock in SFTP upload.
    
    I tried to do an SFTP upload through connection sharing the other day
    and found that pscp sent some data and then hung. Now I debug it, what
    seems to have happened was that we were looping in sftp_recv() waiting
    for an SFTP packet from the remote, but we didn't have any outstanding
    SFTP requests that the remote was going to reply to. Checking further,
    xfer_upload_ready() reported true, so we _could_ have sent something -
    but the logic in the upload loop had a hole through which we managed
    to get into 'waiting for a packet' state.
    
    I think what must have happened is that xfer_upload_ready() reported
    false so that we entered sftp_recv(), but then the event loop inside
    sftp_recv() ran a toplevel callback that made xfer_upload_ready()
    return true. So, the fix: sftp_recv() is our last-ditch fallback, and
    we always try emptying our callback queue and rechecking upload_ready
    before we resort to waiting for a remote packet.
    
    This not only fixes the hang I observed: it also hugely improves the
    upload speed. My guess is that the bug must have been preventing us
    from filling our outgoing request pipeline a _lot_ - but I didn't
    notice it until the one time the queue accidentally ended up empty,
    rather than just sparse enough to make transfers slow.
    
    Annoyingly, I actually considered this fix back when I was trying to
    fix the proftpd issue mentioned in commit cd97b7e7e. I decided fixing
    ssh_sendbuffer() was a better idea. In fact it would have been an even
    better idea to do both! Oh well, better late than never.

 pscp.c  |  9 +++++++++
 psftp.c | 10 ++++++++++
 2 files changed, 19 insertions(+)



More information about the tartarus-commits mailing list