Module: sip-router
Branch: kamailio_3.0
Commit: 3ed668500c9a0f0d2f864f5a56cf7fa886f8457c
URL:    
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=3ed668500c9a0f0d2f864f5a56cf7fa886f8457c

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date:   Wed Dec  2 19:01:09 2009 +0100

tm: drop replies behaviour based on cfg compat mode

- default behaviour for #!KAMAILIO is to drop replies after failure
  route to avoid selecting same reply during the next failure event
- for the rest of cases all replies are kept and used to select the
  code for new failure route (SER compat mode)
- t_drop_replies() can take one parameter
        - 'n[one]' - do not drop any reply (good for #!KAMAILIO mode)
        - 'l[ast]' - drop replies received during last serial forking step
        - 'a[ll]' - drop all replies

        - if the parameter is missing, then will drop all replies

---

 modules/tm/t_reply.c |   20 ++++++++++++++++----
 modules/tm/t_reply.h |    2 +-
 modules/tm/tm.c      |   11 ++++++++++-
 3 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/modules/tm/t_reply.c b/modules/tm/t_reply.c
index a250f63..1573e4d 100644
--- a/modules/tm/t_reply.c
+++ b/modules/tm/t_reply.c
@@ -138,6 +138,7 @@
 #include "t_lookup.h"
 #include "t_fwd.h"
 #include "../../fix_lumps.h"
+#include "../../sr_compat.h"
 #include "t_stats.h"
 #include "uac.h"
 
@@ -1124,7 +1125,10 @@ static enum rps t_should_relay_response( struct cell 
*Trans , int new_code,
                Trans->flags&=~T_6xx; /* clear the 6xx flag , we want to 
                                                                 allow new 
branches from the failure route */
 
-               drop_replies = 0;
+               if(sr_cfg_compat==SR_COMPAT_KAMAILIO)
+                       drop_replies = 1;
+               else
+                       drop_replies = 0;
                /* run ON_FAILURE handlers ( route and callbacks) */
                if (unlikely(has_tran_tmcbs( Trans, 
TMCB_ON_FAILURE_RO|TMCB_ON_FAILURE)
                                                || Trans->on_negative )) {
@@ -1137,7 +1141,15 @@ static enum rps t_should_relay_response( struct cell 
*Trans , int new_code,
                                                                        
picked_code, extra_flags);
                        if (unlikely(drop_replies)) {
                                /* drop all the replies that we have already 
saved */
-                               for (i=0; i<branch_cnt; i++) {
+                               i = 0;
+                               if(drop_replies==2)
+                               {
+                                       for(i=branch_cnt-1; i>=0; i--)
+                                               
if(Trans->uac[i].flags&TM_UAC_FLAG_FB)
+                                                       break;
+                                       if(i<0) i=0;
+                               }
+                               for (; i<branch_cnt; i++) {
                                        if (Trans->uac[i].reply &&
                                        (Trans->uac[i].reply != FAKED_REPLY) &&
                                        (Trans->uac[i].reply->msg_flags & 
FL_SHM_CLONE))
@@ -2237,14 +2249,14 @@ error:
 /* drops all the replies to make sure
  * that none of them is picked up again
  */
-void t_drop_replies(void)
+void t_drop_replies(int v)
 {
        /* It is too risky to free the replies that are in shm mem
        at the middle of failure_route block, because other functions might
        need them as well. And it can also happen that the current reply is not 
yet
        in shm mem, we are just going to clone it. So better to set a flag
        and check it after failure_route has ended. (Miklos) */
-       drop_replies = 1;
+       drop_replies = v;
 }
 
 #if 0
diff --git a/modules/tm/t_reply.h b/modules/tm/t_reply.h
index c385697..0a97e6a 100644
--- a/modules/tm/t_reply.h
+++ b/modules/tm/t_reply.h
@@ -153,7 +153,7 @@ int t_pick_branch_blind(struct cell *t, int *res_code);
 /* drops all the replies to make sure
  * that none of them is picked up again
  */
-void t_drop_replies(void);
+void t_drop_replies(int v);
 
 extern const char* rpc_reply_doc[2];
 void rpc_reply(rpc_t* rpc, void* c);
diff --git a/modules/tm/tm.c b/modules/tm/tm.c
index 09f08c6..51a31c0 100644
--- a/modules/tm/tm.c
+++ b/modules/tm/tm.c
@@ -381,6 +381,8 @@ static cmd_export_t cmds[]={
                        REQUEST_ROUTE|ONREPLY_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE 
},
        {"t_drop_replies",    w_t_drop_replies,         0, 0,
                        FAILURE_ROUTE},
+       {"t_drop_replies",    w_t_drop_replies,         1, 0,
+                       FAILURE_ROUTE},
        {"t_save_lumps",      w_t_save_lumps,           0, 0,
                        REQUEST_ROUTE},
        {"t_check_trans",       t_check_trans,                          0, 0,
@@ -1725,7 +1727,14 @@ int t_grep_status(struct sip_msg* msg, char* status, 
char* bar)
  * that none of them is picked up again */
 static int w_t_drop_replies(struct sip_msg* msg, char* foo, char* bar)
 {
-       t_drop_replies();
+       if(foo==NULL)
+               t_drop_replies(1);
+       else if(*foo=='n')
+               t_drop_replies(0);
+       else if(*foo=='l')
+               t_drop_replies(2);
+       else
+               t_drop_replies(1);
        return 1;
 }
 


_______________________________________________
sr-dev mailing list
[email protected]
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to