[sr-dev] git:master: rls(k): send 200ok for NOTIFY with subscription state termintated

Daniel-Constantin Mierla miconda at gmail.com
Thu Apr 7 12:08:21 CEST 2011


Module: sip-router
Branch: master
Commit: d93dc272bdc9a7a8b74a57712965b3ef5b562060
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=d93dc272bdc9a7a8b74a57712965b3ef5b562060

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at 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
(cherry picked from commit cdee458b2ec4296cb847dd6e531285c0ac64dd80)

---

 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:




More information about the sr-dev mailing list