|
@@ -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) {
|
|
int ts_append_to(struct sip_msg* msg, int tindex, int tlabel, char *table, str *uri) {
|
|
struct cell *t;
|
|
struct cell *t;
|
|
|
|
+ struct cell *orig_t;
|
|
struct sip_msg *orig_msg;
|
|
struct sip_msg *orig_msg;
|
|
int ret;
|
|
int ret;
|
|
|
|
|
|
|
|
+ orig_t = _tmb.t_gett();
|
|
|
|
+
|
|
if(_tmb.t_lookup_ident(&t, tindex, tlabel) < 0)
|
|
if(_tmb.t_lookup_ident(&t, tindex, tlabel) < 0)
|
|
{
|
|
{
|
|
LM_ERR("transaction [%u:%u] not found\n",
|
|
LM_ERR("transaction [%u:%u] not found\n",
|
|
tindex, tlabel);
|
|
tindex, tlabel);
|
|
- return -1;
|
|
|
|
|
|
+ ret = -1;
|
|
|
|
+ goto done;
|
|
}
|
|
}
|
|
|
|
+
|
|
if (t->flags & T_CANCELED) {
|
|
if (t->flags & T_CANCELED) {
|
|
LM_DBG("trasaction [%u:%u] was cancelled\n",
|
|
LM_DBG("trasaction [%u:%u] was cancelled\n",
|
|
tindex, tlabel);
|
|
tindex, tlabel);
|
|
- return -2;
|
|
|
|
|
|
+ ret = -2;
|
|
|
|
+ goto done;
|
|
}
|
|
}
|
|
|
|
+
|
|
if (t->uas.status >= 200) {
|
|
if (t->uas.status >= 200) {
|
|
LM_DBG("trasaction [%u:%u] sent out a final response already - %d\n",
|
|
LM_DBG("trasaction [%u:%u] sent out a final response already - %d\n",
|
|
tindex, tlabel, t->uas.status);
|
|
tindex, tlabel, t->uas.status);
|
|
- return -3;
|
|
|
|
|
|
+ ret = -3;
|
|
|
|
+ goto done;
|
|
}
|
|
}
|
|
|
|
|
|
orig_msg = t->uas.request;
|
|
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 {
|
|
} else {
|
|
ret = _regapi.lookup_to_dset(orig_msg, table, uri);
|
|
ret = _regapi.lookup_to_dset(orig_msg, table, uri);
|
|
}
|
|
}
|
|
|
|
+
|
|
if(ret != 1) {
|
|
if(ret != 1) {
|
|
LM_DBG("transaction %u:%u: error updating dset (%d)\n", tindex, tlabel, ret);
|
|
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;
|
|
}
|
|
}
|