1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-06-30 19:12:48 -05:00

Replace PktIn reference count with a 'free queue'.

This is a new idea I've had to make memory-management of PktIn even
easier. The idea is that a PktIn is essentially _always_ an element of
some linked-list queue: if it's not one of the queues by which packets
move through ssh.c, then it's a special 'free queue' which holds
packets that are unowned and due to be freed.

pq_pop() on a PktInQueue automatically relinks the packet to the free
queue, and also triggers an idempotent callback which will empty the
queue and really free all the packets on it. Hence, you can pop a
packet off a real queue, parse it, handle it, and then just assume
it'll get tidied up at some point - the only constraint being that you
have to finish with it before returning to the application's main loop.

The exception is that it's OK to pq_push() the packet back on to some
other PktInQueue, because a side effect of that will be to _remove_ it
from the free queue again. (And if _all_ the incoming packets get that
treatment, then when the free-queue handler eventually runs, it may
find it has nothing to do - which is harmless.)
This commit is contained in:
Simon Tatham
2018-09-23 16:35:29 +01:00
parent 09c3439b5a
commit f6f8219a3d
7 changed files with 57 additions and 32 deletions

2
defs.h
View File

@ -38,6 +38,8 @@ typedef uint32_t uint32;
typedef struct BinarySink BinarySink;
typedef struct BinarySource BinarySource;
typedef struct IdempotentCallback IdempotentCallback;
typedef struct SockAddr_tag *SockAddr;
typedef struct Socket_vtable Socket_vtable;