Module: kamailio
Branch: master
Commit: cfa1d128e2a1745faad914cb6170c2aa74565523
URL: 
https://github.com/kamailio/kamailio/commit/cfa1d128e2a1745faad914cb6170c2aa74565523

Author: rajneeshksoni <[email protected]>
Committer: Richard Fuchs <[email protected]>
Date: 2026-05-28T08:17:16-04:00

rtpengine:Fix UDP socket leak when rtpengine is removed.

build_rtpp_socks() was creating connected UDP sockets for all nodes in
the linked list, including soft-deleted ones (rn_displayed=0). Since
rtpengine_delete_node() never removes nodes from the list, every reload
after a removal would re-create a live ESTAB socket to the removed
instance — one per worker process.

Fix: skip nodes with rn_displayed=0 in build_rtpp_socks(), avoiding both
socket creation and the rtpp_test ping for deleted nodes.

Note: after a reload, worker processes rebuild their sockets lazily (on
next request). So a stale socket may remain briefly on idle workers until
they process their next request and detect the version change — at which
point the socket is closed and not re-created.

---

Modified: src/modules/rtpengine/rtpengine.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/cfa1d128e2a1745faad914cb6170c2aa74565523.diff
Patch: 
https://github.com/kamailio/kamailio/commit/cfa1d128e2a1745faad914cb6170c2aa74565523.patch

---

diff --git a/src/modules/rtpengine/rtpengine.c 
b/src/modules/rtpengine/rtpengine.c
index a81367064cd..c9a62548df0 100644
--- a/src/modules/rtpengine/rtpengine.c
+++ b/src/modules/rtpengine/rtpengine.c
@@ -2860,6 +2860,9 @@ static int build_rtpp_socks(int lmode, int rtest)
 
                rtpe_reload_lock_get(rtpp_list->rset_lock);
                for(pnode = rtpp_list->rn_first; pnode != 0; pnode = 
pnode->rn_next) {
+                       if(!pnode->rn_displayed) {
+                               continue;
+                       }
                        char *hostname;
                        char *hp;
 

_______________________________________________
Kamailio - Development Mailing List -- [email protected]
To unsubscribe send an email to [email protected]
Important: keep the mailing list in the recipients, do not reply only to the 
sender!

Reply via email to