summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton <anton@picapica.im>2026-11-11 05:59:56 +0400
committerAnton <anton@picapica.im>2026-11-11 05:59:56 +0400
commit6baf0cced94e4ce5281fae9c90191dc8b703bb6e (patch)
tree5b56a747344151f495f948a4e91a58816856f1c9
parent66942db72e99108cce154607ff929e6919894a1d (diff)
downloadpica-pica-6baf0cced94e4ce5281fae9c90191dc8b703bb6e.tar.gz
pica-pica-6baf0cced94e4ce5281fae9c90191dc8b703bb6e.zip
pica-node: exaclty one request per newconn
-rw-r--r--PICA_node.c15
1 files changed, 15 insertions, 0 deletions
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 &&