Use run_top_route where appropriate
authorJan Janak <jan@iptel.org>
Sun, 29 Mar 2009 16:05:24 +0000 (18:05 +0200)
committerJan Janak <jan@iptel.org>
Sun, 29 Mar 2009 16:05:24 +0000 (18:05 +0200)
This patch replaces the sequence of

  reset_static_buffer();
  init_run_actions_ctx();
  run_actions();

at the following places in the code:
 * execution of a branch route in tm
 * execution of a failure route in tm
 * execution of an onreply route in tm
 * execution of on_sl_reply in tm
 * execution of a route block after t_continue has been called
 * execution of the top-level route block in the core when a new SIP
   request arrives
 * execution of the top-level onreply route block in the core when a
   new SIP reply arrives

modules/tm/t_fwd.c
modules/tm/t_reply.c
modules/tm/t_suspend.c
receive.c

index 9e7249c..23ebd2e 100644 (file)
 #ifdef USE_DST_BLACKLIST
 #include "../../dst_blacklist.h"
 #endif
-#include "../../select_buf.h" /* reset_static_buffer() */
 #ifdef POSTPONE_MSG_CLONING
 #include "../../atomic_ops.h" /* membar_depends() */
 #endif
@@ -152,7 +151,6 @@ static char *print_uac_request( struct cell *t, struct sip_msg *i_req,
        struct sip_uri parsed_uri_bak;
        int parsed_uri_ok_bak, uri_backed_up;
        str msg_uri_bak;
-       struct run_act_ctx ra_ctx;
 
        shbuf=0;
        msg_uri_bak.s=0; /* kill warnings */
@@ -190,13 +188,12 @@ static char *print_uac_request( struct cell *t, struct sip_msg *i_req,
        i_req->body_lumps = dup_lump_list(i_req->body_lumps);
 
        if (unlikely(branch_route)) {
-               reset_static_buffer();
                     /* run branch_route actions if provided */
                set_route_type(BRANCH_ROUTE);
-               init_run_actions_ctx(&ra_ctx);
-               if (run_actions(&ra_ctx, branch_rt.rlist[branch_route], i_req) < 0) {
-                       LOG(L_ERR, "ERROR: print_uac_request: Error in run_actions\n");
-               }
+               
+               if (run_top_route(branch_rt.rlist[branch_route], i_req) < 0) {
+                       LOG(L_ERR, "ERROR: print_uac_request: Error in run_top_route\n");
+               }
        }
 
        /* run the specific callbacks for this transaction */
index 4e8a884..a8d1ec3 100644 (file)
 #include "../../usr_avp.h"
 #include "../../atomic_ops.h" /* membar_write() */
 #include "../../compiler_opt.h"
-#include "../../select_buf.h" /* reset_static_buffer() */
 #ifdef USE_DST_BLACKLIST
 #include "../../dst_blacklist.h"
 #endif
@@ -824,7 +823,6 @@ int run_failure_handlers(struct cell *t, struct sip_msg *rpl,
        static struct sip_msg faked_req;
        struct sip_msg *shmem_msg = t->uas.request;
        int on_failure;
-       struct run_act_ctx ra_ctx;
 
        /* failure_route for a local UAC? */
        if (!shmem_msg) {
@@ -859,11 +857,9 @@ int run_failure_handlers(struct cell *t, struct sip_msg *rpl,
                 * on failure */
                on_failure = t->on_negative;
                t->on_negative=0;
-               reset_static_buffer();
                /* run a reply_route action if some was marked */
-               init_run_actions_ctx(&ra_ctx);
-               if (run_actions(&ra_ctx, failure_rt.rlist[on_failure], &faked_req)<0)
-                       LOG(L_ERR, "ERROR: run_failure_handlers: Error in do_action\n");
+               if (run_top_route(failure_rt.rlist[on_failure], &faked_req)<0)
+                       LOG(L_ERR, "ERROR: run_failure_handlers: Error in run_top_route\n");
        }
 
        /* restore original environment and free the fake msg */
@@ -1818,7 +1814,6 @@ int reply_received( struct sip_msg  *p_msg )
        avp_list_t* backup_user_from, *backup_user_to;
        avp_list_t* backup_domain_from, *backup_domain_to;
        avp_list_t* backup_uri_from, *backup_uri_to;
-       struct run_act_ctx ra_ctx;
 #ifdef USE_DNS_FAILOVER
        int branch_ret;
        int prev_branch;
@@ -1962,9 +1957,7 @@ int reply_received( struct sip_msg  *p_msg )
                backup_user_to = set_avp_list(AVP_TRACK_TO | AVP_CLASS_USER, &t->user_avps_to );
                backup_domain_from = set_avp_list(AVP_TRACK_FROM | AVP_CLASS_DOMAIN, &t->domain_avps_from );
                backup_domain_to = set_avp_list(AVP_TRACK_TO | AVP_CLASS_DOMAIN, &t->domain_avps_to );
-               reset_static_buffer();
-               init_run_actions_ctx(&ra_ctx);
-               if (run_actions(&ra_ctx, onreply_rt.rlist[t->on_reply], p_msg)<0)
+               if (run_top_route(onreply_rt.rlist[t->on_reply], p_msg)<0)
                        LOG(L_ERR, "ERROR: on_reply processing failed\n");
                /* transfer current message context back to t */
                if (t->uas.request) t->uas.request->flags=p_msg->flags;
@@ -2090,8 +2083,7 @@ trans_not_found:
        if (goto_on_sl_reply) {
                /* the script writer has a chance to decide whether to
                forward the reply or not */
-               init_run_actions_ctx(&ra_ctx);
-               return run_actions(&ra_ctx, onreply_rt.rlist[goto_on_sl_reply], p_msg);
+               return run_top_route(onreply_rt.rlist[goto_on_sl_reply], p_msg);
        } else {
                /* let the core forward the reply */
                return 1;
index 9b418c1..4a31b80 100644 (file)
@@ -106,7 +106,6 @@ int t_continue(unsigned int hash_index, unsigned int label,
 {
        struct cell     *t;
        struct sip_msg  faked_req;
-       struct run_act_ctx      ra_ctx;
        int     branch;
 
        if (t_lookup_ident(&t, hash_index, label) < 0) {
@@ -148,9 +147,8 @@ int t_continue(unsigned int hash_index, unsigned int label,
        }
        faked_env( t, &faked_req);
 
-       init_run_actions_ctx(&ra_ctx);
-       if (run_actions(&ra_ctx, route, &faked_req)<0)
-               LOG(L_ERR, "ERROR: t_continue: Error in run_action\n");
+       if (run_top_route(route, &faked_req)<0)
+               LOG(L_ERR, "ERROR: t_continue: Error in run_top_route\n");
 
        /* TODO: save_msg_lumps should clone the lumps to shm mem */
 
index beb4c58..9941df7 100644 (file)
--- a/receive.c
+++ b/receive.c
@@ -85,7 +85,6 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info)
 {
        struct sip_msg* msg;
        int ret;
-       struct run_act_ctx ra_ctx;
 #ifdef STATS
        int skipped = 1;
        struct timeval tvb, tve;        
@@ -123,7 +122,6 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info)
 
        /* ... clear branches from previous message */
        clear_branches();
-       reset_static_buffer();
 
        if (msg->first_line.type==SIP_REQUEST){
                if (!IS_SIP(msg)){
@@ -171,8 +169,7 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info)
 
                set_route_type(REQUEST_ROUTE);
                /* exec the routing script */
-               init_run_actions_ctx(&ra_ctx);
-               if (run_actions(&ra_ctx, main_rt.rlist[DEFAULT_RT], msg)<0){
+               if (run_top_route(main_rt.rlist[DEFAULT_RT], msg)<0){
                        LOG(L_WARN, "WARNING: receive_msg: "
                                        "error while trying script\n");
                        goto error_req;
@@ -215,8 +212,7 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info)
                /* exec the onreply routing script */
                if (onreply_rt.rlist[DEFAULT_RT]){
                        set_route_type(ONREPLY_ROUTE);
-                       init_run_actions_ctx(&ra_ctx);
-                       ret=run_actions(&ra_ctx, onreply_rt.rlist[DEFAULT_RT], msg);
+                       ret=run_top_route(onreply_rt.rlist[DEFAULT_RT], msg);
                        if (ret<0){
                                LOG(L_WARN, "WARNING: receive_msg: "
                                                "error while trying onreply script\n");