浏览代码

tm: allow nested backup of avp lists when sending local requests

- added ability to use a local variable instead static var to
  backup/restore avps lists for local generated transactions
Daniel-Constantin Mierla 14 年之前
父节点
当前提交
08798a6d06
共有 3 个文件被更改,包括 9 次插入5 次删除
  1. 5 2
      modules/tm/h_table.c
  2. 1 1
      modules/tm/h_table.h
  3. 3 2
      modules/tm/uac.c

+ 5 - 2
modules/tm/h_table.c

@@ -492,12 +492,15 @@ error0:
  * - mode = 0 - from msg context to _txdata and use T lists
  * - mode = 1 - restore to msg context from _txdata
  */
-void tm_xdata_swap(tm_cell_t *t, int mode)
+void tm_xdata_swap(tm_cell_t *t, tm_xdata_t *xd, int mode)
 {
 	static tm_xdata_t _txdata;
 	tm_xdata_t *x;
 
-	x = &_txdata;
+	if(xd==NULL)
+		x = &_txdata;
+	else
+		x = xd;
 
 	if(mode==0) {
 		if(t==NULL)

+ 1 - 1
modules/tm/h_table.h

@@ -565,7 +565,7 @@ inline static void remove_from_hash_table_unsafe( struct cell * p_cell)
 /**
  * backup xdata from/to msg context to local var and use T lists
  */
-void tm_xdata_swap(tm_cell_t *t, int mode);
+void tm_xdata_swap(tm_cell_t *t, tm_xdata_t *xd, int mode);
 
 #endif
 

+ 3 - 2
modules/tm/uac.c

@@ -216,6 +216,7 @@ static inline int t_uac_prepare(uac_req_t *uac_r,
 	int backup_route_type;
 #endif
 	snd_flags_t snd_flags;
+	tm_xdata_t backup_xd;
 
 	ret=-1;
 	hi=0; /* make gcc happy */
@@ -353,7 +354,7 @@ static inline int t_uac_prepare(uac_req_t *uac_r,
 				lreq.rcv.comp=dst.comp;
 			#endif /* USE_COMP */
 				sflag_bk = getsflags();
-				tm_xdata_swap(new_cell, 0);
+				tm_xdata_swap(new_cell, &backup_xd, 0);
 
 				/* run the route */
 				backup_route_type = get_route_type();
@@ -372,7 +373,7 @@ static inline int t_uac_prepare(uac_req_t *uac_r,
 				set_route_type( backup_route_type );
 
 				/* restore original environment */
-				tm_xdata_swap(new_cell, 1);
+				tm_xdata_swap(new_cell, &backup_xd, 1);
 				setsflagsval(sflag_bk);
 
 				if (unlikely(lreq.new_uri.s))