Module: kamailio
Branch: 6.0
Commit: 53091debc027d71a38ccad9adfc9fe35ac22da62
URL: 
https://github.com/kamailio/kamailio/commit/53091debc027d71a38ccad9adfc9fe35ac22da62

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date: 2025-11-27T17:34:31+01:00

core: tcp - decrease busy field if sending to child fails

- GH #4437

(cherry picked from commit 52f9a57e1a4a817b7ad0c05b3673daaf8458bc92)

---

Modified: src/core/tcp_main.c

---

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

---

diff --git a/src/core/tcp_main.c b/src/core/tcp_main.c
index b24349a8b60..43162098d77 100644
--- a/src/core/tcp_main.c
+++ b/src/core/tcp_main.c
@@ -4416,8 +4416,11 @@ inline static int send2child(struct tcp_connection 
*tcpconn)
           even replaced by another one with the same number) so it
           must not be sent to a reader anymore */
        if(unlikely(tcpconn->state == S_CONN_BAD
-                               || (tcpconn->flags & F_CONN_FD_CLOSED)))
+                               || (tcpconn->flags & F_CONN_FD_CLOSED))) {
+               tcp_children[idx].busy--;
+               tcp_children[idx].n_reqs--;
                return -1;
+       }
 #ifdef SEND_FD_QUEUE
        /* if queue full, try to queue the io */
        if(unlikely(send_fd(tcp_children[idx].unix_sock, &tcpconn, 
sizeof(tcpconn),
@@ -4432,11 +4435,15 @@ inline static int send2child(struct tcp_connection 
*tcpconn)
                                           &send2child_q, 
tcp_children[idx].unix_sock, tcpconn)
                                        != 0) {
                                LM_ERR("queue send op. failed\n");
+                               tcp_children[idx].busy--;
+                               tcp_children[idx].n_reqs--;
                                return -1;
                        }
                } else {
                        LM_ERR("send_fd failed for %p (flags 0x%0x), fd %d\n", 
tcpconn,
                                        tcpconn->flags, tcpconn->s);
+                       tcp_children[idx].busy--;
+                       tcp_children[idx].n_reqs--;
                        return -1;
                }
        }
@@ -4446,6 +4453,8 @@ inline static int send2child(struct tcp_connection 
*tcpconn)
                                <= 0)) {
                LM_ERR("send_fd failed for %p (flags 0x%0x), fd %d\n", tcpconn,
                                tcpconn->flags, tcpconn->s);
+               tcp_children[idx].busy--;
+               tcp_children[idx].n_reqs--;
                return -1;
        }
 #endif

_______________________________________________
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