Browse code

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

Andrei Pelinescu-Onciul authored on 18/09/2009 18:52:37
Showing 1 changed files
... ...
@@ -2270,6 +2270,9 @@ conn_wait_close:
2270 2270
 	 * connection (tcpconn_chld_put(c))) or when tcp_main receives a
2271 2271
 	 * CONN_ERROR it*/
2272 2272
+	/* 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);
2273 2276
2274 2277
 		if (c->flags & F_CONN_HASHED){
2275 2278
 			/* if some other parallel tcp_send did send CONN_ERROR to