Selaa lähdekoodia

tcp: fix send2child() error case

If send2child() fails don't decrement the refcnt if the connection
was already removed from the hash due to some other previous
error (very unlikely, but possible).
Andrei Pelinescu-Onciul 14 vuotta sitten
vanhempi
commit
a8859f52b9
1 muutettua tiedostoa jossa 4 lisäystä ja 4 poistoa
  1. 4 4
      tcp_main.c

+ 4 - 4
tcp_main.c

@@ -4036,8 +4036,8 @@ static inline int handle_new_connect(struct socket_info* si)
 			su2a(&su, sizeof(su)), tcpconn, tcpconn->s, tcpconn->flags);
 		if(unlikely(send2child(tcpconn)<0)){
 			tcpconn->flags&=~F_CONN_READER;
-			tcpconn_put(tcpconn);
-			tcpconn_try_unhash(tcpconn);
+			if (tcpconn_try_unhash(tcpconn))
+				tcpconn_put(tcpconn);
 			tcpconn_put_destroy(tcpconn);
 		}
 #endif
@@ -4226,8 +4226,8 @@ send_to_child:
 				tcpconn->flags&=~F_CONN_WRITE_W;
 			}
 #endif /* TCP_ASYNC */
-			tcpconn_put(tcpconn);
-			tcpconn_try_unhash(tcpconn); 
+			if (tcpconn_try_unhash(tcpconn))
+				tcpconn_put(tcpconn);
 			tcpconn_put_destroy(tcpconn); /* because of the tcpconn_ref() */
 		}
 	}