浏览代码

modules/ims_usrloc_scscf: update expires of subscriber on update subscriber

Richard Good 10 年之前
父节点
当前提交
626f37f322
共有 1 个文件被更改,包括 25 次插入0 次删除
  1. 25 0
      modules/ims_usrloc_scscf/subscribe.c

+ 25 - 0
modules/ims_usrloc_scscf/subscribe.c

@@ -179,11 +179,14 @@ reg_subscriber* new_subscriber(subscriber_data_t* subscriber_data) {
     }
     }
     
     
     /*This lets us get presentity URI info for subsequent SUBSCRIBEs that don't have presentity URI as req URI*/
     /*This lets us get presentity URI info for subsequent SUBSCRIBEs that don't have presentity URI as req URI*/
+    get_act_time();
     
     
     subs.pres_uri = s->presentity_uri;
     subs.pres_uri = s->presentity_uri;
     subs.from_tag = s->from_tag;
     subs.from_tag = s->from_tag;
     subs.to_tag = s->to_tag;
     subs.to_tag = s->to_tag;
     subs.callid = s->call_id;
     subs.callid = s->call_id;
+    subs.expires = s->expires - act_time;
+    subs.contact = s->watcher_contact;
     
     
     hash_code = core_hash(&subs.callid, &subs.to_tag, sub_dialog_hash_size);
     hash_code = core_hash(&subs.callid, &subs.to_tag, sub_dialog_hash_size);
     
     
@@ -283,6 +286,8 @@ done:
 
 
 int update_subscriber(impurecord_t* urec, reg_subscriber** _reg_subscriber, int *expires, int *local_cseq, int *version) {
 int update_subscriber(impurecord_t* urec, reg_subscriber** _reg_subscriber, int *expires, int *local_cseq, int *version) {
 
 
+    subs_t subs;
+    unsigned int hash_code = 0;
     reg_subscriber *rs = *_reg_subscriber;
     reg_subscriber *rs = *_reg_subscriber;
     if (expires) {
     if (expires) {
         rs->expires = *expires;
         rs->expires = *expires;
@@ -300,6 +305,26 @@ int update_subscriber(impurecord_t* urec, reg_subscriber** _reg_subscriber, int
         LM_DBG("No version so will not update subscriber version.\n");
         LM_DBG("No version so will not update subscriber version.\n");
     }
     }
     
     
+    /*This lets us get presentity URI info for subsequent SUBSCRIBEs that don't have presentity URI as req URI*/
+    get_act_time();
+    
+    subs.pres_uri = rs->presentity_uri;
+    subs.from_tag = rs->from_tag;
+    subs.to_tag = rs->to_tag;
+    subs.callid = rs->call_id;
+    subs.expires = rs->expires - act_time;
+    subs.contact = rs->watcher_contact;
+    
+    hash_code = core_hash(&subs.callid, &subs.to_tag, sub_dialog_hash_size);
+    
+    LM_DBG("Updating sub dialog hash info with call_id: <%.*s> and ttag <%.*s> amd ftag <%.*s> and hash code <%d>", subs.callid.len, subs.callid.s, subs.to_tag.len, subs.to_tag.s, subs.from_tag.len,  subs.from_tag.s, hash_code);
+    
+    if (pres_update_shtable(sub_dialog_table, hash_code, &subs, REMOTE_TYPE))
+    {
+	LM_ERR("while updating new subscription\n");
+	return 0;
+    }
+        
     /*DB?*/
     /*DB?*/
     if (db_mode == WRITE_THROUGH && db_insert_subscriber(urec, rs) != 0) {
     if (db_mode == WRITE_THROUGH && db_insert_subscriber(urec, rs) != 0) {
 	    LM_ERR("Failed to insert subscriber into DB subscriber [%.*s] to IMPU [%.*s]...continuing but db will be out of sync!\n", 
 	    LM_ERR("Failed to insert subscriber into DB subscriber [%.*s] to IMPU [%.*s]...continuing but db will be out of sync!\n",