mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-01 03:22:48 -05:00
New Seat callback, seat_sent().
This is used to notify the Seat that some data has been cleared from the backend's outgoing data buffer. In other words, it notifies the Seat that it might be worth calling backend_sendbuffer() again. We've never needed this before, because until now, Seats have always been the 'main program' part of the application, meaning they were also in control of the event loop. So they've been able to call backend_sendbuffer() proactively, every time they go round the event loop, instead of having to wait for a callback. But now, the SSH proxy is the first example of a Seat without privileged access to the event loop, so it has no way to find out that the backend's sendbuffer has got smaller. And without that, it can't pass that notification on to plug_sent, to unblock in turn whatever the proxied connection might have been waiting to send. In fact, before this commit, sshproxy.c never called plug_sent at all. As a result, large data uploads over an SSH jump host would hang forever as soon as the outgoing buffer filled up for the first time: the main backend (to which sshproxy.c was acting as a Socket) would carefully stop filling up the buffer, and then never receive the call to plug_sent that would cause it to start again. The new callback is ignored everywhere except in sshproxy.c. It might be a good idea to remove backend_sendbuffer() entirely and convert all previous uses of it into non-empty implementations of this callback, so that we've only got one system; but for the moment, I haven't done that.
This commit is contained in:
@ -201,4 +201,6 @@ static void ssh2_bare_bpp_handle_output(BinaryPacketProtocol *bpp)
|
||||
ssh2_bare_bpp_format_packet(s, pkt);
|
||||
ssh_free_pktout(pkt);
|
||||
}
|
||||
|
||||
ssh_sendbuffer_changed(bpp->ssh);
|
||||
}
|
||||
|
@ -376,6 +376,8 @@ static void ssh1_bpp_handle_output(BinaryPacketProtocol *bpp)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ssh_sendbuffer_changed(bpp->ssh);
|
||||
}
|
||||
|
||||
static void ssh1_bpp_queue_disconnect(BinaryPacketProtocol *bpp,
|
||||
|
@ -979,4 +979,6 @@ static void ssh2_bpp_handle_output(BinaryPacketProtocol *bpp)
|
||||
ssh2_bpp_enable_pending_compression(s);
|
||||
}
|
||||
}
|
||||
|
||||
ssh_sendbuffer_changed(bpp->ssh);
|
||||
}
|
||||
|
@ -1157,6 +1157,7 @@ static size_t ssh2_try_send(struct ssh2_channel *c)
|
||||
if (!bufsize && c->pending_eof)
|
||||
ssh2_channel_try_eof(c);
|
||||
|
||||
ssh_sendbuffer_changed(s->ppl.ssh);
|
||||
return bufsize;
|
||||
}
|
||||
|
||||
|
@ -107,6 +107,7 @@ static int server_confirm_weak_cached_hostkey(
|
||||
static const SeatVtable server_seat_vt = {
|
||||
.output = nullseat_output,
|
||||
.eof = nullseat_eof,
|
||||
.sent = nullseat_sent,
|
||||
.get_userpass_input = nullseat_get_userpass_input,
|
||||
.notify_remote_exit = nullseat_notify_remote_exit,
|
||||
.notify_remote_disconnect = nullseat_notify_remote_disconnect,
|
||||
@ -187,6 +188,10 @@ LogContext *ssh_get_logctx(Ssh *ssh)
|
||||
return srv->logctx;
|
||||
}
|
||||
|
||||
void ssh_sendbuffer_changed(Ssh *ssh)
|
||||
{
|
||||
}
|
||||
|
||||
void ssh_throttle_conn(Ssh *ssh, int adjust)
|
||||
{
|
||||
server *srv = container_of(ssh, server, ssh);
|
||||
|
@ -186,6 +186,7 @@ static bool sesschan_get_window_pixel_size(Seat *seat, int *w, int *h);
|
||||
static const SeatVtable sesschan_seat_vt = {
|
||||
.output = sesschan_seat_output,
|
||||
.eof = sesschan_seat_eof,
|
||||
.sent = nullseat_sent,
|
||||
.get_userpass_input = nullseat_get_userpass_input,
|
||||
.notify_remote_exit = sesschan_notify_remote_exit,
|
||||
.notify_remote_disconnect = nullseat_notify_remote_disconnect,
|
||||
|
@ -640,6 +640,7 @@ static void ssh_sent(Plug *plug, size_t bufsize)
|
||||
if (bufsize < SSH_MAX_BACKLOG) {
|
||||
ssh_throttle_all(ssh, false, bufsize);
|
||||
queue_idempotent_callback(&ssh->ic_out_raw);
|
||||
ssh_sendbuffer_changed(ssh);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1042,6 +1043,11 @@ static size_t ssh_sendbuffer(Backend *be)
|
||||
return backlog;
|
||||
}
|
||||
|
||||
void ssh_sendbuffer_changed(Ssh *ssh)
|
||||
{
|
||||
seat_sent(ssh->seat, ssh_sendbuffer(&ssh->backend));
|
||||
}
|
||||
|
||||
/*
|
||||
* Called to set the size of the window from SSH's POV.
|
||||
*/
|
||||
|
@ -1484,6 +1484,7 @@ static void ssh2_transport_process_queue(PacketProtocolLayer *ppl)
|
||||
* layer's outgoing queue on to our own.
|
||||
*/
|
||||
pq_concatenate(s->ppl.out_pq, s->ppl.out_pq, &s->pq_out_higher);
|
||||
ssh_sendbuffer_changed(s->ppl.ssh);
|
||||
|
||||
/*
|
||||
* Expect SSH2_MSG_NEWKEYS from server.
|
||||
@ -1620,6 +1621,7 @@ static void ssh2_transport_process_queue(PacketProtocolLayer *ppl)
|
||||
|
||||
/* Pass through outgoing packets from the higher layer. */
|
||||
pq_concatenate(s->ppl.out_pq, s->ppl.out_pq, &s->pq_out_higher);
|
||||
ssh_sendbuffer_changed(s->ppl.ssh);
|
||||
|
||||
/* Wait for either a KEXINIT, or something setting
|
||||
* s->rekey_class. This call to ssh2_transport_pop also has
|
||||
|
Reference in New Issue
Block a user