Browse code

tm: Always compile TMCB_ONSEND code, it was used unconditionally anyway.

Timo Reimann authored on 05/10/2011 08:14:21
Showing 8 changed files
... ...
@@ -141,14 +141,12 @@ void run_trans_dlg_callbacks(dlg_t* dlg, struct cell* trans,
141 141
 	if (dlg->dlg_callbacks.first==0)
142 142
 		return;
143 143
 	memset(&params, 0, sizeof(params));
144
-#ifdef TMCB_ONSEND
145 144
 	if (rbuf){
146 145
 		params.t_rbuf=rbuf;
147 146
 		params.dst=&rbuf->dst;
148 147
 		params.send_buf.s=rbuf->buffer;
149 148
 		params.send_buf.len=rbuf->buffer_len;
150 149
 	}
151
-#endif
152 150
 	
153 151
 	run_trans_callbacks_internal(&dlg->dlg_callbacks, TMCB_DLG, trans, 
154 152
 									&params);
... ...
@@ -326,14 +326,10 @@ int cancel_branch( struct cell *t, int branch,
326 326
 	crb->buffer_len = len;
327 327
 
328 328
 	DBG("DEBUG: cancel_branch: sending cancel...\n");
329
-#ifdef TMCB_ONSEND
330 329
 	if (SEND_BUFFER( crb )>=0){
331 330
 		if (unlikely (has_tran_tmcbs(t, TMCB_REQUEST_SENT)))
332 331
 			run_onsend_callbacks(TMCB_REQUEST_SENT, crb, 0, 0, TMCB_LOCAL_F);
333 332
 	}
334
-#else
335
-	SEND_BUFFER( crb );
336
-#endif
337 333
 	/*sets and starts the FINAL RESPONSE timer */
338 334
 	if (start_retr( crb )!=0)
339 335
 		LOG(L_CRIT, "BUG: cancel_branch: failed to start retransmission"
... ...
@@ -1188,14 +1188,12 @@ void e2e_cancel( struct sip_msg *cancel_msg,
1188 1188
 				if (SEND_BUFFER(&t_cancel->uac[i].request) == -1) {
1189 1189
 					LOG(L_ERR, "ERROR: e2e_cancel: send failed\n");
1190 1190
 				}
1191
-#ifdef TMCB_ONSEND
1192 1191
 				else{
1193 1192
 					if (unlikely(has_tran_tmcbs(t_cancel, TMCB_REQUEST_SENT)))
1194 1193
 						run_onsend_callbacks(TMCB_REQUEST_SENT, 
1195 1194
 												&t_cancel->uac[i].request,
1196 1195
 												cancel_msg, 0, TMCB_LOCAL_F);
1197 1196
 				}
1198
-#endif
1199 1197
 				if (start_retr( &t_cancel->uac[i].request )!=0)
1200 1198
 					LOG(L_CRIT, "BUG: e2e_cancel: failed to start retr."
1201 1199
 							" for %p\n", &t_cancel->uac[i].request);
... ...
@@ -1382,10 +1380,8 @@ int t_send_branch( struct cell *t, int branch, struct sip_msg* p_msg ,
1382 1380
 		if (proxy) { proxy->errors++; proxy->ok=0; }
1383 1381
 		return -2;
1384 1382
 	} else {
1385
-#ifdef TMCB_ONSEND
1386 1383
 		if (unlikely(has_tran_tmcbs(t, TMCB_REQUEST_SENT)))
1387 1384
 			run_onsend_callbacks(TMCB_REQUEST_SENT, &uac->request, p_msg, 0,0);
1388
-#endif
1389 1385
 		/* start retr. only if the send succeeded */
1390 1386
 		if (start_retr( &uac->request )!=0){
1391 1387
 			LOG(L_CRIT, "BUG: t_send_branch: retr. already started for %p\n",
... ...
@@ -319,7 +319,6 @@ void run_trans_callbacks( int type , struct cell *trans,
319 319
 
320 320
 
321 321
 
322
-#ifdef TMCB_ONSEND
323 322
 void run_onsend_callbacks(int type, struct retr_buf* rbuf,
324 323
 					struct sip_msg* req, struct sip_msg* repl, short flags)
325 324
 {
... ...
@@ -347,7 +346,6 @@ void run_onsend_callbacks2(int type, struct cell* trans, struct tmcb_params* p)
347 346
 	run_trans_callbacks_internal(&trans->tmcb_hl, type, p->t_rbuf->my_T, p);
348 347
 }
349 348
 
350
-#endif
351 349
 
352 350
 static void run_reqin_callbacks_internal(struct tmcb_head_list* hl,
353 351
 							struct cell *trans, struct tmcb_params* params)
... ...
@@ -46,12 +46,12 @@
46 46
 
47 47
 #include "defs.h"
48 48
 
49
-/* if defined support for ONSEND callbacks will be added and
50
- * the tmcb_params structure will get some additional members */
49
+/* TMCB_ONSEND used to enable certain callback-related features when
50
+ * ONSEND was set, these days it's always enabled. For compatibility
51
+ * reasons with modules that check ONSEND, continue to set it
52
+ * unconditionally*/
51 53
 #define TMCB_ONSEND
52
-#ifdef TMCB_ONSEND
53 54
 #include "../../ip_addr.h" /* dest_info */
54
-#endif
55 55
 
56 56
 struct sip_msg;
57 57
 struct cell;
... ...
@@ -78,13 +78,9 @@ struct cell;
78 78
 #ifdef WITH_AS_SUPPORT
79 79
 #define TMCB_DONT_ACK_N         19 /* TM shoudn't ACK a local UAC  */
80 80
 #endif
81
-#ifdef TMCB_ONSEND
82 81
 #define TMCB_REQUEST_SENT_N     20
83 82
 #define TMCB_RESPONSE_SENT_N    21
84 83
 #define TMCB_MAX_N              21
85
-#else
86
-#define TMCB_MAX_N              19
87
-#endif
88 84
 
89 85
 
90 86
 #define TMCB_REQUEST_IN       (1<<TMCB_REQUEST_IN_N)
... ...
@@ -109,10 +105,8 @@ struct cell;
109 105
 #ifdef WITH_AS_SUPPORT
110 106
 #define TMCB_DONT_ACK         (1<<TMCB_DONT_ACK_N)
111 107
 #endif
112
-#ifdef TMCB_ONSEND
113 108
 #define TMCB_REQUEST_SENT      (1<<TMCB_REQUEST_SENT_N)
114 109
 #define TMCB_RESPONSE_SENT     (1<<TMCB_RESPONSE_SENT_N)
115
-#endif
116 110
 #define TMCB_MAX              ((1<<(TMCB_MAX_N+1))-1)
117 111
 
118 112
 
... ...
@@ -294,17 +288,15 @@ struct cell;
294 288
  *  t_uac.
295 289
  *   For a reply the code is the response status (which is always >0, e.g. 200,
296 290
  *   408, a.s.o).
297
- *  Note: - these callbacks can be used only if TMCB_ONSEND is defined.
298 291
  *        - the callbacks will be called sometimes with the REPLY lock held
299 292
  *          and sometimes without it, so trying to acquire the REPLY lock
300 293
  *          from these callbacks could lead to deadlocks (avoid it unless
301 294
  *           you really know what you're doing).
302 295
  *
303
- *  TMCB_REQUEST_SENT (present only if TMCB_ONSEND is defined) -- called 
304
- *  each time a request was sent (even for retransmissions), it includes 
305
- *  local and forwarded request, ser generated CANCELs and ACKs. The 
306
- *  tmcb_params structure will have the t_rbuf, dst, send_buf and is_retr
307
- *  members  filled.
296
+ *  TMCB_REQUEST_SENT -- called each time a request was sent (even for
297
+ *  retransmissions), it includes *  local and forwarded request, ser generated
298
+ *  CANCELs and ACKs. The tmcb_params structure will have the t_rbuf, dst,
299
+ *  send_buf and is_retr members filled.
308 300
  *  This callback is "read-only", the message was already sent and no changes
309 301
  *  are allowed.
310 302
  *  Note: send_buf can be different from t_rbuf->buffer for ACKs (in this
... ...
@@ -312,11 +304,11 @@ struct cell;
312 304
  *   its destination). The same goes for t_rbuf->dst and tmcb->dst for local 
313 305
  *   transactions ACKs to 2xxs.
314 306
  *
315
- *  TMCB_RESPONSE_SENT  (present only if TMCB_ONSEND is defined) -- called 
316
- *  each time a response was sent (even for retransmissions). The tmcb_params
317
- *   structure will have t_rbuf set to the reply retransmission buffer and
318
- *   send_buf set to the data sent (in this case it will always be the same 
319
- *   with t_rbuf->buf). is_retr will also be set if the reply is retransmitted
307
+ *  TMCB_RESPONSE_SENT -- called each time a response was sent (even for
308
+ *  retransmissions). The tmcb_params structure will have t_rbuf set to the
309
+ *  reply retransmission buffer and send_buf set to the data sent (in this case
310
+ *  it will always be the same with t_rbuf->buf). is_retr will also be set if
311
+ *  the reply is retransmitted
320 312
  *   by ser.
321 313
  *  This callback is "read-only", the message was already sent and no changes
322 314
  *  are allowed.
... ...
@@ -343,10 +335,8 @@ struct cell;
343 335
 	).
344 336
 */
345 337
 
346
-#ifdef TMCB_ONSEND
347 338
 #define TMCB_RETR_F 1
348 339
 #define TMCB_LOCAL_F 2
349
-#endif
350 340
 
351 341
 /* pack structure with all params passed to callback function */
352 342
 struct tmcb_params {
... ...
@@ -354,7 +344,6 @@ struct tmcb_params {
354 344
 	struct sip_msg* rpl;
355 345
 	void **param;
356 346
 	int code;
357
-#ifdef TMCB_ONSEND
358 347
 	unsigned short flags; /* set to a combination of:
359 348
 							 TMCB_RETR_F if this is a _ser_ retransmission
360 349
 							 (but not if if it's a "forwarded" retr., like a 
... ...
@@ -370,7 +359,6 @@ struct tmcb_params {
370 359
 	struct dest_info* dst; /* destination */
371 360
 	str send_buf; /* what was/will be sent on the net, used for ACKs
372 361
 					(which don't have a retr_buf). */
373
-#endif
374 362
 };
375 363
 
376 364
 #define INIT_TMCB_PARAMS(tmcb, request, reply, r_code)\
... ...
@@ -380,7 +368,6 @@ do{\
380 368
 	(tmcb).code=(r_code); \
381 369
 }while(0)
382 370
 
383
-#ifdef TMCB_ONSEND
384 371
 #define INIT_TMCB_ONSEND_PARAMS(tmcb, req, repl, rbuf, dest, buf, buf_len, \
385 372
 								onsend_flags, t_branch, code) \
386 373
 do{ \
... ...
@@ -389,7 +376,6 @@ do{ \
389 376
 	tmcb.send_buf.s=(buf); tmcb.send_buf.len=(buf_len); \
390 377
 	tmcb.flags=(onsend_flags); tmcb.branch=(t_branch); \
391 378
 }while(0)
392
-#endif
393 379
 
394 380
 /* callback function prototype */
395 381
 typedef void (transaction_cb) (struct cell* t, int type, struct tmcb_params*);
... ...
@@ -458,11 +444,9 @@ void run_reqin_callbacks( struct cell *trans, struct sip_msg *req, int code );
458 444
 void run_local_reqin_callbacks( struct cell *trans, struct sip_msg *req, 
459 445
 		int code );
460 446
 
461
-#ifdef TMCB_ONSEND
462
-
447
+/* TBD: explanation */
463 448
 void run_onsend_callbacks(int type, struct retr_buf* rbuf, struct sip_msg* req,
464 449
 									struct sip_msg* repl, short flags);
465 450
 void run_onsend_callbacks2(int type, struct cell* t, struct tmcb_params* p);
466
-#endif
467 451
 
468 452
 #endif
... ...
@@ -564,9 +564,7 @@ static int _reply_light( struct cell *trans, char* buf, unsigned int len,
564 564
 	struct retr_buf *rb;
565 565
 	unsigned int buf_len;
566 566
 	struct cancel_info cancel_data;
567
-#ifdef TMCB_ONSEND
568 567
 	struct tmcb_params onsend_params;
569
-#endif
570 568
 
571 569
 	init_cancel_info(&cancel_data);
572 570
 	if (!buf)
... ...
@@ -653,7 +651,6 @@ static int _reply_light( struct cell *trans, char* buf, unsigned int len,
653 651
 						has_tran_tmcbs(trans, TMCB_RESPONSE_OUT)) )
654 652
 				run_trans_callbacks(TMCB_RESPONSE_OUT, trans,
655 653
 									trans->uas.request, FAKED_REPLY, code);
656
-#ifdef TMCB_ONSEND
657 654
 			if (unlikely(has_tran_tmcbs(trans, TMCB_RESPONSE_SENT))){
658 655
 				INIT_TMCB_ONSEND_PARAMS(onsend_params, trans->uas.request,
659 656
 								FAKED_REPLY, rb, &rb->dst, 
... ...
@@ -661,7 +658,6 @@ static int _reply_light( struct cell *trans, char* buf, unsigned int len,
661 658
 				run_onsend_callbacks2(TMCB_RESPONSE_SENT, trans,
662 659
 										&onsend_params);
663 660
 			}
664
-#endif /* TMCB_ONSEND */
665 661
 		}
666 662
 		DBG("DEBUG: reply sent out. buf=%p: %.20s..., shmem=%p: %.20s\n",
667 663
 			buf, buf, rb->buffer, rb->buffer );
... ...
@@ -1444,14 +1440,12 @@ int t_retransmit_reply( struct cell *t )
1444 1440
 	memcpy( b, t->uas.response.buffer, len );
1445 1441
 	UNLOCK_REPLIES( t );
1446 1442
 	SEND_PR_BUFFER( & t->uas.response, b, len );
1447
-#ifdef TMCB_ONSEND
1448 1443
 	if (unlikely(has_tran_tmcbs(t, TMCB_RESPONSE_SENT))){ 
1449 1444
 		/* we don't know if it's a retransmission of a local reply or a 
1450 1445
 		 * forwarded reply */
1451 1446
 		run_onsend_callbacks(TMCB_RESPONSE_SENT, &t->uas.response, 0, 0,
1452 1447
 								TMCB_RETR_F);
1453 1448
 	}
1454
-#endif
1455 1449
 	DBG("DEBUG: reply retransmitted. buf=%p: %.9s..., shmem=%p: %.9s\n",
1456 1450
 		b, b, t->uas.response.buffer, t->uas.response.buffer );
1457 1451
 	return 1;
... ...
@@ -1635,9 +1629,7 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
1635 1629
 	struct retr_buf *uas_rb;
1636 1630
 	str* to_tag;
1637 1631
 	str reason;
1638
-#ifdef TMCB_ONSEND
1639 1632
 	struct tmcb_params onsend_params;
1640
-#endif
1641 1633
 
1642 1634
 	/* keep compiler warnings about use of uninit vars silent */
1643 1635
 	res_len=0;
... ...
@@ -1831,7 +1823,6 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
1831 1823
 				run_trans_callbacks( TMCB_RESPONSE_OUT, t, t->uas.request,
1832 1824
 					relayed_msg, relayed_code);
1833 1825
 			}
1834
-#ifdef TMCB_ONSEND
1835 1826
 			if (unlikely(has_tran_tmcbs(t, TMCB_RESPONSE_SENT))){
1836 1827
 				INIT_TMCB_ONSEND_PARAMS(onsend_params, t->uas.request,
1837 1828
 									relayed_msg, uas_rb, &uas_rb->dst, buf,
... ...
@@ -1840,7 +1831,6 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
1840 1831
 									uas_rb->branch, relayed_code);
1841 1832
 				run_onsend_callbacks2(TMCB_RESPONSE_SENT, t, &onsend_params);
1842 1833
 			}
1843
-#endif
1844 1834
 		} else if (unlikely(uas_rb->dst.send_sock == 0))
1845 1835
 			ERR("no resolved dst to send reply to\n");
1846 1836
 		/* Call put_on_wait() only if we really send out
... ...
@@ -2013,9 +2003,7 @@ int reply_received( struct sip_msg  *p_msg )
2013 2003
 	int blst_503_timeout;
2014 2004
 	struct hdr_field* hf;
2015 2005
 #endif
2016
-#ifdef TMCB_ONSEND
2017 2006
 	struct tmcb_params onsend_params;
2018
-#endif
2019 2007
 	struct run_act_ctx ctx;
2020 2008
 
2021 2009
 	/* make sure we know the associated transaction ... */
... ...
@@ -2074,7 +2062,6 @@ int reply_received( struct sip_msg  *p_msg )
2074 2062
 			if (msg_status >= 300) {
2075 2063
 				ack = build_ack(p_msg, t, branch, &ack_len);
2076 2064
 				if (ack) {
2077
-#ifdef	TMCB_ONSEND
2078 2065
 					if (SEND_PR_BUFFER(&uac->request, ack, ack_len)>=0)
2079 2066
 						if (unlikely(has_tran_tmcbs(t, TMCB_REQUEST_SENT))){ 
2080 2067
 							INIT_TMCB_ONSEND_PARAMS(onsend_params, 
... ...
@@ -2084,9 +2071,6 @@ int reply_received( struct sip_msg  *p_msg )
2084 2071
 							run_onsend_callbacks2(TMCB_REQUEST_SENT, t,
2085 2072
 													&onsend_params);
2086 2073
 						}
2087
-#else
2088
-					SEND_PR_BUFFER(&uac->request, ack, ack_len);
2089
-#endif
2090 2074
 					shm_free(ack);
2091 2075
 				}
2092 2076
 			} else if (is_local(t) /*&& 200 <= msg_status < 300*/) {
... ...
@@ -2094,7 +2078,6 @@ int reply_received( struct sip_msg  *p_msg )
2094 2078
 				if (ack) {
2095 2079
 					if (msg_send(&lack_dst, ack, ack_len)<0)
2096 2080
 						LOG(L_ERR, "Error while sending local ACK\n");
2097
-#ifdef	TMCB_ONSEND
2098 2081
 					else if (unlikely(has_tran_tmcbs(t, TMCB_REQUEST_SENT))){
2099 2082
 							INIT_TMCB_ONSEND_PARAMS(onsend_params, 
2100 2083
 									t->uas.request, p_msg, &uac->request,
... ...
@@ -2103,7 +2086,6 @@ int reply_received( struct sip_msg  *p_msg )
2103 2086
 							run_onsend_callbacks2(TMCB_REQUEST_SENT, t,
2104 2087
 													&onsend_params);
2105 2088
 					}
2106
-#endif
2107 2089
 #ifndef WITH_AS_SUPPORT
2108 2090
 					shm_free(ack);
2109 2091
 #endif
... ...
@@ -2119,16 +2101,12 @@ int reply_received( struct sip_msg  *p_msg )
2119 2101
 								  local_cancel */
2120 2102
 				/* re-transmit if cancel already built */
2121 2103
 				DBG("tm: reply_received: branch CANCEL retransmit\n");
2122
-#ifdef TMCB_ONSEND
2123 2104
 				if (SEND_BUFFER( &uac->local_cancel)>=0){
2124 2105
 					if (unlikely (has_tran_tmcbs(t, TMCB_REQUEST_SENT)))
2125 2106
 						run_onsend_callbacks(TMCB_REQUEST_SENT,
2126 2107
 											&uac->local_cancel,
2127 2108
 											0, 0, TMCB_LOCAL_F);
2128 2109
 				}
2129
-#else
2130
-				SEND_BUFFER( &uac->local_cancel );
2131
-#endif
2132 2110
 				/* retrs. should be already started so do nothing */
2133 2111
 			}else if (atomic_cmpxchg_long((void*)&uac->local_cancel.buffer, 0,
2134 2112
 										(long)BUSY_BUFFER)==0){
... ...
@@ -392,11 +392,9 @@ inline static ticks_t retransmission_handler( struct retr_buf *r_buf )
392 392
 				fake_reply(r_buf->my_T, r_buf->branch, 503 );
393 393
 				return (ticks_t)-1;
394 394
 			}
395
-#ifdef TMCB_ONSEND
396 395
 			if (unlikely(has_tran_tmcbs(r_buf->my_T, TMCB_REQUEST_SENT))) 
397 396
 				run_onsend_callbacks(TMCB_REQUEST_SENT, r_buf, 
398 397
 										0, 0, TMCB_RETR_F);
399
-#endif
400 398
 	} else {
401 399
 #ifdef EXTRA_DEBUG
402 400
 			DBG("DEBUG: retransmission_handler : "
... ...
@@ -495,12 +495,10 @@ static inline void send_prepared_request_impl(struct retr_buf *request, int retr
495 495
 	if (SEND_BUFFER(request) == -1) {
496 496
 		LOG(L_ERR, "t_uac: Attempt to send to precreated request failed\n");
497 497
 	}
498
-#ifdef TMCB_ONSEND
499 498
 	else if (unlikely(has_tran_tmcbs(request->my_T, TMCB_REQUEST_SENT)))
500 499
 		/* we don't know the method here */
501 500
 			run_onsend_callbacks(TMCB_REQUEST_SENT, request, 0, 0,
502 501
 									TMCB_LOCAL_F);
503
-#endif
504 502
 	
505 503
 	if (retransmit && (start_retr(request)!=0))
506 504
 		LOG(L_CRIT, "BUG: t_uac: failed to start retr. for %p\n", request);
... ...
@@ -599,9 +597,7 @@ int ack_local_uac(struct cell *trans, str *hdrs, str *body)
599 597
 {
600 598
 	struct retr_buf *local_ack, *old_lack;
601 599
 	int ret;
602
-#ifdef	TMCB_ONSEND
603 600
 	struct tmcb_params onsend_params;
604
-#endif
605 601
 
606 602
 	/* sanity checks */
607 603
 
... ...
@@ -661,7 +657,6 @@ int ack_local_uac(struct cell *trans, str *hdrs, str *body)
661 657
 		ret = -1;
662 658
 		goto fin;
663 659
 	}
664
-#ifdef	TMCB_ONSEND
665 660
 	else {
666 661
 		INIT_TMCB_ONSEND_PARAMS(onsend_params, 0, 0, &trans->uac[0].request,
667 662
 								&local_ack->dst,
... ...
@@ -669,7 +664,6 @@ int ack_local_uac(struct cell *trans, str *hdrs, str *body)
669 664
 								TMCB_LOCAL_F, 0 /* branch */, TYPE_LOCAL_ACK);
670 665
 		run_onsend_callbacks2(TMCB_REQUEST_SENT, trans, &onsend_params);
671 666
 	}
672
-#endif
673 667
 
674 668
 	ret = 0;
675 669
 fin: