Module: sip-router
Branch: master
Commit: 02e845bf64f0151255ca54feb7f59a9b500dc1e0
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=02e845b…
Author: Timo Reimann <timo.reimann(a)1und1.de>
Committer: Timo Reimann <timo.reimann(a)1und1.de>
Date: Mon Sep 12 11:20:55 2011 +0200
modules_k/dialog: Do not log an ERROR level message when
attempting to delete a non-existing dialog variable, thereby
bringing dialog variable behavior more in line with AVP behavior.
Credits to Anca Vamanu (anca.vamanu(a)1and1.ro).
---
modules_k/dialog/dlg_var.c | 36 ++++++++++++++----------------------
1 files changed, 14 insertions(+), 22 deletions(-)
diff --git a/modules_k/dialog/dlg_var.c b/modules_k/dialog/dlg_var.c
index 3226bc4..310b674 100644
--- a/modules_k/dialog/dlg_var.c
+++ b/modules_k/dialog/dlg_var.c
@@ -150,10 +150,9 @@ int set_dlg_variable_unsafe(struct dlg_cell *dlg, str *key, str
*val)
}
/* not found: */
-
if (!var) {
- LM_ERR("dialog variable <%.*s> does not exist in variable list\n",
key->len, key->s);
- return -1;
+ LM_DBG("dialog variable <%.*s> does not exist in variable list\n",
key->len, key->s);
+ return 1;
}
/* insert a new one at the beginning of the list */
@@ -240,6 +239,7 @@ str * get_dlg_variable(struct dlg_cell *dlg, str *key)
int set_dlg_variable(struct dlg_cell *dlg, str *key, str *val)
{
+ int ret = -1;
if( !dlg || !key || key->len > strlen(key->s) || (val && val->len
> strlen(val->s)))
{
LM_ERR("BUG - bad parameters\n");
@@ -248,18 +248,9 @@ int set_dlg_variable(struct dlg_cell *dlg, str *key, str *val)
dlg_lock(d_table, &(d_table->entries[dlg->h_entry]));
- if( !val)
- {
- if (set_dlg_variable_unsafe(dlg, key, NULL)!=0) {
- LM_ERR("failed to delete dialog variable <%.*s>\n",
key->len,key->s);
- goto error;
- }
- } else {
- if (set_dlg_variable_unsafe(dlg, key, val)!=0) {
- LM_ERR("failed to store dialog values
<%.*s>\n",key->len,key->s);
- goto error;
- }
- }
+ ret = set_dlg_variable_unsafe(dlg, key, val);
+ if(ret!= 0)
+ goto done;
dlg->dflags &= DLG_FLAG_CHANGED_VARS;
dlg_unlock(d_table, &(d_table->entries[dlg->h_entry]));
@@ -270,9 +261,9 @@ int set_dlg_variable(struct dlg_cell *dlg, str *key, str *val)
return 0;
-error:
+done:
dlg_unlock(d_table, &(d_table->entries[dlg->h_entry]));
- return -1;
+ return ret;
}
int pv_get_dlg_variable(struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
@@ -313,6 +304,7 @@ int pv_get_dlg_variable(struct sip_msg *msg, pv_param_t *param,
pv_value_t *res)
int pv_set_dlg_variable(struct sip_msg* msg, pv_param_t *param, int op, pv_value_t *val)
{
struct dlg_cell *dlg;
+ int ret = -1;
/* Retrieve the current dialog */
dlg=get_current_dialog( msg);
@@ -332,11 +324,11 @@ int pv_set_dlg_variable(struct sip_msg* msg, pv_param_t *param, int
op, pv_value
if (val==NULL || val->flags&(PV_VAL_NONE|PV_VAL_NULL|PV_VAL_EMPTY)) {
/* if NULL, remove the value */
- if (set_dlg_variable_unsafe(dlg, ¶m->pvn.u.isname.name.s, NULL)!=0) {
- LM_ERR("failed to delete dialog variable <%.*s>\n",
param->pvn.u.isname.name.s.len,param->pvn.u.isname.name.s.s);
+ ret = set_dlg_variable_unsafe(dlg, ¶m->pvn.u.isname.name.s, NULL);
+ if(ret!= 0) {
/* unlock dialog */
if (dlg) dlg_unlock(d_table, &(d_table->entries[dlg->h_entry]));
- return -1;
+ return ret;
}
} else {
/* if value, must be string */
@@ -347,8 +339,8 @@ int pv_set_dlg_variable(struct sip_msg* msg, pv_param_t *param, int
op, pv_value
return -1;
}
- if (set_dlg_variable_unsafe(dlg, ¶m->pvn.u.isname.name.s,
&val->rs)!=0) {
- LM_ERR("failed to store dialog values
<%.*s>\n",param->pvn.u.isname.name.s.len,param->pvn.u.isname.name.s.s);
+ ret = set_dlg_variable_unsafe(dlg, ¶m->pvn.u.isname.name.s,
&val->rs);
+ if(ret!= 0) {
/* unlock dialog */
if (dlg) dlg_unlock(d_table, &(d_table->entries[dlg->h_entry]));
return -1;