tm: Always compile TMCB_ONSEND code, it was used unconditionally anyway.
authorTimo Reimann <timo.reimann@1und1.de>
Wed, 5 Oct 2011 08:14:21 +0000 (10:14 +0200)
committerTimo Reimann <timo.reimann@1und1.de>
Mon, 17 Oct 2011 18:05:46 +0000 (20:05 +0200)
modules/tm/dlg.c
modules/tm/t_cancel.c
modules/tm/t_fwd.c
modules/tm/t_hooks.c
modules/tm/t_hooks.h
modules/tm/t_reply.c
modules/tm/timer.c
modules/tm/uac.c

index bc8ed7c..647e34f 100644 (file)
@@ -141,14 +141,12 @@ void run_trans_dlg_callbacks(dlg_t* dlg, struct cell* trans,
        if (dlg->dlg_callbacks.first==0)
                return;
        memset(&params, 0, sizeof(params));
-#ifdef TMCB_ONSEND
        if (rbuf){
                params.t_rbuf=rbuf;
                params.dst=&rbuf->dst;
                params.send_buf.s=rbuf->buffer;
                params.send_buf.len=rbuf->buffer_len;
        }
-#endif
        
        run_trans_callbacks_internal(&dlg->dlg_callbacks, TMCB_DLG, trans, 
                                                                        &params);
index c1b52be..6ee8774 100644 (file)
@@ -326,14 +326,10 @@ int cancel_branch( struct cell *t, int branch,
        crb->buffer_len = len;
 
        DBG("DEBUG: cancel_branch: sending cancel...\n");
-#ifdef TMCB_ONSEND
        if (SEND_BUFFER( crb )>=0){
                if (unlikely (has_tran_tmcbs(t, TMCB_REQUEST_SENT)))
                        run_onsend_callbacks(TMCB_REQUEST_SENT, crb, 0, 0, TMCB_LOCAL_F);
        }
-#else
-       SEND_BUFFER( crb );
-#endif
        /*sets and starts the FINAL RESPONSE timer */
        if (start_retr( crb )!=0)
                LOG(L_CRIT, "BUG: cancel_branch: failed to start retransmission"
index 210601d..1fb9cf7 100644 (file)
@@ -1188,14 +1188,12 @@ void e2e_cancel( struct sip_msg *cancel_msg,
                                if (SEND_BUFFER(&t_cancel->uac[i].request) == -1) {
                                        LOG(L_ERR, "ERROR: e2e_cancel: send failed\n");
                                }
-#ifdef TMCB_ONSEND
                                else{
                                        if (unlikely(has_tran_tmcbs(t_cancel, TMCB_REQUEST_SENT)))
                                                run_onsend_callbacks(TMCB_REQUEST_SENT, 
                                                                                                &t_cancel->uac[i].request,
                                                                                                cancel_msg, 0, TMCB_LOCAL_F);
                                }
-#endif
                                if (start_retr( &t_cancel->uac[i].request )!=0)
                                        LOG(L_CRIT, "BUG: e2e_cancel: failed to start retr."
                                                        " 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 ,
                if (proxy) { proxy->errors++; proxy->ok=0; }
                return -2;
        } else {
-#ifdef TMCB_ONSEND
                if (unlikely(has_tran_tmcbs(t, TMCB_REQUEST_SENT)))
                        run_onsend_callbacks(TMCB_REQUEST_SENT, &uac->request, p_msg, 0,0);
-#endif
                /* start retr. only if the send succeeded */
                if (start_retr( &uac->request )!=0){
                        LOG(L_CRIT, "BUG: t_send_branch: retr. already started for %p\n",
index 8dc77b1..f996586 100644 (file)
@@ -319,7 +319,6 @@ void run_trans_callbacks( int type , struct cell *trans,
 
 
 
-#ifdef TMCB_ONSEND
 void run_onsend_callbacks(int type, struct retr_buf* rbuf,
                                        struct sip_msg* req, struct sip_msg* repl, short flags)
 {
@@ -347,7 +346,6 @@ void run_onsend_callbacks2(int type, struct cell* trans, struct tmcb_params* p)
        run_trans_callbacks_internal(&trans->tmcb_hl, type, p->t_rbuf->my_T, p);
 }
 
-#endif
 
 static void run_reqin_callbacks_internal(struct tmcb_head_list* hl,
                                                        struct cell *trans, struct tmcb_params* params)
index 38ba5d4..0432aa6 100644 (file)
 
 #include "defs.h"
 
-/* if defined support for ONSEND callbacks will be added and
- * the tmcb_params structure will get some additional members */
+/* TMCB_ONSEND used to enable certain callback-related features when
+ * ONSEND was set, these days it's always enabled. For compatibility
+ * reasons with modules that check ONSEND, continue to set it
+ * unconditionally*/
 #define TMCB_ONSEND
-#ifdef TMCB_ONSEND
 #include "../../ip_addr.h" /* dest_info */
-#endif
 
 struct sip_msg;
 struct cell;
@@ -78,13 +78,9 @@ struct cell;
 #ifdef WITH_AS_SUPPORT
 #define TMCB_DONT_ACK_N         19 /* TM shoudn't ACK a local UAC  */
 #endif
-#ifdef TMCB_ONSEND
 #define TMCB_REQUEST_SENT_N     20
 #define TMCB_RESPONSE_SENT_N    21
 #define TMCB_MAX_N              21
-#else
-#define TMCB_MAX_N              19
-#endif
 
 
 #define TMCB_REQUEST_IN       (1<<TMCB_REQUEST_IN_N)
@@ -109,10 +105,8 @@ struct cell;
 #ifdef WITH_AS_SUPPORT
 #define TMCB_DONT_ACK         (1<<TMCB_DONT_ACK_N)
 #endif
-#ifdef TMCB_ONSEND
 #define TMCB_REQUEST_SENT      (1<<TMCB_REQUEST_SENT_N)
 #define TMCB_RESPONSE_SENT     (1<<TMCB_RESPONSE_SENT_N)
-#endif
 #define TMCB_MAX              ((1<<(TMCB_MAX_N+1))-1)
 
 
@@ -294,17 +288,15 @@ struct cell;
  *  t_uac.
  *   For a reply the code is the response status (which is always >0, e.g. 200,
  *   408, a.s.o).
- *  Note: - these callbacks can be used only if TMCB_ONSEND is defined.
  *        - the callbacks will be called sometimes with the REPLY lock held
  *          and sometimes without it, so trying to acquire the REPLY lock
  *          from these callbacks could lead to deadlocks (avoid it unless
  *           you really know what you're doing).
  *
- *  TMCB_REQUEST_SENT (present only if TMCB_ONSEND is defined) -- called 
- *  each time a request was sent (even for retransmissions), it includes 
- *  local and forwarded request, ser generated CANCELs and ACKs. The 
- *  tmcb_params structure will have the t_rbuf, dst, send_buf and is_retr
- *  members  filled.
+ *  TMCB_REQUEST_SENT -- called each time a request was sent (even for
+ *  retransmissions), it includes *  local and forwarded request, ser generated
+ *  CANCELs and ACKs. The tmcb_params structure will have the t_rbuf, dst,
+ *  send_buf and is_retr members filled.
  *  This callback is "read-only", the message was already sent and no changes
  *  are allowed.
  *  Note: send_buf can be different from t_rbuf->buffer for ACKs (in this
@@ -312,11 +304,11 @@ struct cell;
  *   its destination). The same goes for t_rbuf->dst and tmcb->dst for local 
  *   transactions ACKs to 2xxs.
  *
- *  TMCB_RESPONSE_SENT  (present only if TMCB_ONSEND is defined) -- called 
- *  each time a response was sent (even for retransmissions). The tmcb_params
- *   structure will have t_rbuf set to the reply retransmission buffer and
- *   send_buf set to the data sent (in this case it will always be the same 
- *   with t_rbuf->buf). is_retr will also be set if the reply is retransmitted
+ *  TMCB_RESPONSE_SENT -- called each time a response was sent (even for
+ *  retransmissions). The tmcb_params structure will have t_rbuf set to the
+ *  reply retransmission buffer and send_buf set to the data sent (in this case
+ *  it will always be the same with t_rbuf->buf). is_retr will also be set if
+ *  the reply is retransmitted
  *   by ser.
  *  This callback is "read-only", the message was already sent and no changes
  *  are allowed.
@@ -343,10 +335,8 @@ struct cell;
        ).
 */
 
-#ifdef TMCB_ONSEND
 #define TMCB_RETR_F 1
 #define TMCB_LOCAL_F 2
-#endif
 
 /* pack structure with all params passed to callback function */
 struct tmcb_params {
@@ -354,7 +344,6 @@ struct tmcb_params {
        struct sip_msg* rpl;
        void **param;
        int code;
-#ifdef TMCB_ONSEND
        unsigned short flags; /* set to a combination of:
                                                         TMCB_RETR_F if this is a _ser_ retransmission
                                                         (but not if if it's a "forwarded" retr., like a 
@@ -370,7 +359,6 @@ struct tmcb_params {
        struct dest_info* dst; /* destination */
        str send_buf; /* what was/will be sent on the net, used for ACKs
                                        (which don't have a retr_buf). */
-#endif
 };
 
 #define INIT_TMCB_PARAMS(tmcb, request, reply, r_code)\
@@ -380,7 +368,6 @@ do{\
        (tmcb).code=(r_code); \
 }while(0)
 
-#ifdef TMCB_ONSEND
 #define INIT_TMCB_ONSEND_PARAMS(tmcb, req, repl, rbuf, dest, buf, buf_len, \
                                                                onsend_flags, t_branch, code) \
 do{ \
@@ -389,7 +376,6 @@ do{ \
        tmcb.send_buf.s=(buf); tmcb.send_buf.len=(buf_len); \
        tmcb.flags=(onsend_flags); tmcb.branch=(t_branch); \
 }while(0)
-#endif
 
 /* callback function prototype */
 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 );
 void run_local_reqin_callbacks( struct cell *trans, struct sip_msg *req, 
                int code );
 
-#ifdef TMCB_ONSEND
-
+/* TBD: explanation */
 void run_onsend_callbacks(int type, struct retr_buf* rbuf, struct sip_msg* req,
                                                                        struct sip_msg* repl, short flags);
 void run_onsend_callbacks2(int type, struct cell* t, struct tmcb_params* p);
-#endif
 
 #endif
index b7c3a84..b4ee307 100644 (file)
@@ -564,9 +564,7 @@ static int _reply_light( struct cell *trans, char* buf, unsigned int len,
        struct retr_buf *rb;
        unsigned int buf_len;
        struct cancel_info cancel_data;
-#ifdef TMCB_ONSEND
        struct tmcb_params onsend_params;
-#endif
 
        init_cancel_info(&cancel_data);
        if (!buf)
@@ -653,7 +651,6 @@ static int _reply_light( struct cell *trans, char* buf, unsigned int len,
                                                has_tran_tmcbs(trans, TMCB_RESPONSE_OUT)) )
                                run_trans_callbacks(TMCB_RESPONSE_OUT, trans,
                                                                        trans->uas.request, FAKED_REPLY, code);
-#ifdef TMCB_ONSEND
                        if (unlikely(has_tran_tmcbs(trans, TMCB_RESPONSE_SENT))){
                                INIT_TMCB_ONSEND_PARAMS(onsend_params, trans->uas.request,
                                                                FAKED_REPLY, rb, &rb->dst, 
@@ -661,7 +658,6 @@ static int _reply_light( struct cell *trans, char* buf, unsigned int len,
                                run_onsend_callbacks2(TMCB_RESPONSE_SENT, trans,
                                                                                &onsend_params);
                        }
-#endif /* TMCB_ONSEND */
                }
                DBG("DEBUG: reply sent out. buf=%p: %.20s..., shmem=%p: %.20s\n",
                        buf, buf, rb->buffer, rb->buffer );
@@ -1444,14 +1440,12 @@ int t_retransmit_reply( struct cell *t )
        memcpy( b, t->uas.response.buffer, len );
        UNLOCK_REPLIES( t );
        SEND_PR_BUFFER( & t->uas.response, b, len );
-#ifdef TMCB_ONSEND
        if (unlikely(has_tran_tmcbs(t, TMCB_RESPONSE_SENT))){ 
                /* we don't know if it's a retransmission of a local reply or a 
                 * forwarded reply */
                run_onsend_callbacks(TMCB_RESPONSE_SENT, &t->uas.response, 0, 0,
                                                                TMCB_RETR_F);
        }
-#endif
        DBG("DEBUG: reply retransmitted. buf=%p: %.9s..., shmem=%p: %.9s\n",
                b, b, t->uas.response.buffer, t->uas.response.buffer );
        return 1;
@@ -1635,9 +1629,7 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
        struct retr_buf *uas_rb;
        str* to_tag;
        str reason;
-#ifdef TMCB_ONSEND
        struct tmcb_params onsend_params;
-#endif
 
        /* keep compiler warnings about use of uninit vars silent */
        res_len=0;
@@ -1831,7 +1823,6 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
                                run_trans_callbacks( TMCB_RESPONSE_OUT, t, t->uas.request,
                                        relayed_msg, relayed_code);
                        }
-#ifdef TMCB_ONSEND
                        if (unlikely(has_tran_tmcbs(t, TMCB_RESPONSE_SENT))){
                                INIT_TMCB_ONSEND_PARAMS(onsend_params, t->uas.request,
                                                                        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,
                                                                        uas_rb->branch, relayed_code);
                                run_onsend_callbacks2(TMCB_RESPONSE_SENT, t, &onsend_params);
                        }
-#endif
                } else if (unlikely(uas_rb->dst.send_sock == 0))
                        ERR("no resolved dst to send reply to\n");
                /* Call put_on_wait() only if we really send out
@@ -2013,9 +2003,7 @@ int reply_received( struct sip_msg  *p_msg )
        int blst_503_timeout;
        struct hdr_field* hf;
 #endif
-#ifdef TMCB_ONSEND
        struct tmcb_params onsend_params;
-#endif
        struct run_act_ctx ctx;
 
        /* make sure we know the associated transaction ... */
@@ -2074,7 +2062,6 @@ int reply_received( struct sip_msg  *p_msg )
                        if (msg_status >= 300) {
                                ack = build_ack(p_msg, t, branch, &ack_len);
                                if (ack) {
-#ifdef TMCB_ONSEND
                                        if (SEND_PR_BUFFER(&uac->request, ack, ack_len)>=0)
                                                if (unlikely(has_tran_tmcbs(t, TMCB_REQUEST_SENT))){ 
                                                        INIT_TMCB_ONSEND_PARAMS(onsend_params, 
@@ -2084,9 +2071,6 @@ int reply_received( struct sip_msg  *p_msg )
                                                        run_onsend_callbacks2(TMCB_REQUEST_SENT, t,
                                                                                                        &onsend_params);
                                                }
-#else
-                                       SEND_PR_BUFFER(&uac->request, ack, ack_len);
-#endif
                                        shm_free(ack);
                                }
                        } else if (is_local(t) /*&& 200 <= msg_status < 300*/) {
@@ -2094,7 +2078,6 @@ int reply_received( struct sip_msg  *p_msg )
                                if (ack) {
                                        if (msg_send(&lack_dst, ack, ack_len)<0)
                                                LOG(L_ERR, "Error while sending local ACK\n");
-#ifdef TMCB_ONSEND
                                        else if (unlikely(has_tran_tmcbs(t, TMCB_REQUEST_SENT))){
                                                        INIT_TMCB_ONSEND_PARAMS(onsend_params, 
                                                                        t->uas.request, p_msg, &uac->request,
@@ -2103,7 +2086,6 @@ int reply_received( struct sip_msg  *p_msg )
                                                        run_onsend_callbacks2(TMCB_REQUEST_SENT, t,
                                                                                                        &onsend_params);
                                        }
-#endif
 #ifndef WITH_AS_SUPPORT
                                        shm_free(ack);
 #endif
@@ -2119,16 +2101,12 @@ int reply_received( struct sip_msg  *p_msg )
                                                                  local_cancel */
                                /* re-transmit if cancel already built */
                                DBG("tm: reply_received: branch CANCEL retransmit\n");
-#ifdef TMCB_ONSEND
                                if (SEND_BUFFER( &uac->local_cancel)>=0){
                                        if (unlikely (has_tran_tmcbs(t, TMCB_REQUEST_SENT)))
                                                run_onsend_callbacks(TMCB_REQUEST_SENT,
                                                                                        &uac->local_cancel,
                                                                                        0, 0, TMCB_LOCAL_F);
                                }
-#else
-                               SEND_BUFFER( &uac->local_cancel );
-#endif
                                /* retrs. should be already started so do nothing */
                        }else if (atomic_cmpxchg_long((void*)&uac->local_cancel.buffer, 0,
                                                                                (long)BUSY_BUFFER)==0){
index b834f11..0280ba3 100644 (file)
@@ -392,11 +392,9 @@ inline static ticks_t retransmission_handler( struct retr_buf *r_buf )
                                fake_reply(r_buf->my_T, r_buf->branch, 503 );
                                return (ticks_t)-1;
                        }
-#ifdef TMCB_ONSEND
                        if (unlikely(has_tran_tmcbs(r_buf->my_T, TMCB_REQUEST_SENT))) 
                                run_onsend_callbacks(TMCB_REQUEST_SENT, r_buf, 
                                                                                0, 0, TMCB_RETR_F);
-#endif
        } else {
 #ifdef EXTRA_DEBUG
                        DBG("DEBUG: retransmission_handler : "
index e6ba762..857c82f 100644 (file)
@@ -495,12 +495,10 @@ static inline void send_prepared_request_impl(struct retr_buf *request, int retr
        if (SEND_BUFFER(request) == -1) {
                LOG(L_ERR, "t_uac: Attempt to send to precreated request failed\n");
        }
-#ifdef TMCB_ONSEND
        else if (unlikely(has_tran_tmcbs(request->my_T, TMCB_REQUEST_SENT)))
                /* we don't know the method here */
                        run_onsend_callbacks(TMCB_REQUEST_SENT, request, 0, 0,
                                                                        TMCB_LOCAL_F);
-#endif
        
        if (retransmit && (start_retr(request)!=0))
                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)
 {
        struct retr_buf *local_ack, *old_lack;
        int ret;
-#ifdef TMCB_ONSEND
        struct tmcb_params onsend_params;
-#endif
 
        /* sanity checks */
 
@@ -661,7 +657,6 @@ int ack_local_uac(struct cell *trans, str *hdrs, str *body)
                ret = -1;
                goto fin;
        }
-#ifdef TMCB_ONSEND
        else {
                INIT_TMCB_ONSEND_PARAMS(onsend_params, 0, 0, &trans->uac[0].request,
                                                                &local_ack->dst,
@@ -669,7 +664,6 @@ int ack_local_uac(struct cell *trans, str *hdrs, str *body)
                                                                TMCB_LOCAL_F, 0 /* branch */, TYPE_LOCAL_ACK);
                run_onsend_callbacks2(TMCB_REQUEST_SENT, trans, &onsend_params);
        }
-#endif
 
        ret = 0;
 fin: