Module: kamailio
Branch: master
Commit: 3c086a85b99d59dabc48f77893d4c68199af0577
URL: 
https://github.com/kamailio/kamailio/commit/3c086a85b99d59dabc48f77893d4c68199af0577

Author: Federico Cabiddu <[email protected]>
Committer: Federico Cabiddu <[email protected]>
Date: 2015-10-07T09:29:39+02:00

tsilo: unref the transaction after appending new branches

---

Modified: modules/tsilo/ts_append.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/3c086a85b99d59dabc48f77893d4c68199af0577.diff
Patch: 
https://github.com/kamailio/kamailio/commit/3c086a85b99d59dabc48f77893d4c68199af0577.patch

---

diff --git a/modules/tsilo/ts_append.c b/modules/tsilo/ts_append.c
index 1079632..4e8f172 100644
--- a/modules/tsilo/ts_append.c
+++ b/modules/tsilo/ts_append.c
@@ -72,24 +72,32 @@ int ts_append(struct sip_msg* msg, str *ruri, char *table) {
 
 int ts_append_to(struct sip_msg* msg, int tindex, int tlabel, char *table, str 
*uri) {
        struct cell     *t;
+       struct cell     *orig_t;
        struct sip_msg *orig_msg;
        int ret;
 
+       orig_t = _tmb.t_gett();
+
        if(_tmb.t_lookup_ident(&t, tindex, tlabel) < 0)
        {
                LM_ERR("transaction [%u:%u] not found\n",
                                tindex, tlabel);
-               return -1;
+               ret = -1;
+               goto done;
        }
+
        if (t->flags & T_CANCELED) {
                LM_DBG("trasaction [%u:%u] was cancelled\n",
                                tindex, tlabel);
-               return -2;
+               ret = -2;
+               goto done;
        }
+
        if (t->uas.status >= 200) {
                LM_DBG("trasaction [%u:%u] sent out a final response already - 
%d\n",
                                tindex, tlabel, t->uas.status);
-               return -3;
+               ret = -3;
+               goto done;
        }
 
        orig_msg = t->uas.request;
@@ -99,10 +107,20 @@ int ts_append_to(struct sip_msg* msg, int tindex, int 
tlabel, char *table, str *
        } else {
                ret = _regapi.lookup_to_dset(orig_msg, table, uri);
        }
+
        if(ret != 1) {
                LM_DBG("transaction %u:%u: error updating dset (%d)\n", tindex, 
tlabel, ret);
-               return -4;
+               ret = -4;
+               goto done;
        }
-
-       return _tmb.t_append_branches();
+       
+       ret = _tmb.t_append_branches();
+
+done:
+       /* unref the transaction which had been referred by t_lookup_ident() 
call. 
+        * Restore the original transaction (if any) */
+       _tmb.unref_cell(t);
+       _tmb.t_sett(orig_t, T_BR_UNDEFINED);
+       
+       return ret;
 }


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

Reply via email to