Browse code

modules_k/rls FIX call child_init also for main process

- call child_init also for main process, it has to be able to do the
flush to DB at shutdown
- updated to the last changes in the presence interface

Anca Vamanu authored on 15/02/2012 11:59:19
Showing 2 changed files
... ...
@@ -115,7 +115,7 @@ extern subs_t* rls_search_shtable(shtable_t htable,str callid,str to_tag,
115 115
 extern int rls_delete_shtable(shtable_t htable,unsigned int hash_code,str to_tag);
116 116
 extern int rls_update_shtable(shtable_t htable,unsigned int hash_code, 
117 117
 		subs_t* subs, int type);
118
-extern void rls_update_db_subs(db1_con_t *db,db_func_t dbf, shtable_t hash_table,
118
+extern void rls_update_db_subs_timer(db1_con_t *db,db_func_t dbf, shtable_t hash_table,
119 119
 	int htable_size, int no_lock, handle_expired_func_t handle_expired_func);
120 120
 
121 121
 new_shtable_t pres_new_shtable;
... ...
@@ -125,7 +125,7 @@ update_shtable_t pres_update_shtable;
125 125
 delete_shtable_t pres_delete_shtable;
126 126
 destroy_shtable_t pres_destroy_shtable;
127 127
 mem_copy_subs_t  pres_copy_subs;
128
-update_db_subs_t pres_update_db_subs;
128
+update_db_subs_t pres_update_db_subs_timer;
129 129
 extract_sdialog_info_t pres_extract_sdialog_info;
130 130
 int rls_events= EVENT_PRESENCE;
131 131
 int to_presence_code = 1;
... ...
@@ -358,23 +358,23 @@ static int mod_init(void)
358 358
 
359 359
 	if (dbmode == RLS_DB_ONLY)
360 360
 	{
361
-		pres_new_shtable    = rls_new_shtable;
362
-		pres_destroy_shtable= rls_destroy_shtable;
363
-		pres_insert_shtable = rls_insert_shtable;
364
-		pres_delete_shtable = rls_delete_shtable;
365
-		pres_update_shtable = rls_update_shtable;
366
-		pres_search_shtable = rls_search_shtable;
367
-		pres_update_db_subs = rls_update_db_subs;
361
+		pres_new_shtable          = rls_new_shtable;
362
+		pres_destroy_shtable      = rls_destroy_shtable;
363
+		pres_insert_shtable       = rls_insert_shtable;
364
+		pres_delete_shtable       = rls_delete_shtable;
365
+		pres_update_shtable       = rls_update_shtable;
366
+		pres_search_shtable       = rls_search_shtable;
367
+		pres_update_db_subs_timer = rls_update_db_subs_timer;
368 368
 	}
369 369
 	else
370 370
 	{
371
-		pres_new_shtable    = pres.new_shtable;
372
-		pres_destroy_shtable= pres.destroy_shtable;
373
-		pres_insert_shtable = pres.insert_shtable;
374
-		pres_delete_shtable = pres.delete_shtable;
375
-		pres_update_shtable = pres.update_shtable;
376
-		pres_search_shtable = pres.search_shtable;
377
-		pres_update_db_subs = pres.update_db_subs;
371
+		pres_new_shtable          = pres.new_shtable;
372
+		pres_destroy_shtable      = pres.destroy_shtable;
373
+		pres_insert_shtable       = pres.insert_shtable;
374
+		pres_delete_shtable       = pres.delete_shtable;
375
+		pres_update_shtable       = pres.update_shtable;
376
+		pres_search_shtable       = pres.search_shtable;
377
+		pres_update_db_subs_timer = pres.update_db_subs_timer;
378 378
 	}
379 379
 
380 380
 	pres_copy_subs      = pres.mem_copy_subs;
... ...
@@ -635,8 +635,8 @@ static int mod_init(void)
635 635
  */
636 636
 static int child_init(int rank)
637 637
 {
638
-	if (rank==PROC_INIT || rank==PROC_MAIN || rank==PROC_TCP_MAIN)
639
-		return 0; /* do nothing for the main process */
638
+	if (rank==PROC_INIT || rank==PROC_TCP_MAIN)
639
+		return 0; /* don't call child_init for main process more than once */
640 640
 
641 641
 	LM_DBG("child [%d]  pid [%d]\n", rank, getpid());
642 642
 
... ...
@@ -771,7 +771,7 @@ void rlsubs_table_update(unsigned int ticks,void *param)
771 771
 		LM_ERR("sql use table failed\n");
772 772
 		return;
773 773
 	}
774
-	pres_update_db_subs(rls_db, rls_dbf, rls_table, hash_size, 
774
+	pres_update_db_subs_timer(rls_db, rls_dbf, rls_table, hash_size, 
775 775
 			no_lock, handle_expired_record);
776 776
 
777 777
 }
... ...
@@ -103,10 +103,10 @@ int rls_update_shtable(shtable_t htable,unsigned int hash_code,
103 103
 
104 104
 /******************************************************************************/
105 105
 
106
-void rls_update_db_subs(db1_con_t *db,db_func_t dbf, shtable_t hash_table,
106
+void rls_update_db_subs_timer(db1_con_t *db,db_func_t dbf, shtable_t hash_table,
107 107
 	int htable_size, int no_lock, handle_expired_func_t handle_expired_func)
108 108
 {
109
-  LM_ERR( "rls_update_db_subs shouldn't be called in RLS_DB_ONLY mode\n" );
109
+  LM_ERR( "rls_update_db_subs_timer shouldn't be called in RLS_DB_ONLY mode\n" );
110 110
 }
111 111
 
112 112
 /******************************************************************************/