[sr-dev] git:master:f2ef2a90: presence: test if event is dialog for checking terminated state in presentity update

Daniel-Constantin Mierla miconda at gmail.com
Fri Sep 16 22:24:06 CEST 2016


Module: kamailio
Branch: master
Commit: f2ef2a9016f41e97d3466b34b4039e66505d53a1
URL: https://github.com/kamailio/kamailio/commit/f2ef2a9016f41e97d3466b34b4039e66505d53a1

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2016-09-16T22:22:57+02:00

presence: test if event is dialog for checking terminated state in presentity update

- reported by Juha Heinanen

---

Modified: modules/presence/presentity.c

---

Diff:  https://github.com/kamailio/kamailio/commit/f2ef2a9016f41e97d3466b34b4039e66505d53a1.diff
Patch: https://github.com/kamailio/kamailio/commit/f2ef2a9016f41e97d3466b34b4039e66505d53a1.patch

---

diff --git a/modules/presence/presentity.c b/modules/presence/presentity.c
index b78f84a..b5d7b65 100644
--- a/modules/presence/presentity.c
+++ b/modules/presence/presentity.c
@@ -494,7 +494,7 @@ int get_dialog_state(presentity_t* presentity, char** state)
 	}
 
 	if (pa_dbf.query (pa_db, query_cols, query_ops, query_vals,
-	 result_cols, n_query_cols, n_result_cols, 0, &result) < 0)
+				result_cols, n_query_cols, n_result_cols, 0, &result) < 0)
 	{
 		LM_ERR("unsuccessful sql query\n");
 		return -2;
@@ -515,7 +515,8 @@ int get_dialog_state(presentity_t* presentity, char** state)
 		tmp_db_body.s = (char*)row_vals[rez_body_col].val.string_val;
 		tmp_db_body.len = strlen(tmp_db_body.s);
 
-		parse_state_result = parse_dialog_state_from_body(tmp_db_body, &db_is_dialog, state);
+		parse_state_result = parse_dialog_state_from_body(tmp_db_body,
+				&db_is_dialog, state);
 
 		pa_dbf.free_result(pa_db, result);
 		result = NULL;
@@ -966,23 +967,25 @@ int update_presentity(struct sip_msg* msg, presentity_t* presentity, str* body,
 		else
 			cur_etag= presentity->etag;
 
-		if (is_dialog_terminated(presentity))
-		{
-			LM_WARN("Trying to update an already terminated state. Skipping update.\n");
-
-			/* send 200OK */
-			if (publ_send200ok(msg, presentity->expires, cur_etag)< 0)
+		if (presentity->event->evp->type==EVENT_DIALOG) {
+			if(is_dialog_terminated(presentity))
 			{
-				LM_ERR("sending 200OK reply\n");
-				goto error;
-			}
-			if (sent_reply) *sent_reply= 1;
+				LM_WARN("Trying to update an already terminated state."
+						" Skipping update.\n");
 
-			if(etag.s)
-				pkg_free(etag.s);
-			etag.s= NULL;
+				/* send 200OK */
+				if (publ_send200ok(msg, presentity->expires, cur_etag)< 0) {
+					LM_ERR("sending 200OK reply\n");
+					goto error;
+				}
+				if (sent_reply) *sent_reply= 1;
 
-			goto done;
+				if(etag.s)
+					pkg_free(etag.s);
+				etag.s= NULL;
+
+				goto done;
+			}
 		}
 
 		update_keys[n_update_cols] = &str_expires_col;




More information about the sr-dev mailing list