From 6baf0cced94e4ce5281fae9c90191dc8b703bb6e Mon Sep 17 00:00:00 2001 From: Anton Date: Wed, 11 Nov 2026 05:59:56 +0400 Subject: pica-node: exaclty one request per newconn --- PICA_node.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'PICA_node.c') diff --git a/PICA_node.c b/PICA_node.c index 73d0a01..28d20f3 100644 --- a/PICA_node.c +++ b/PICA_node.c @@ -268,6 +268,13 @@ unsigned int procmsg_INITREQ(unsigned char* buf, unsigned int size, void* ptr) PICA_debug1("received INITREQ"); + /* Exactly one request message per newconn. A second (e.g. two INITREQs in + * one record) would create a second client on the same socket and orphan + * the first, which later closes a socket it no longer owns. + */ + if (nc->type != NEWCONN_UNKNOWN) + return 0; + nc->type = NEWCONN_C2N; if (buf[2] == PICA_PROTO_VER_HIGH && buf[3] == PICA_PROTO_VER_LOW) @@ -350,6 +357,10 @@ unsigned int procmsg_CONNID(unsigned char* buf, unsigned int size, void* ptr) PICA_debug1("received CONNID"); + /* One request message per newconn - see procmsg_INITREQ(). */ + if (nc->type != NEWCONN_UNKNOWN) + return 0; + nc->type = NEWCONN_C2C; caller_id = buf + 2; @@ -405,6 +416,10 @@ unsigned int procmsg_NODECONNREQ(unsigned char* buf, unsigned int size, void* pt PICA_debug1("received NODECONNREQ"); + /* One request message per newconn - see procmsg_INITREQ(). */ + if (nc->type != NEWCONN_UNKNOWN) + return 0; + nc->type = NEWCONN_N2N; if (buf[2] == PICA_PROTO_VER_HIGH && -- cgit v1.2.1