diff --git a/pscp.c b/pscp.c index 69e1e40e..695ace3d 100644 --- a/pscp.c +++ b/pscp.c @@ -811,6 +811,15 @@ int scp_send_filedata(char *data, int len) } while (!xfer_upload_ready(scp_sftp_xfer)) { + if (toplevel_callback_pending()) { + /* If we have pending callbacks, they might make + * xfer_upload_ready start to return true. So we should + * run them and then re-check xfer_upload_ready, before + * we go as far as waiting for an entire packet to + * arrive. */ + run_toplevel_callbacks(); + continue; + } pktin = sftp_recv(); ret = xfer_upload_gotpkt(scp_sftp_xfer, pktin); if (ret <= 0) { diff --git a/psftp.c b/psftp.c index 8399ac07..2be47894 100644 --- a/psftp.c +++ b/psftp.c @@ -725,6 +725,16 @@ bool sftp_put_file(char *fname, char *outfname, bool recurse, bool restart) } } + if (toplevel_callback_pending() && !err && !eof) { + /* If we have pending callbacks, they might make + * xfer_upload_ready start to return true. So we should + * run them and then re-check xfer_upload_ready, before + * we go as far as waiting for an entire packet to + * arrive. */ + run_toplevel_callbacks(); + continue; + } + if (!xfer_done(xfer)) { pktin = sftp_recv(); ret = xfer_upload_gotpkt(xfer, pktin);