[sr-dev] git:master:8077f387: presence: init pres and subs hash tables for non db-only mode and memory index

Daniel-Constantin Mierla miconda at gmail.com
Wed Apr 22 08:44:01 CEST 2020


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

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2020-04-21T22:42:12+02:00

presence: init pres and subs hash tables for non db-only mode and memory index

---

Modified: src/modules/presence/presence.c

---

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

---

diff --git a/src/modules/presence/presence.c b/src/modules/presence/presence.c
index cbbc23feb3..7120dd7951 100644
--- a/src/modules/presence/presence.c
+++ b/src/modules/presence/presence.c
@@ -350,10 +350,11 @@ static int mod_init(void)
 	}
 
 	if(publ_cache_mode==PS_PCACHE_HYBRID || publ_cache_mode==PS_PCACHE_RECORD) {
-		if(phtable_size < 1)
+		if(phtable_size < 1) {
 			phtable_size = 256;
-		else
+		} else {
 			phtable_size = 1 << phtable_size;
+		}
 	}
 
 	if(publ_cache_mode==PS_PCACHE_RECORD) {
@@ -362,6 +363,28 @@ static int mod_init(void)
 		}
 	}
 
+	if(pres_subs_dbmode != DB_ONLY) {
+		if(shtable_size < 1) {
+			shtable_size = 512;
+		} else {
+			shtable_size = 1 << shtable_size;
+		}
+
+		subs_htable = new_shtable(shtable_size);
+		if(subs_htable == NULL) {
+			LM_ERR(" initializing subscribe hash table\n");
+			goto dberror;
+		}
+	}
+
+	if(publ_cache_mode==PS_PCACHE_HYBRID) {
+		pres_htable = new_phtable();
+		if(pres_htable == NULL) {
+			LM_ERR("initializing presentity hash table\n");
+			goto dberror;
+		}
+	}
+
 	if(publ_cache_mode != PS_PCACHE_RECORD || pres_subs_dbmode != NO_DB) {
 		if(pres_db_url.s == NULL) {
 			LM_ERR("database url not set!\n");
@@ -405,17 +428,8 @@ static int mod_init(void)
 			goto dberror;
 		}
 
+
 		if(pres_subs_dbmode != DB_ONLY) {
-			if(shtable_size < 1)
-				shtable_size = 512;
-			else
-				shtable_size = 1 << shtable_size;
-
-			subs_htable = new_shtable(shtable_size);
-			if(subs_htable == NULL) {
-				LM_ERR(" initializing subscribe hash table\n");
-				goto dberror;
-			}
 			if(restore_db_subs() < 0) {
 				LM_ERR("restoring subscribe info from database\n");
 				goto dberror;
@@ -423,13 +437,7 @@ static int mod_init(void)
 		}
 
 		if(publ_cache_mode==PS_PCACHE_HYBRID) {
-			pres_htable = new_phtable();
-			if(pres_htable == NULL) {
-				LM_ERR("initializing presentity hash table\n");
-				goto dberror;
-			}
-
-			if(pres_htable_restore() < 0) {
+			if(pres_htable_db_restore() < 0) {
 				LM_ERR("filling in presentity hash table from database\n");
 				goto dberror;
 			}




More information about the sr-dev mailing list