tcp: fix double increment for the established stats
authorAndrei Pelinescu-Onciul <andrei@iptel.org>
Wed, 18 Aug 2010 16:36:14 +0000 (18:36 +0200)
committerAndrei Pelinescu-Onciul <andrei@iptel.org>
Wed, 18 Aug 2010 16:49:10 +0000 (18:49 +0200)
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.

tcp_main.c

index a1761f6..31fc0fa 100644 (file)
@@ -3973,7 +3973,15 @@ static inline int handle_new_connect(struct socket_info* si)
                return 1; /* success, because the accept was succesfull */
        }
        (*tcp_connections_no)++;
-       TCP_STATS_ESTABLISHED(S_CONN_ACCEPT);
+       /* stats for established connections are incremented after
+          the first received or sent packet.
+          Alternatively they could be incremented here for accepted
+          connections, but then the connection state must be changed to
+         S_CONN_OK:
+         TCP_STATS_ESTABLISHED(S_CONN_ACCEPT);
+         ...
+         tcpconn=tcpconn_new(new_sock, &su, dst_su, si, si->proto, S_CONN_OK);
+       */
        
        dst_su=&si->su;
        if (unlikely(si->flags & SI_IS_ANY)){