Преглед на файлове

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 години
родител
ревизия
a8859f52b9
променени са 1 файла, в които са добавени 4 реда и са изтрити 4 реда
  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() */
 		}
 	}