Module: sip-router
Branch: master
Commit: 5ccf1eedb4e38d85d7cd29ea5d69f29b40289755
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=5ccf1ee…
Author: Anca Vamanu <anca.vamanu(a)1and1.ro>
Committer: Anca Vamanu <anca.vamanu(a)1and1.ro>
Date: Thu Mar 15 18:38:43 2012 +0200
modules_k/presence Change delete sql query to use key
The delete operation in active_watchers is now performed on
callid, to_tag, from_tag.
---
modules_k/presence/notify.c | 22 ++++++++++++++++------
modules_k/presence/notify.h | 3 ++-
modules_k/presence/subscribe.c | 28 +++++++++++++++-------------
modules_k/presence/subscribe.h | 2 +-
4 files changed, 34 insertions(+), 21 deletions(-)
diff --git a/modules_k/presence/notify.c b/modules_k/presence/notify.c
index 52cb958..6ebf9fe 100644
--- a/modules_k/presence/notify.c
+++ b/modules_k/presence/notify.c
@@ -1591,9 +1591,9 @@ void p_tm_callback( struct cell *t, int type, struct tmcb_params
*ps)
c_back_param* cb;
if(ps->param==NULL || *ps->param==NULL ||
- ((c_back_param*)(*ps->param))->pres_uri.s == NULL ||
- ((c_back_param*)(*ps->param))->ev_name.s== NULL ||
- ((c_back_param*)(*ps->param))->to_tag.s== NULL)
+ ((c_back_param*)(*ps->param))->callid.s == NULL ||
+ ((c_back_param*)(*ps->param))->to_tag.s== NULL ||
+ ((c_back_param*)(*ps->param))->from_tag.s== NULL)
{
LM_DBG("message id not received, probably a timeout notify\n");
if(ps->param != NULL && *ps->param !=NULL)
@@ -1606,7 +1606,8 @@ void p_tm_callback( struct cell *t, int type, struct tmcb_params
*ps)
ps->code, cb->to_tag.len, cb->to_tag.s);
if(ps->code == 481 || (ps->code == 408 && timeout_rm_subs))
- delete_subs(&cb->pres_uri, &cb->ev_name, &cb->to_tag);
+ delete_subs(&cb->pres_uri, &cb->ev_name,
+ &cb->to_tag, &cb->from_tag, &cb->callid);
free_cbparam(cb);
}
@@ -1622,8 +1623,9 @@ c_back_param* shm_dup_cbparam(subs_t* subs)
int size;
c_back_param* cb_param = NULL;
- size = sizeof(c_back_param) + subs->pres_uri.len+
- subs->event->name.len + subs->to_tag.len;
+ size = sizeof(c_back_param) + subs->pres_uri.len +
+ subs->event->name.len + subs->to_tag.len +
+ subs->from_tag.len + subs->callid.len;
cb_param= (c_back_param*)shm_malloc(size);
LM_DBG("=== %d/%d/%d\n", subs->pres_uri.len,
@@ -1645,6 +1647,14 @@ c_back_param* shm_dup_cbparam(subs_t* subs)
memcpy(cb_param->to_tag.s, subs->to_tag.s, subs->to_tag.len);
cb_param->to_tag.len = subs->to_tag.len;
+ cb_param->from_tag.s = (char*)(cb_param->to_tag.s) + cb_param->to_tag.len;
+ memcpy(cb_param->from_tag.s, subs->from_tag.s, subs->from_tag.len);
+ cb_param->from_tag.len = subs->from_tag.len;
+
+ cb_param->callid.s = (char*)(cb_param->from_tag.s) + cb_param->from_tag.len;
+ memcpy(cb_param->callid.s, subs->callid.s, subs->callid.len);
+ cb_param->callid.len = subs->callid.len;
+
return cb_param;
}
diff --git a/modules_k/presence/notify.h b/modules_k/presence/notify.h
index 9a03f56..8af54a0 100644
--- a/modules_k/presence/notify.h
+++ b/modules_k/presence/notify.h
@@ -65,7 +65,8 @@ typedef struct wid_cback
str pres_uri;
str ev_name;
str to_tag; /* to identify the exact record */
- subs_t* wi_subs;
+ str from_tag;
+ str callid;
}c_back_param;
extern str str_to_user_col;
diff --git a/modules_k/presence/subscribe.c b/modules_k/presence/subscribe.c
index 7e45a9b..0c914c7 100644
--- a/modules_k/presence/subscribe.c
+++ b/modules_k/presence/subscribe.c
@@ -138,30 +138,30 @@ error:
}
-int delete_db_subs(str* pres_uri, str* ev_stored_name, str* to_tag)
+int delete_db_subs(str* to_tag, str* from_tag, str* callid)
{
- db_key_t query_cols[5];
- db_val_t query_vals[5];
+ db_key_t query_cols[3];
+ db_val_t query_vals[3];
int n_query_cols= 0;
- query_cols[n_query_cols] = &str_presentity_uri_col;
+ query_cols[n_query_cols] = &str_callid_col;
query_vals[n_query_cols].type = DB1_STR;
query_vals[n_query_cols].nul = 0;
- query_vals[n_query_cols].val.str_val = *pres_uri;
+ query_vals[n_query_cols].val.str_val = *callid;
n_query_cols++;
- query_cols[n_query_cols] = &str_event_col;
+ query_cols[n_query_cols] = &str_to_tag_col;
query_vals[n_query_cols].type = DB1_STR;
query_vals[n_query_cols].nul = 0;
- query_vals[n_query_cols].val.str_val = *ev_stored_name;
+ query_vals[n_query_cols].val.str_val = *to_tag;
n_query_cols++;
- query_cols[n_query_cols] = &str_to_tag_col;
+ query_cols[n_query_cols] = &str_from_tag_col;
query_vals[n_query_cols].type = DB1_STR;
query_vals[n_query_cols].nul = 0;
- query_vals[n_query_cols].val.str_val = *to_tag;
+ query_vals[n_query_cols].val.str_val = *from_tag;
n_query_cols++;
-
+
if (pa_dbf.use_table(pa_db, &active_watchers_table) < 0)
{
LM_ERR("in use table sql operation\n");
@@ -405,7 +405,8 @@ int update_subs_db(subs_t* subs, int type)
return 0;
}
-void delete_subs(str* pres_uri, str* ev_name, str* to_tag)
+void delete_subs(str* pres_uri, str* ev_name, str* to_tag,
+ str* from_tag, str* callid)
{
/* delete record from hash table also if not in dbonly mode */
if(subs_dbmode != DB_ONLY)
@@ -415,7 +416,7 @@ void delete_subs(str* pres_uri, str* ev_name, str* to_tag)
LM_ERR("Failed to delete subscription from memory\n");
}
- if(subs_dbmode != NO_DB && delete_db_subs(pres_uri, ev_name, to_tag)< 0)
+ if(subs_dbmode != NO_DB && delete_db_subs(to_tag, from_tag, callid)< 0)
LM_ERR("Failed to delete subscription from database\n");
}
@@ -436,7 +437,8 @@ int update_subscription(struct sip_msg* msg, subs_t* subs, int
to_tag_gen,
{
LM_DBG("expires =0 -> deleting record\n");
- delete_subs(&subs->pres_uri, &subs->event->name,
&subs->to_tag);
+ delete_subs(&subs->pres_uri, &subs->event->name,
&subs->to_tag,
+ &subs->from_tag, &subs->callid);
if(subs->event->type & PUBL_TYPE)
{
diff --git a/modules_k/presence/subscribe.h b/modules_k/presence/subscribe.h
index bf7d189..8ba3893 100644
--- a/modules_k/presence/subscribe.h
+++ b/modules_k/presence/subscribe.h
@@ -116,6 +116,6 @@ int extract_sdialog_info(subs_t* subs,struct sip_msg* msg, int
max_expire,
int* to_tag_gen, str scontact);
typedef int (*extract_sdialog_info_t)(subs_t* subs, struct sip_msg* msg,
int max_expire, int* to_tag_gen, str scontact);
-void delete_subs(str* pres_uri, str* ev_name, str* to_tag);
+void delete_subs(str* pres_uri, str* ev_name, str* to_tag, str* from_tag, str* callid);
#endif