summaryrefslogtreecommitdiffstats
path: root/PICA_node.c
diff options
context:
space:
mode:
authorAnton <anton@picapica.im>2026-11-11 05:58:59 +0400
committerAnton <anton@picapica.im>2026-11-11 05:58:59 +0400
commit66942db72e99108cce154607ff929e6919894a1d (patch)
treeacb3a35c7bc5b5c09da21467bf6e691ce3281173 /PICA_node.c
parentd7a200a36b9c2baf1e328823b3e522b5c2fa2d90 (diff)
downloadpica-pica-66942db72e99108cce154607ff929e6919894a1d.tar.gz
pica-pica-66942db72e99108cce154607ff929e6919894a1d.zip
pica-node: delete associated newcons in cclink_list_delete()
Diffstat (limited to 'PICA_node.c')
-rw-r--r--PICA_node.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/PICA_node.c b/PICA_node.c
index 47b23e0..73d0a01 100644
--- a/PICA_node.c
+++ b/PICA_node.c
@@ -1298,6 +1298,41 @@ struct cclink* cclink_list_search(const unsigned char *caller_id, const unsigned
void cclink_list_delete(struct cclink *l)
{
PICA_debug1("cclink_list_delete(%p)", (void*)l);
+
+ /* A CONNID connection may still be mid anon-TLS-shutdown with its socket
+ * handed to this link (sck_p1/sck_p2) and nc->iconn.cc pointing here. If
+ * the link is torn down first (WAITACTIVE timeout, or a client
+ * disconnecting), that newconn would later double-close the socket and
+ * re-delete this freed link from newconn_close(). Retire it now: drop its
+ * event and anon SSL and relinquish the fd, which is closed below.
+ */
+ {
+ int i;
+ for (i = 0; i < MAX_NEWCONNS; i++)
+ {
+ struct newconn *nc = &newconns[i];
+
+ if (nc->type == NEWCONN_C2C && nc->iconn.cc == l)
+ {
+ if (nc->ev)
+ {
+ event_del(nc->ev);
+ event_free(nc->ev);
+ nc->ev = NULL;
+ }
+ if (nc->anonssl)
+ {
+ SSL_free(nc->anonssl);
+ nc->anonssl = NULL;
+ }
+ nc->iconn.cc = NULL;
+ nc->sck = -1; /* owned and closed by the link below */
+ nc->pos = 0;
+ nc->type = NEWCONN_UNKNOWN;
+ }
+ }
+ }
+
//удаление из глобального списка
if (l->prev)
l->prev->next = l->next;