diff options
Diffstat (limited to 'PICA_node.c')
| -rw-r--r-- | PICA_node.c | 15 |
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 && |
