Module: sip-router Branch: master Commit: b3d312bc3795f394e5907ac54bb59560e829e38b URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=b3d312bc...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: Mon Apr 21 21:39:07 2014 +0200
core: proper destroy of tcp connection at shutdown
- don't access connection fields after freeing structure
---
tcp_main.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/tcp_main.c b/tcp_main.c index c0320dd..701f90f 100644 --- a/tcp_main.c +++ b/tcp_main.c @@ -4517,9 +4517,12 @@ static inline void tcpconn_destroy_all(void) #ifdef USE_TLS if (fd>0 && (c->type==PROTO_TLS || c->type==PROTO_WSS)) tls_close(c, fd); + if (unlikely(c->type==PROTO_TLS || c->type==PROTO_WSS)) + (*tls_connections_no)--; #endif - _tcpconn_rm(c); + (*tcp_connections_no)--; c->flags &= ~F_CONN_HASHED; + _tcpconn_rm(c); if (fd>0) { #ifdef TCP_FD_CACHE if (likely(cfg_get(tcp, tcp_cfg, fd_cache))) @@ -4527,9 +4530,6 @@ static inline void tcpconn_destroy_all(void) #endif /* TCP_FD_CACHE */ tcp_safe_close(fd); } - (*tcp_connections_no)--; - if (unlikely(c->type==PROTO_TLS || c->type==PROTO_WSS)) - (*tls_connections_no)--; c=next; } }