Module: sip-router
Branch: master
Commit: 3a0e8503d3abd1bb320e76b694280efd7a8d3db6
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=3a0e850…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Tue May 19 09:24:11 2009 +0300
presence: fixes related to f2db mode
- reported by Juha Heinanen
---
modules_k/presence/hash.c | 5 ++++-
modules_k/presence/subscribe.c | 22 +++++++++++-----------
2 files changed, 15 insertions(+), 12 deletions(-)
diff --git a/modules_k/presence/hash.c b/modules_k/presence/hash.c
index 11e5fc9..874fe03 100644
--- a/modules_k/presence/hash.c
+++ b/modules_k/presence/hash.c
@@ -261,7 +261,10 @@ int insert_shtable(shtable_t htable,unsigned int hash_code, subs_t*
subs)
}
new_rec->expires+= (int)time(NULL);
- new_rec->db_flag= INSERTDB_FLAG;
+ if(fallback2db==0)
+ new_rec->db_flag= INSERTDB_FLAG;
+ else
+ new_rec->db_flag= NO_UPDATEDB_FLAG;
lock_get(&htable[hash_code].lock);
diff --git a/modules_k/presence/subscribe.c b/modules_k/presence/subscribe.c
index cfec2c8..f05300a 100644
--- a/modules_k/presence/subscribe.c
+++ b/modules_k/presence/subscribe.c
@@ -362,18 +362,18 @@ int update_subscription(struct sip_msg* msg, subs_t* subs, int
to_tag_gen,
if(update_shtable(subs_htable, hash_code, subs, REMOTE_TYPE)< 0)
{
- if(fallback2db)
+ if(fallback2db==0)
{
- /* update in database table */
- if(update_subs_db(subs, REMOTE_TYPE)< 0)
- {
- LM_ERR("updating subscription in database table\n");
- goto error;
- }
+ LM_ERR("updating subscription record in hash table\n");
+ goto error;
}
- else
+ }
+ if(fallback2db!=0)
+ {
+ /* update in database table */
+ if(update_subs_db(subs, REMOTE_TYPE)< 0)
{
- LM_ERR("updating subscription record in hash table\n");
+ LM_ERR("updating subscription in database table\n");
goto error;
}
}
@@ -1509,7 +1509,7 @@ void update_db_subs(db1_con_t *db,db_func_t dbf, shtable_t
hash_table,
while(s)
{
printf_subs(s);
- if(s->expires < (int)time(NULL)- 50)
+ if(s->expires < (int)time(NULL)- expires_offset)
{
LM_DBG("Found expired record\n");
if(!no_lock)
@@ -1834,7 +1834,7 @@ int restore_db_subs(void)
pa_dbf.free_result(pa_db, result);
/* delete all records */
- if(pa_dbf.delete(pa_db, 0,0,0,0)< 0)
+ if(fallback2db==0 && pa_dbf.delete(pa_db, 0,0,0,0)< 0)
{
LM_ERR("deleting all records from database table\n");
return -1;