Browse code

tcp: minor fix: TCP_EV_CONNECT_RST() not always called

The TCP_EV_CONNECT_RST() macro was not called, when a received RST
was "signaled" by a poll/epoll/.. error, because the tcp
connection state was destroyed before it was checked.
(minor impact, only logging was affected)

Reported-and-tested-by: Libor Chocholaty <libor@iptel.org>
Reported-and-tested-by: Jan Pewner <jpewner@iptel.org>

Andrei Pelinescu-Onciul authored on 25/05/2009 18:20:11
Showing 1 changed files
... ...
@@ -3493,10 +3493,6 @@ inline static int handle_tcpconn_ev(struct tcp_connection* tcpconn, short ev,
3493 3493
 			}
3494 3494
 			tcpconn->flags&=~(F_CONN_WRITE_W|F_CONN_READ_W|
3495 3495
 								F_CONN_WANTS_RD|F_CONN_WANTS_WR);
3496
-			if (unlikely(!tcpconn_try_unhash(tcpconn))){
3497
-				LOG(L_CRIT, "BUG: tcpconn_ev: unhashed connection %p\n",
3498
-							tcpconn);
3499
-			}
3500 3496
 			if (unlikely(ev & POLLERR)){
3501 3497
 				if (unlikely(tcpconn->state==S_CONN_CONNECT)){
3502 3498
 #ifdef USE_DST_BLACKLIST
... ...
@@ -3517,6 +3513,10 @@ inline static int handle_tcpconn_ev(struct tcp_connection* tcpconn, short ev,
3517 3517
 					TCP_STATS_CON_RESET(); /* FIXME: it could != RST */
3518 3518
 				}
3519 3519
 			}
3520
+			if (unlikely(!tcpconn_try_unhash(tcpconn))){
3521
+				LOG(L_CRIT, "BUG: tcpconn_ev: unhashed connection %p\n",
3522
+							tcpconn);
3523
+			}
3520 3524
 			tcpconn_put_destroy(tcpconn);
3521 3525
 			goto error;
3522 3526
 		}