Browse code

presence: fixes related to f2db mode

- reported by Juha Heinanen

Daniel-Constantin Mierla authored on 19/05/2009 06:24:11
Showing 2 changed files
... ...
@@ -261,7 +261,10 @@ int insert_shtable(shtable_t htable,unsigned int hash_code, subs_t* subs)
261 261
 	}
262 262
 
263 263
 	new_rec->expires+= (int)time(NULL);
264
-	new_rec->db_flag= INSERTDB_FLAG;
264
+	if(fallback2db==0)
265
+		new_rec->db_flag= INSERTDB_FLAG;
266
+	else
267
+		new_rec->db_flag= NO_UPDATEDB_FLAG;
265 268
 
266 269
 	lock_get(&htable[hash_code].lock);
267 270
 	
... ...
@@ -362,18 +362,18 @@ int update_subscription(struct sip_msg* msg, subs_t* subs, int to_tag_gen,
362 362
 
363 363
 		if(update_shtable(subs_htable, hash_code, subs, REMOTE_TYPE)< 0)
364 364
 		{
365
-			if(fallback2db)
365
+			if(fallback2db==0)
366 366
 			{
367
-				/* update in database table */
368
-				if(update_subs_db(subs, REMOTE_TYPE)< 0)
369
-				{
370
-					LM_ERR("updating subscription in database table\n");
371
-					goto error;
372
-				}
367
+				LM_ERR("updating subscription record in hash table\n");
368
+				goto error;
373 369
 			}
374
-			else
370
+		}
371
+		if(fallback2db!=0)
372
+		{
373
+			/* update in database table */
374
+			if(update_subs_db(subs, REMOTE_TYPE)< 0)
375 375
 			{
376
-				LM_ERR("updating subscription record in hash table\n");
376
+				LM_ERR("updating subscription in database table\n");
377 377
 				goto error;
378 378
 			}
379 379
 		}
... ...
@@ -1509,7 +1509,7 @@ void update_db_subs(db1_con_t *db,db_func_t dbf, shtable_t hash_table,
1509 1509
 		while(s)
1510 1510
 		{
1511 1511
 			printf_subs(s);
1512
-			if(s->expires < (int)time(NULL)- 50)	
1512
+			if(s->expires < (int)time(NULL)- expires_offset)	
1513 1513
 			{
1514 1514
 				LM_DBG("Found expired record\n");
1515 1515
 				if(!no_lock)
... ...
@@ -1834,7 +1834,7 @@ int restore_db_subs(void)
1834 1834
 	pa_dbf.free_result(pa_db, result);
1835 1835
 
1836 1836
 	/* delete all records */
1837
-	if(pa_dbf.delete(pa_db, 0,0,0,0)< 0)
1837
+	if(fallback2db==0 && pa_dbf.delete(pa_db, 0,0,0,0)< 0)
1838 1838
 	{
1839 1839
 		LM_ERR("deleting all records from database table\n");
1840 1840
 		return -1;