[sr-dev] git:master: sca: fix DB updates

Andrew Mortensen admorten at isc.upenn.edu
Tue Dec 4 23:08:29 CET 2012


Module: sip-router
Branch: master
Commit: 5871982d3c76a4b42cd05e4b8dfb0e6128acb799
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=5871982d3c76a4b42cd05e4b8dfb0e6128acb799

Author: Andrew Mortensen <admorten at isc.upenn.edu>
Committer: Andrew Mortensen <admorten at isc.upenn.edu>
Date:   Tue Dec  4 17:04:11 2012 -0500

sca: fix DB updates

- if a subscription were updated before being inserted into the DB, the
  next DB sync call would incorrectly try to UPDATE instead of INSERT.
- no effect on SCA functionality, but subscriptions are no longer lost
  across restarts.

---

 modules/sca/sca_subscribe.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/modules/sca/sca_subscribe.c b/modules/sca/sca_subscribe.c
index 16368e3..54331ef 100644
--- a/modules/sca/sca_subscribe.c
+++ b/modules/sca/sca_subscribe.c
@@ -826,8 +826,10 @@ sca_subscription_update_unsafe( sca_mod *scam, sca_subscription *saved_sub,
     saved_sub->dialog.notify_cseq += 1;
     saved_sub->expires = time( NULL ) + update_sub->expires;
 
-    /* flag subscription for write back to DB */ 
-    saved_sub->db_cmd_flag = SCA_DB_FLAG_UPDATE;
+    /* flag subscription for DB update only if we've already inserted */ 
+    if ( saved_sub->db_cmd_flag == SCA_DB_FLAG_NONE ) {
+	saved_sub->db_cmd_flag = SCA_DB_FLAG_UPDATE;
+    }
 
     if ( update_sub->index != SCA_CALL_INFO_APPEARANCE_INDEX_ANY ) {
 	saved_sub->index = update_sub->index;




More information about the sr-dev mailing list