Jiri Kuthan пре 23 година
родитељ
комит
e7d79f5dd4
6 измењених фајлова са 45 додато и 20 уклоњено
  1. 20 1
      modules/tm/h_table.c
  2. 3 1
      modules/tm/h_table.h
  3. 1 1
      modules/tm/t_fwd.c
  4. 12 12
      modules/tm/t_stats.c
  5. 5 5
      modules/tm/t_stats.h
  6. 4 0
      modules/tm/tm.c

+ 20 - 1
modules/tm/h_table.c

@@ -35,6 +35,7 @@
 #include "../../ut.h"
 #include "../../globals.h"
 #include "../../error.h"
+#include "../../fifo_server.h"
 #include "t_reply.h"
 #include "t_cancel.h"
 #include "t_stats.h"
@@ -360,7 +361,7 @@ void remove_from_hash_table_unsafe( struct cell * p_cell)
 	else
 		p_entry->last_cell = p_cell->prev_cell;
 	/* update stats */
-	p_entry->entries--;
+	/* p_entry->entries--; */
 	cur_stats->transactions--;
 	if (p_cell->local) cur_stats->client_transactions--;
 	cur_stats->waiting--;
@@ -368,4 +369,22 @@ void remove_from_hash_table_unsafe( struct cell * p_cell)
 	/* unlock( &(p_entry->mutex) ); */
 }
 
+/* print accumulated distribution of the hash table */
+int fifo_hash( FILE *stream, char *response_file )
+{
+	FILE *reply_file;
+	unsigned int i;
 
+	reply_file=open_reply_pipe(response_file);
+	if (reply_file==0) {
+		LOG(L_ERR, "ERROR: fifo_hash: file '%s' not opened\n", 
+			response_file);
+		return -1;
+	}
+	fputs( "200 ok\n", reply_file);
+	for (i=0; i<TABLE_ENTRIES; i++) {
+		fprintf(reply_file, "%d.\t%ld\n", i, tm_table->entrys[i].entries );
+	}
+	fclose(reply_file);
+	return 1;
+}

+ 3 - 1
modules/tm/h_table.h

@@ -238,7 +238,7 @@ typedef struct entry
 	unsigned int    next_label;
 	/* sync mutex */
 	ser_lock_t      mutex;
-	unsigned int	entries;
+	unsigned long entries;
 }entry_type;
 
 
@@ -266,6 +266,8 @@ void   insert_into_hash_table_unsafe( struct cell * p_cell );
 
 unsigned int transaction_count( void );
 
+int fifo_hash( FILE *stream, char *response_file );
+
 #endif
 
 

+ 1 - 1
modules/tm/t_fwd.c

@@ -323,7 +323,7 @@ void e2e_cancel( struct sip_msg *cancel_msg,
 	*/
 	DBG("DEBUG: e2e_cancel: sending 487\n");
 	/* in case that something in the meantime has been sent upstream
-	   (like if FR hit at the same time), don't try to send
+	   (like if FR hit at the same time), don't try to send */
 	if (t_invite->uas.status>=200) return;
 	/* there is still a race-condition -- the FR can hit now; that's
 	   not too bad -- we take care in t_reply's REPLY_LOCK; in

+ 12 - 12
modules/tm/t_stats.c

@@ -45,32 +45,32 @@ struct t_stats *cur_stats, *acc_stats;
 int print_stats(  FILE *f )
 {
 	fprintf(f, "Current:\n");
-	fprintf(f, "# of transactions: %d, ", 
+	fprintf(f, "# of transactions: %ld, ", 
 		cur_stats->transactions );
-	fprintf(f, "local: %d, ",
+	fprintf(f, "local: %ld, ",
 		cur_stats->client_transactions );
-	fprintf(f, "waiting: %d" CLEANUP_EOL ,
+	fprintf(f, "waiting: %ld" CLEANUP_EOL ,
 		cur_stats->waiting );
 
 	fprintf(f, "Total:\n");
-	fprintf(f, "# of transactions: %d,",
+	fprintf(f, "# of transactions: %ld,",
 		acc_stats->transactions );
-	fprintf(f, " local: %d,",
+	fprintf(f, " local: %ld,",
 		acc_stats->client_transactions );
-	fprintf(f, " waiting: %d" CLEANUP_EOL ,
+	fprintf(f, " waiting: %ld" CLEANUP_EOL ,
 		acc_stats->waiting );
 
-	fprintf(f, "Replied localy: %d" CLEANUP_EOL ,
+	fprintf(f, "Replied localy: %ld" CLEANUP_EOL ,
 		acc_stats->replied_localy );
-	fprintf(f, "Completion status 6xx: %d,",
+	fprintf(f, "Completion status 6xx: %ld,",
 		acc_stats->completed_6xx );
-	fprintf(f, " 5xx: %d,",
+	fprintf(f, " 5xx: %ld,",
 		acc_stats->completed_5xx );
-	fprintf(f, " 4xx: %d,",
+	fprintf(f, " 4xx: %ld,",
 		acc_stats->completed_4xx );
-	fprintf(f, " 3xx: %d,",
+	fprintf(f, " 3xx: %ld,",
 		acc_stats->completed_3xx );
-	fprintf(f, "2xx: %d" CLEANUP_EOL ,
+	fprintf(f, "2xx: %ld" CLEANUP_EOL ,
 		acc_stats->completed_2xx );
 	
 	return 1;

+ 5 - 5
modules/tm/t_stats.h

@@ -36,15 +36,15 @@ extern struct t_stats *cur_stats, *acc_stats;
 
 struct t_stats {
 	/* number of server transactions */
-	unsigned int transactions;
+	unsigned long transactions;
 	/* number of UAC transactions (part of transactions) */
-	unsigned int client_transactions;
+	unsigned long client_transactions;
 	/* number of transactions in wait state */
-	unsigned int waiting;
+	unsigned long waiting;
 	/* number of transactions which completed with this status */
-	unsigned int completed_3xx, completed_4xx, completed_5xx, 
+	unsigned long completed_3xx, completed_4xx, completed_5xx, 
 		completed_6xx, completed_2xx;
-	unsigned int replied_localy;
+	unsigned long replied_localy;
 };
 
 int init_tm_stats(void);

+ 4 - 0
modules/tm/tm.c

@@ -289,6 +289,10 @@ static int mod_init(void)
 		LOG(L_CRIT, "cannot register fifo uac\n");
 		return -1;
 	}
+	if (register_fifo_cmd(fifo_hash, "t_hash", 0)<0) {
+		LOG(L_CRIT, "cannot register hash\n");
+		return -1;
+	}
 	
 	if (init_tm_stats()<0) {
 		LOG(L_CRIT, "ERROR: mod_init: failed to init stats\n");