Prechádzať zdrojové kódy

tcp: stats: added init & destroy macros

Andrei Pelinescu-Onciul 16 rokov pred
rodič
commit
0dc023ec75
2 zmenil súbory, kde vykonal 23 pridanie a 1 odobranie
  1. 2 0
      tcp_main.c
  2. 21 1
      tcp_stats.h

+ 2 - 0
tcp_main.c

@@ -3972,6 +3972,7 @@ void destroy_tcp()
 			shm_free(tcpconn_id_hash);
 			shm_free(tcpconn_id_hash);
 			tcpconn_id_hash=0;
 			tcpconn_id_hash=0;
 		}
 		}
+		DESTROY_TCP_STATS();
 		if (tcp_connections_no){
 		if (tcp_connections_no){
 			shm_free(tcp_connections_no);
 			shm_free(tcp_connections_no);
 			tcp_connections_no=0;
 			tcp_connections_no=0;
@@ -4032,6 +4033,7 @@ int init_tcp()
 		goto error;
 		goto error;
 	}
 	}
 	*tcp_connections_no=0;
 	*tcp_connections_no=0;
+	if (INIT_TCP_STATS()!=0) goto error;
 	connection_id=shm_malloc(sizeof(int));
 	connection_id=shm_malloc(sizeof(int));
 	if (connection_id==0){
 	if (connection_id==0){
 		LOG(L_CRIT, "ERROR: init_tcp: could not alloc globals\n");
 		LOG(L_CRIT, "ERROR: init_tcp: could not alloc globals\n");

+ 21 - 1
tcp_stats.h

@@ -27,6 +27,26 @@
 #ifndef __tcp_stats_h
 #ifndef __tcp_stats_h
 #define __tcp_stats_h
 #define __tcp_stats_h
 
 
+#ifndef USE_TCP_STATS
+
+#define INIT_TCP_STATS() 0 /* success */
+#define DESTROY_TCP_STATS()
+
+#define TCP_STATS_ESTABLISHED(state)
+#define TCP_STATS_CONNECT_FAILED()
+#define TCP_STATS_LOCAL_REJECT()
+#define TCP_STATS_CON_TIMEOUT()
+#define TCP_STATS_CON_RESET()
+#define TCP_STATS_SEND_TIMEOUT()
+#define TCP_STATS_SENDQ_FULL()
+
+#else /* USE_TCP_STATS */
+
+#define INIT_TCP_STATS() 0 /* success */
+
+#define DESTROY_TCP_STATS()
+
+
 /** called each time a new tcp connection is established.
 /** called each time a new tcp connection is established.
  *  @param state - S_CONN_ACCEPT if it was the result of an accept()
  *  @param state - S_CONN_ACCEPT if it was the result of an accept()
  *               - S_CONN_CONNECT if it was the result of a connect()
  *               - S_CONN_CONNECT if it was the result of a connect()
@@ -65,7 +85,7 @@
   */
   */
 #define TCP_STATS_SENDQ_FULL()
 #define TCP_STATS_SENDQ_FULL()
 
 
-
+#endif /* USE_TCP_STATS */
 
 
 #endif /*__tcp_stats_h*/
 #endif /*__tcp_stats_h*/