aboutsummaryrefslogtreecommitdiffstats
path: root/channels
diff options
context:
space:
mode:
authorschmitds <schmitds@f38db490-d61c-443f-a65b-d21fe96a405b>2010-10-01 09:42:22 +0000
committerschmitds <schmitds@f38db490-d61c-443f-a65b-d21fe96a405b>2010-10-01 09:42:22 +0000
commit001f39e727e6649cae32ddbeb0facfeb1d0308a5 (patch)
tree4c35056296245d526c3a1f46558a8d75ae275d0a /channels
parent4b071e1960d468fa9b66639395504b05c52980e4 (diff)
don't iterate through all dialogs to find and delete old subscribes
On every incoming subscribe there is a iteration through all dialogs to find old subscribes and delete them. This is slow and not RFC conform. This was only needed in 1.2 cause a subscribe was not deleted when a dialog was destroyed, after 1.4 a subscribe get removed when its dialog is destroyed. (closes issue #17950) Reported by: schmidts Tested by: schmidts Review: https://reviewboard.asterisk.org/r/901/ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@289622 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_sip.c32
1 files changed, 6 insertions, 26 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 1e52ca6cc..18db5ca5d 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -13970,6 +13970,10 @@ static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_
/* The other side has no transaction to cancel,
just assume it's all right then */
ast_log(LOG_WARNING, "Remote host can't match request %s to call '%s'. Giving up.\n", sip_methods[sipmethod].text, p->callid);
+ } else if (sipmethod == SIP_NOTIFY) {
+ /* The other side has no active Subscribe for this Callid.
+ * Remove this Dialog and old Subscription */
+ ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
} else {
ast_log(LOG_WARNING, "Remote host can't match request %s to call '%s'. Giving up.\n", sip_methods[sipmethod].text, p->callid);
/* Guessing that this is not an important request */
@@ -14166,6 +14170,8 @@ static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_
handle_response_invite(p, resp, rest, req, seqno);
} else if (sipmethod == SIP_BYE) {
ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
+ } else if (sipmethod == SIP_NOTIFY) {
+ ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
} else if (sipdebug) {
ast_log (LOG_DEBUG, "Remote host can't match request %s to call '%s'. Giving up\n", sip_methods[sipmethod].text, p->callid);
}
@@ -16656,7 +16662,6 @@ static int handle_request_subscribe(struct sip_pvt *p, struct sip_request *req,
ASTOBJ_UNLOCK(p->relatedpeer);
}
} else {
- struct sip_pvt *p_old;
if ((firststate = ast_extension_state(NULL, p->context, p->exten)) < 0) {
@@ -16672,31 +16677,6 @@ static int handle_request_subscribe(struct sip_pvt *p, struct sip_request *req,
/* hide the 'complete' exten/context in the refer_to field for later display */
ast_string_field_build(p, subscribeuri, "%s@%s", p->exten, p->context);
- /* remove any old subscription from this peer for the same exten/context,
- as the peer has obviously forgotten about it and it's wasteful to wait
- for it to expire and send NOTIFY messages to the peer only to have them
- ignored (or generate errors)
- */
- ast_mutex_lock(&iflock);
- for (p_old = iflist; p_old; p_old = p_old->next) {
- if (p_old == p)
- continue;
- if (p_old->initreq.method != SIP_SUBSCRIBE)
- continue;
- if (p_old->subscribed == NONE)
- continue;
- ast_mutex_lock(&p_old->lock);
- if (!strcmp(p_old->username, p->username)) {
- if (!strcmp(p_old->exten, p->exten) &&
- !strcmp(p_old->context, p->context)) {
- ast_set_flag(&p_old->flags[0], SIP_NEEDDESTROY);
- ast_mutex_unlock(&p_old->lock);
- break;
- }
- }
- ast_mutex_unlock(&p_old->lock);
- }
- ast_mutex_unlock(&iflock);
}
if (!p->expiry)
ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);