Module: sip-router
Branch: master
Commit: 647a786907178bfa3c709497678afe1589646943
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=647a786…
Author: root <root(a)boyce.voipuser.org>
Committer: root <root(a)boyce.voipuser.org>
Date: Sat Oct 2 20:09:09 2010 +0100
presence(k): fallback2db==1 mode updates
- go through all the list of active subcriptions when sync'ing to db, even one db
operation throws error
- if fallback2db==1, don't attempt to insert the record back
---
modules_k/presence/hash.c | 10 ++++++----
modules_k/presence/subscribe.c | 26 ++++++++++----------------
2 files changed, 16 insertions(+), 20 deletions(-)
diff --git a/modules_k/presence/hash.c b/modules_k/presence/hash.c
index bc31b87..9d36642 100644
--- a/modules_k/presence/hash.c
+++ b/modules_k/presence/hash.c
@@ -261,10 +261,12 @@ int insert_shtable(shtable_t htable,unsigned int hash_code, subs_t*
subs)
}
new_rec->expires+= (int)time(NULL);
- if(fallback2db!=0)
- new_rec->db_flag= INSERTDB_FLAG;
- else
- new_rec->db_flag= NO_UPDATEDB_FLAG;
+ if(fallback2db!=0) {
+ if(new_rec->db_flag==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 c6f4aa2..94bf9d8 100644
--- a/modules_k/presence/subscribe.c
+++ b/modules_k/presence/subscribe.c
@@ -1536,12 +1536,10 @@ void update_db_subs(db1_con_t *db,db_func_t dbf, shtable_t
hash_table,
switch(s->db_flag)
{
case NO_UPDATEDB_FLAG:
- {
LM_DBG("NO_UPDATEDB_FLAG\n");
break;
- }
+
case UPDATEDB_FLAG:
- {
LM_DBG("UPDATEDB_FLAG\n");
query_vals[pres_uri_col].val.str_val= s->pres_uri;
@@ -1560,14 +1558,12 @@ void update_db_subs(db1_con_t *db,db_func_t dbf, shtable_t
hash_table,
update_vals, n_query_update, n_update_cols)< 0)
{
LM_ERR("updating in database\n");
- if(!no_lock)
- lock_release(&hash_table[i].lock);
- return ;
+ } else {
+ s->db_flag= NO_UPDATEDB_FLAG;
}
break;
- }
+
case INSERTDB_FLAG:
- {
LM_DBG("INSERTDB_FLAG\n");
query_vals[pres_uri_col].val.str_val= s->pres_uri;
@@ -1594,15 +1590,11 @@ void update_db_subs(db1_con_t *db,db_func_t dbf, shtable_t
hash_table,
if(dbf.insert(db,query_cols,query_vals,n_query_cols )<0)
{
LM_ERR("unsuccessful sql insert\n");
- if(!no_lock)
- lock_release(&hash_table[i].lock);
- return ;
+ } else {
+ s->db_flag= NO_UPDATEDB_FLAG;
}
break;
- }
-
- }
- s->db_flag= NO_UPDATEDB_FLAG;
+ } /* switch */
prev_s= s;
s= s->next;
}
@@ -1808,7 +1800,9 @@ int restore_db_subs(void)
s.sockinfo_str.s=(char*)row_vals[sockinfo_col].val.string_val;
s.sockinfo_str.len= strlen(s.sockinfo_str.s);
-
+
+ if(fallback2db!=0)
+ s.db_flag = NO_UPDATEDB_FLAG;
hash_code= core_hash(&s.pres_uri, &s.event->name, shtable_size);
if(insert_shtable(subs_htable, hash_code, &s)< 0)
{