Browse code

core: proper destroy of tcp connection at shutdown

- don't access connection fields after freeing structure

Daniel-Constantin Mierla authored on 21/04/2014 19:39:07
Showing 1 changed files
... ...
@@ -4517,9 +4517,12 @@ static inline void tcpconn_destroy_all(void)
4517 4517
 #ifdef USE_TLS
4518 4518
 				if (fd>0 && (c->type==PROTO_TLS || c->type==PROTO_WSS))
4519 4519
 					tls_close(c, fd);
4520
+				if (unlikely(c->type==PROTO_TLS || c->type==PROTO_WSS))
4521
+					(*tls_connections_no)--;
4520 4522
 #endif
4521
-				_tcpconn_rm(c);
4523
+				(*tcp_connections_no)--;
4522 4524
 				c->flags &= ~F_CONN_HASHED;
4525
+				_tcpconn_rm(c);
4523 4526
 				if (fd>0) {
4524 4527
 #ifdef TCP_FD_CACHE
4525 4528
 					if (likely(cfg_get(tcp, tcp_cfg, fd_cache)))
... ...
@@ -4527,9 +4530,6 @@ static inline void tcpconn_destroy_all(void)
4527 4527
 #endif /* TCP_FD_CACHE */
4528 4528
 					tcp_safe_close(fd);
4529 4529
 				}
4530
-				(*tcp_connections_no)--;
4531
-				if (unlikely(c->type==PROTO_TLS || c->type==PROTO_WSS))
4532
-					(*tls_connections_no)--;
4533 4530
 			c=next;
4534 4531
 		}
4535 4532
 	}