소스 검색

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

Daniel-Constantin Mierla 5 년 전
부모
커밋
8077f387f9
1개의 변경된 파일27개의 추가작업 그리고 19개의 파일을 삭제
  1. 27 19
      src/modules/presence/presence.c

+ 27 - 19
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;
 			}