[sr-dev] git:master:5f4f5102: presence: pass pointer to subs_t for pres_update_status()

Daniel-Constantin Mierla miconda at gmail.com
Mon Aug 14 09:12:16 CEST 2017


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

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2017-08-14T09:10:26+02:00

presence: pass pointer to subs_t for pres_update_status()

- passing content of a large structure may be inneficient at runtime

---

Modified: src/modules/presence/presence.c

---

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

---

diff --git a/src/modules/presence/presence.c b/src/modules/presence/presence.c
index ad4275f64d..2b2079cc69 100644
--- a/src/modules/presence/presence.c
+++ b/src/modules/presence/presence.c
@@ -687,7 +687,7 @@ int ki_pres_refresh_watchers_file(sip_msg_t *msg, str *pres, str *event,
 	return pres_refresh_watchers(pres, event, type, file_uri, filename);
 }
 
-int pres_update_status(subs_t subs, str reason, db_key_t* query_cols,
+int pres_update_status(subs_t *subs, str reason, db_key_t* query_cols,
 		db_val_t* query_vals, int n_query_cols, subs_t** subs_array)
 {
 	db_key_t update_cols[5];
@@ -715,29 +715,29 @@ int pres_update_status(subs_t subs, str reason, db_key_t* query_cols,
 	update_vals[u_reason_col].type= DB1_STR;
 	n_update_cols++;
 
-	status= subs.status;
-	if(subs.event->get_auth_status(&subs)< 0)
+	status= subs->status;
+	if(subs->event->get_auth_status(subs)< 0)
 	{
 		LM_ERR( "getting status from rules document\n");
 		return -1;
 	}
-	LM_DBG("subs.status= %d\n", subs.status);
-	if(get_status_str(subs.status)== NULL)
+	LM_DBG("subs.status= %d\n", subs->status);
+	if(get_status_str(subs->status)== NULL)
 	{
-		LM_ERR("wrong status: %d\n", subs.status);
+		LM_ERR("wrong status: %d\n", subs->status);
 		return -1;
 	}
 
-	if(subs.status!= status || reason.len!= subs.reason.len ||
-			(reason.s && subs.reason.s && strncmp(reason.s, subs.reason.s,
+	if(subs->status!= status || reason.len!= subs->reason.len ||
+			(reason.s && subs->reason.s && strncmp(reason.s, subs->reason.s,
 				reason.len)))
 	{
 		/* update in watchers_table */
-		query_vals[q_wuser_col].val.str_val= subs.watcher_user;
-		query_vals[q_wdomain_col].val.str_val= subs.watcher_domain;
+		query_vals[q_wuser_col].val.str_val= subs->watcher_user;
+		query_vals[q_wdomain_col].val.str_val= subs->watcher_domain;
 
-		update_vals[u_status_col].val.int_val= subs.status;
-		update_vals[u_reason_col].val.str_val= subs.reason;
+		update_vals[u_status_col].val.int_val= subs->status;
+		update_vals[u_reason_col].val.str_val= subs->reason;
 
 		if (pa_dbf.use_table(pa_db, &watchers_table) < 0)
 		{
@@ -753,12 +753,12 @@ int pres_update_status(subs_t subs, str reason, db_key_t* query_cols,
 		}
 		/* save in the list all affected dialogs */
 		/* if status switches to terminated -> delete dialog */
-		if(update_pw_dialogs(&subs, subs.db_flag, subs_array)< 0)
+		if(update_pw_dialogs(subs, subs->db_flag, subs_array)< 0)
 		{
 			LM_ERR( "extracting dialogs from [watcher]=%.*s@%.*s to"
-					" [presentity]=%.*s\n",	subs.watcher_user.len, subs.watcher_user.s,
-					subs.watcher_domain.len, subs.watcher_domain.s, subs.pres_uri.len,
-					subs.pres_uri.s);
+					" [presentity]=%.*s\n",	subs->watcher_user.len, subs->watcher_user.s,
+					subs->watcher_domain.len, subs->watcher_domain.s, subs->pres_uri.len,
+					subs->pres_uri.s);
 			return -1;
 		}
 	}
@@ -971,7 +971,7 @@ int update_watchers_status(str pres_uri, pres_ev_t* ev, str* rules_doc)
 			subs.status = ws_list[i].status;
 			memset(&subs.reason, 0, sizeof(str));
 
-			if( pres_update_status(subs, reason, query_cols, query_vals,
+			if( pres_update_status(&subs, reason, query_cols, query_vals,
 						n_query_cols, &subs_array)< 0)
 			{
 				LM_ERR("failed to update watcher status\n");
@@ -1014,7 +1014,7 @@ int update_watchers_status(str pres_uri, pres_ev_t* ev, str* rules_doc)
 		subs.status= status;
 		memset(&subs.reason, 0, sizeof(str));
 
-		if( pres_update_status(subs,reason, query_cols, query_vals,
+		if( pres_update_status(&subs,reason, query_cols, query_vals,
 					n_query_cols, &subs_array)< 0)
 		{
 			LM_ERR("failed to update watcher status\n");




More information about the sr-dev mailing list