Module: sip-router Branch: 3.1 Commit: cdee458b2ec4296cb847dd6e531285c0ac64dd80 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=cdee458b...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: Thu Apr 7 12:03:32 2011 +0200
rls(k): send 200ok for NOTIFY with subscription state termintated
- when rls module sends an un-SUBSCRIBE (expires=0), then the dialog structure is removed and the NOTIFY arriving later to confirm the termination of subscription does not find any record, resulting in no reply - the patch detects the subscribe-state terminated in NOTIFY requests and sends back 200ok - reported by Peter Dunkley
---
modules_k/rls/resource_notify.c | 36 +++++++++++++++++++++++------------- 1 files changed, 23 insertions(+), 13 deletions(-)
diff --git a/modules_k/rls/resource_notify.c b/modules_k/rls/resource_notify.c index d41f3ca..0caf7cb 100644 --- a/modules_k/rls/resource_notify.c +++ b/modules_k/rls/resource_notify.c @@ -240,16 +240,6 @@ int rls_handle_notify(struct sip_msg* msg, char* c1, char* c2) LM_ERR("unrecognized event package\n"); goto error; } - if(pua_get_record_id(&dialog, &res_id)< 0) // verify if within a stored dialog - { - LM_ERR("occured when trying to get record id\n"); - goto error; - } - if(res_id== 0) - { - LM_ERR("record not found\n"); - goto error; - }
/* extract the subscription state */ hdr = msg->headers; @@ -276,6 +266,24 @@ int rls_handle_notify(struct sip_msg* msg, char* c1, char* c2) LM_ERR("while parsing 'Subscription-State' header\n"); goto error; } + if(pua_get_record_id(&dialog, &res_id)< 0) // verify if within a stored dialog + { + LM_ERR("occured when trying to get record id\n"); + goto error; + } + if(res_id==0) + { + LM_DBG("presence dialog record not found\n"); + /* if it is a NOTIFY for a terminated SUBSCRIBE dialog in RLS, then + * the module might not have the dialog structure anymore + * - just send 200ok, it is harmless + */ + if(auth_flag==TERMINATED_STATE) + goto done; + LM_ERR("no presence dialog record for non-TERMINATED state\n"); + goto error; + } + if(msg->content_type== NULL || msg->content_type->body.s== NULL) { LM_DBG("cannot find content type header header\n"); @@ -408,9 +416,11 @@ done: goto error; }
- pkg_free(res_id->s); - pkg_free(res_id); - + if(res_id!=NULL) + { + pkg_free(res_id->s); + pkg_free(res_id); + } return 1;
error: