Browse code

tcp: fix double increment for the established stats

The counter/stats for established TCP connections were incremented
twice in the case of accept()-ed connections: once immediately
after the accept() and another time after the first packet
received or sent on the connection.
Now they are incremented only after the first successful send or
receive.

Andrei Pelinescu-Onciul authored on 18/08/2010 16:36:14
Showing 1 changed files
... ...
@@ -3973,7 +3973,15 @@ static inline int handle_new_connect(struct socket_info* si)
3973 3973
 		return 1; /* success, because the accept was succesfull */
3974 3974
 	}
3975 3975
 	(*tcp_connections_no)++;
3976
-	TCP_STATS_ESTABLISHED(S_CONN_ACCEPT);
3976
+	/* stats for established connections are incremented after
3977
+	   the first received or sent packet.
3978
+	   Alternatively they could be incremented here for accepted
3979
+	   connections, but then the connection state must be changed to
3980
+	  S_CONN_OK:
3981
+	  TCP_STATS_ESTABLISHED(S_CONN_ACCEPT);
3982
+	  ...
3983
+	  tcpconn=tcpconn_new(new_sock, &su, dst_su, si, si->proto, S_CONN_OK);
3984
+	*/
3977 3985
 	
3978 3986
 	dst_su=&si->su;
3979 3987
 	if (unlikely(si->flags & SI_IS_ANY)){