Skip to content

Commit

Permalink
presence: variable for last subscription uri made static and renamed
Browse files Browse the repository at this point in the history
- avoid eventual conflicts in the future because presence modules bind between
  each other
  • Loading branch information
miconda committed Mar 31, 2015
1 parent 08acf09 commit 47d506c
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions modules/presence/subscribe.c
Expand Up @@ -755,7 +755,7 @@ void msg_watchers_clean(unsigned int ticks,void *param)
LM_ERR("cleaning pending subscriptions\n");
}

char* last_presentity = NULL;
static char* _pres_subs_last_presentity = NULL;

int pv_parse_subscription_name(pv_spec_p sp, str *in)
{
Expand Down Expand Up @@ -787,7 +787,8 @@ int pv_parse_subscription_name(pv_spec_p sp, str *in)
int pv_get_subscription(struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
{
if(param->pvn.u.isname.name.n==1) /* presentity */
return last_presentity == NULL ? pv_get_null(msg, param, res) : pv_get_strzval(msg, param, res, last_presentity);
return (_pres_subs_last_presentity == NULL) ? pv_get_null(msg, param, res)
: pv_get_strzval(msg, param, res, _pres_subs_last_presentity);

LM_ERR("unknown specifier\n");
return pv_get_null(msg, param, res);
Expand Down Expand Up @@ -848,9 +849,9 @@ int handle_subscribe(struct sip_msg* msg, str watcher_user, str watcher_domain)
str reply_str;
int sent_reply= 0;

if(last_presentity) {
pkg_free(last_presentity);
last_presentity = NULL;
if(_pres_subs_last_presentity) {
pkg_free(_pres_subs_last_presentity);
_pres_subs_last_presentity = NULL;
}

/* ??? rename to avoid collisions with other symbols */
Expand Down Expand Up @@ -952,9 +953,10 @@ int handle_subscribe(struct sip_msg* msg, str watcher_user, str watcher_domain)
}

if(subs.pres_uri.len > 0 && subs.pres_uri.s) {
last_presentity= (char*)pkg_malloc((subs.pres_uri.len+1) * sizeof(char));
strncpy(last_presentity, subs.pres_uri.s, subs.pres_uri.len);
last_presentity[subs.pres_uri.len] = '\0';
_pres_subs_last_presentity =
(char*)pkg_malloc((subs.pres_uri.len+1) * sizeof(char));
strncpy(_pres_subs_last_presentity, subs.pres_uri.s, subs.pres_uri.len);
_pres_subs_last_presentity[subs.pres_uri.len] = '\0';
}

/* mark that the received event is a SUBSCRIBE message */
Expand Down

0 comments on commit 47d506c

Please sign in to comment.