Browse code

tcp: stats: added init & destroy macros

Andrei Pelinescu-Onciul authored on 10/04/2009 10:24:40
Showing 2 changed files
... ...
@@ -3972,6 +3972,7 @@ void destroy_tcp()
3972 3972
 			shm_free(tcpconn_id_hash);
3973 3973
 			tcpconn_id_hash=0;
3974 3974
 		}
3975
+		DESTROY_TCP_STATS();
3975 3976
 		if (tcp_connections_no){
3976 3977
 			shm_free(tcp_connections_no);
3977 3978
 			tcp_connections_no=0;
... ...
@@ -4032,6 +4033,7 @@ int init_tcp()
4032 4032
 		goto error;
4033 4033
 	}
4034 4034
 	*tcp_connections_no=0;
4035
+	if (INIT_TCP_STATS()!=0) goto error;
4035 4036
 	connection_id=shm_malloc(sizeof(int));
4036 4037
 	if (connection_id==0){
4037 4038
 		LOG(L_CRIT, "ERROR: init_tcp: could not alloc globals\n");
... ...
@@ -27,6 +27,26 @@
27 27
 #ifndef __tcp_stats_h
28 28
 #define __tcp_stats_h
29 29
 
30
+#ifndef USE_TCP_STATS
31
+
32
+#define INIT_TCP_STATS() 0 /* success */
33
+#define DESTROY_TCP_STATS()
34
+
35
+#define TCP_STATS_ESTABLISHED(state)
36
+#define TCP_STATS_CONNECT_FAILED()
37
+#define TCP_STATS_LOCAL_REJECT()
38
+#define TCP_STATS_CON_TIMEOUT()
39
+#define TCP_STATS_CON_RESET()
40
+#define TCP_STATS_SEND_TIMEOUT()
41
+#define TCP_STATS_SENDQ_FULL()
42
+
43
+#else /* USE_TCP_STATS */
44
+
45
+#define INIT_TCP_STATS() 0 /* success */
46
+
47
+#define DESTROY_TCP_STATS()
48
+
49
+
30 50
 /** called each time a new tcp connection is established.
31 51
  *  @param state - S_CONN_ACCEPT if it was the result of an accept()
32 52
  *               - S_CONN_CONNECT if it was the result of a connect()
... ...
@@ -65,7 +85,7 @@
65 65
   */
66 66
 #define TCP_STATS_SENDQ_FULL()
67 67
 
68
-
68
+#endif /* USE_TCP_STATS */
69 69
 
70 70
 #endif /*__tcp_stats_h*/
71 71