Module: sip-router
Branch: master
Commit: b8d528b657bd52fce0b342e01380001b4ffa15fe
URL:    
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=b8d528b657bd52fce0b342e01380001b4ffa15fe

Author: Andrei Pelinescu-Onciul <[email protected]>
Committer: Andrei Pelinescu-Onciul <[email protected]>
Date:   Fri Sep 18 20:52:37 2009 +0200

tcp: fix fd leak on async error or quick connect

In some error cases (from which the most likely to appear in
real-life would be maximum global send queue size exceeded),
the fd for a new created connection (in tcp_send()) was not closed
when the connection was destroyed.
Same thing happened in the case of a "quick" connect (connect & send
finish immediately, this happens in general only on localhost) for
a connection marked as close-after-send (via the new msg
send_flags).

---

 tcp_main.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/tcp_main.c b/tcp_main.c
index a72e3cc..d2f7b59 100644
--- a/tcp_main.c
+++ b/tcp_main.c
@@ -2270,6 +2270,9 @@ conn_wait_close:
         * connection (tcpconn_chld_put(c))) or when tcp_main receives a
         * CONN_ERROR it*/
        c->state=S_CONN_BAD;
+       /* we are here only if we opened a new fd (and not reused a cached or
+          a reader one) => if the connect was successful close the fd */
+       if (fd>=0) close(fd);
        TCPCONN_LOCK;
                if (c->flags & F_CONN_HASHED){
                        /* if some other parallel tcp_send did send CONN_ERROR 
to


_______________________________________________
sr-dev mailing list
[email protected]
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to