Преглед изворни кода

- TM callbacks bug (reflected on acc) fixed

Bogdan-Andrei Iancu пре 21 година
родитељ
комит
cb0a8be5c2
4 измењених фајлова са 27 додато и 18 уклоњено
  1. 0 1
      modules/tm/h_table.c
  2. 1 1
      modules/tm/t_funcs.c
  3. 20 12
      modules/tm/t_hooks.c
  4. 6 4
      modules/tm/t_hooks.h

+ 0 - 1
modules/tm/h_table.c

@@ -158,7 +158,6 @@ void free_cell( struct cell* dead_cell )
 
 
 
-
 struct cell*  build_cell( struct sip_msg* p_msg )
 {
 	struct cell* new_cell;

+ 1 - 1
modules/tm/t_funcs.c

@@ -106,7 +106,7 @@ void tm_shutdown()
 	/* destroy the hash table */
 	DBG("DEBUG: tm_shutdown : empting hash table\n");
 	free_hash_table( );
-	DBG("DEBUG: tm_shutdown: releasing timers\n");
+	DBG("DEBUG: tm_shutdown : releasing timers\n");
 	free_timer_table();
 	DBG("DEBUG: tm_shutdown : removing semaphores\n");
 	lock_cleanup();

+ 20 - 12
modules/tm/t_hooks.c

@@ -73,7 +73,7 @@ void destroy_tmcb_lists()
 	for( cbp=req_in_tmcb_hl->first; cbp ; ) {
 		cbp_tmp = cbp;
 		cbp = cbp->next;
-		if (cbp->param) shm_free( cbp->param );
+		if (cbp_tmp->param) shm_free( cbp_tmp->param );
 		shm_free( cbp_tmp );
 	}
 
@@ -114,10 +114,10 @@ inline int insert_tmcb(struct tmcb_head_list *cb_list, int types,
  * will be called back whenever one of the events occurs in transaction module
  * (global or per transacation, depinding of event type)
 */
-int register_tmcb( struct sip_msg* p_msg, int types, transaction_cb f,
-																void *param )
+int register_tmcb( struct sip_msg* p_msg, struct cell *t, int types,
+											transaction_cb f, void *param )
 {
-	struct cell* t;
+	//struct cell* t;
 	struct tmcb_head_list *cb_list;
 
 	/* are the callback types valid?... */
@@ -140,14 +140,22 @@ int register_tmcb( struct sip_msg* p_msg, int types, transaction_cb f,
 		}
 		cb_list = req_in_tmcb_hl;
 	} else {
-		/* look for the transaction */
-		if ( t_check(p_msg,0)!=1 ){
-			LOG(L_CRIT,"BUG:tm:register_tmcb: no transaction found\n");
-			return E_BUG;
-		}
-		if ( (t=get_t())==0 ) {
-			LOG(L_CRIT,"BUG:tm:register_tmcb: transaction found is NULL\n");
-			return E_BUG;
+		if (!t) {
+			if (!p_msg) {
+				LOG(L_CRIT,"BUG:tm:register_tmcb: no sip_msg, nor transaction"
+					" given\n");
+				return E_BUG;
+			}
+			/* look for the transaction */
+			if ( t_check(p_msg,0)!=1 ){
+				LOG(L_CRIT,"BUG:tm:register_tmcb: no transaction found\n");
+				return E_BUG;
+			}
+			if ( (t=get_t())==0 ) {
+				LOG(L_CRIT,"BUG:tm:register_tmcb: transaction found "
+					"is NULL\n");
+				return E_BUG;
+			}
 		}
 		cb_list = &(t->tmcb_hl);
 	}

+ 6 - 4
modules/tm/t_hooks.h

@@ -171,8 +171,8 @@ struct tmcb_params {
 /* callback function prototype */
 typedef void (transaction_cb) (struct cell* t, int type, struct tmcb_params*);
 /* register callback function prototype */
-typedef int (*register_tmcb_f)(struct sip_msg* p_msg, int cb_types,
-		transaction_cb f, void *param);
+typedef int (*register_tmcb_f)(struct sip_msg* p_msg, struct cell *t,
+		int cb_types, transaction_cb f, void *param);
 
 
 struct tm_callback {
@@ -204,8 +204,10 @@ void destroy_tmcb_lists();
 
 
 /* register a callback for several types of events */
-int register_tmcb( struct sip_msg* p_msg, int types, transaction_cb f,
-																void *param );
+int register_tmcb( struct sip_msg* p_msg, struct cell *t, int types,
+											transaction_cb f, void *param );
+//int register_tmcb( struct sip_msg* p_msg, int types, transaction_cb f,
+//																void *param );
 
 /* inserts a callback into the a callback list */
 int insert_tmcb(struct tmcb_head_list *cb_list, int types,