Browse code

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 authored on 03/08/2011 17:34:09
Showing 3 changed files
... ...
@@ -492,12 +492,15 @@ error0:
492 492
  * - mode = 0 - from msg context to _txdata and use T lists
493 493
  * - mode = 1 - restore to msg context from _txdata
494 494
  */
495
-void tm_xdata_swap(tm_cell_t *t, int mode)
495
+void tm_xdata_swap(tm_cell_t *t, tm_xdata_t *xd, int mode)
496 496
 {
497 497
 	static tm_xdata_t _txdata;
498 498
 	tm_xdata_t *x;
499 499
 
500
-	x = &_txdata;
500
+	if(xd==NULL)
501
+		x = &_txdata;
502
+	else
503
+		x = xd;
501 504
 
502 505
 	if(mode==0) {
503 506
 		if(t==NULL)
... ...
@@ -565,7 +565,7 @@ inline static void remove_from_hash_table_unsafe( struct cell * p_cell)
565 565
 /**
566 566
  * backup xdata from/to msg context to local var and use T lists
567 567
  */
568
-void tm_xdata_swap(tm_cell_t *t, int mode);
568
+void tm_xdata_swap(tm_cell_t *t, tm_xdata_t *xd, int mode);
569 569
 
570 570
 #endif
571 571
 
... ...
@@ -216,6 +216,7 @@ static inline int t_uac_prepare(uac_req_t *uac_r,
216 216
 	int backup_route_type;
217 217
 #endif
218 218
 	snd_flags_t snd_flags;
219
+	tm_xdata_t backup_xd;
219 220
 
220 221
 	ret=-1;
221 222
 	hi=0; /* make gcc happy */
... ...
@@ -353,7 +354,7 @@ static inline int t_uac_prepare(uac_req_t *uac_r,
353 354
 				lreq.rcv.comp=dst.comp;
354 355
 			#endif /* USE_COMP */
355 356
 				sflag_bk = getsflags();
356
-				tm_xdata_swap(new_cell, 0);
357
+				tm_xdata_swap(new_cell, &backup_xd, 0);
357 358
 
358 359
 				/* run the route */
359 360
 				backup_route_type = get_route_type();
... ...
@@ -372,7 +373,7 @@ static inline int t_uac_prepare(uac_req_t *uac_r,
372 373
 				set_route_type( backup_route_type );
373 374
 
374 375
 				/* restore original environment */
375
-				tm_xdata_swap(new_cell, 1);
376
+				tm_xdata_swap(new_cell, &backup_xd, 1);
376 377
 				setsflagsval(sflag_bk);
377 378
 
378 379
 				if (unlikely(lreq.new_uri.s))