mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-25 01:02:24 +00:00
Make the rdpkt functions output to a PacketQueue.
Each of the coroutines that parses the incoming wire data into a stream of 'struct Packet' now delivers those packets to a PacketQueue called ssh->pq_full (containing the full, unfiltered stream of all packets received on the SSH connection), replacing the old API in which each coroutine would directly return a 'struct Packet *' to its caller, or NULL if it didn't have one ready yet. This simplifies the function-call API of the rdpkt coroutines (they now return void). It increases the complexity at the other end, because we've now got a function ssh_process_pq_full (scheduled as an idempotent callback whenever rdpkt appends anything to the queue) which pulls things out of the queue and passes them to ssh->protocol. But that's only a temporary complexity increase; by the time I finish the upcoming stream of refactorings, there won't be two chained functions there any more. One small workaround I had to add in this commit is a flag called 'pending_newkeys', which ssh2_rdpkt sets when it's just returned an SSH_MSG_NEWKEYS packet, and then waits for the transport layer to process the NEWKEYS and set up the new encryption context before processing any more wire data. This wasn't necessary before, because the old architecture was naturally synchronous - ssh2_rdpkt would return a NEWKEYS, which would be immediately passed to do_ssh2_transport, which would finish processing it immediately, and by the time ssh2_rdpkt was next called, the keys would already be in place. This change adds a big while loop around the whole of each rdpkt function, so it's easiest to read it as a whitespace-ignored diff.
This commit is contained in:
parent
9d495b2176
commit
2b57b84fa5