Browse code

modules/ims_usrloc_scscf: update expires of subscriber on update subscriber

Richard Good authored on 13/11/2014 07:51:29
Showing 1 changed files
... ...
@@ -179,11 +179,14 @@ reg_subscriber* new_subscriber(subscriber_data_t* subscriber_data) {
179 179
     }
180 180
     
181 181
     /*This lets us get presentity URI info for subsequent SUBSCRIBEs that don't have presentity URI as req URI*/
182
+    get_act_time();
182 183
     
183 184
     subs.pres_uri = s->presentity_uri;
184 185
     subs.from_tag = s->from_tag;
185 186
     subs.to_tag = s->to_tag;
186 187
     subs.callid = s->call_id;
188
+    subs.expires = s->expires - act_time;
189
+    subs.contact = s->watcher_contact;
187 190
     
188 191
     hash_code = core_hash(&subs.callid, &subs.to_tag, sub_dialog_hash_size);
189 192
     
... ...
@@ -283,6 +286,8 @@ done:
283 286
 
284 287
 int update_subscriber(impurecord_t* urec, reg_subscriber** _reg_subscriber, int *expires, int *local_cseq, int *version) {
285 288
 
289
+    subs_t subs;
290
+    unsigned int hash_code = 0;
286 291
     reg_subscriber *rs = *_reg_subscriber;
287 292
     if (expires) {
288 293
         rs->expires = *expires;
... ...
@@ -300,6 +305,26 @@ int update_subscriber(impurecord_t* urec, reg_subscriber** _reg_subscriber, int
300 305
         LM_DBG("No version so will not update subscriber version.\n");
301 306
     }
302 307
     
308
+    /*This lets us get presentity URI info for subsequent SUBSCRIBEs that don't have presentity URI as req URI*/
309
+    get_act_time();
310
+    
311
+    subs.pres_uri = rs->presentity_uri;
312
+    subs.from_tag = rs->from_tag;
313
+    subs.to_tag = rs->to_tag;
314
+    subs.callid = rs->call_id;
315
+    subs.expires = rs->expires - act_time;
316
+    subs.contact = rs->watcher_contact;
317
+    
318
+    hash_code = core_hash(&subs.callid, &subs.to_tag, sub_dialog_hash_size);
319
+    
320
+    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);
321
+    
322
+    if (pres_update_shtable(sub_dialog_table, hash_code, &subs, REMOTE_TYPE))
323
+    {
324
+	LM_ERR("while updating new subscription\n");
325
+	return 0;
326
+    }
327
+        
303 328
     /*DB?*/
304 329
     if (db_mode == WRITE_THROUGH && db_insert_subscriber(urec, rs) != 0) {
305 330
 	    LM_ERR("Failed to insert subscriber into DB subscriber [%.*s] to IMPU [%.*s]...continuing but db will be out of sync!\n",