Skip to content

Commit

Permalink
tsilo: unref the transaction after appending new branches
Browse files Browse the repository at this point in the history
(cherry picked from commit 3c086a8)
  • Loading branch information
grumvalski committed Oct 8, 2015
1 parent 42f3e1f commit 0aaa2dd
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions modules/tsilo/ts_append.c
Expand Up @@ -49,9 +49,9 @@ int ts_append(struct sip_msg* msg, str *ruri, char *table) {

if (res != 0) {
LM_ERR("failed to retrieve record for %.*s\n", ruri->len, ruri->s);
unlock_entry_by_ruri(ruri);
return -1;
}
unlock_entry_by_ruri(ruri);
return -1;
}

ptr = _r->transactions;

Expand All @@ -68,33 +68,50 @@ 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) {
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;

ret = _regapi.lookup_to_dset(orig_msg, table, NULL);
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;
}

0 comments on commit 0aaa2dd

Please sign in to comment.