MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / wb_timer

Function wb_timer

modules/usrloc/urecord.c:314–395  ·  view source on GitHub ↗

! \brief * Write-back timer */

Source from the content-addressed store, hash-verified

312 * Write-back timer
313 */
314static inline int wb_timer(urecord_t* _r,query_list_t **ins_list)
315{
316 ucontact_t* ptr, *t;
317 cstate_t old_state;
318 int op,ins_done=0;
319
320 ptr = _r->contacts;
321
322 if (rr_persist == RRP_LOAD_FROM_SQL && persist_urecord_kv_store(_r) != 0)
323 LM_DBG("failed to persist latest urecord K/V storage\n");
324
325 while(ptr) {
326 if (!VALID_CONTACT(ptr, act_time)) {
327 /* for forcibly expired contacts, DELETE event is already run */
328 if (!FORCE_EXPIRED_CONTACT(ptr) && exists_ulcb_type(UL_CONTACT_EXPIRE))
329 run_ul_callbacks( UL_CONTACT_EXPIRE, ptr, NULL);
330
331 LM_DBG("Binding '%.*s','%.*s' has expired\n",
332 ptr->aor->len, ZSW(ptr->aor->s),
333 ptr->c.len, ZSW(ptr->c.s));
334
335 if (have_mem_storage())
336 update_stat( _r->slot->d->expires, 1);
337
338 t = ptr;
339 ptr = ptr->next;
340
341 /* Should we remove the contact from the database ? */
342 if (cid_vals && st_expired_ucontact(t) == 1
343 && !(t->flags & FL_MEM)) {
344 VAL_BIGINT(cid_vals+cid_len) = t->contact_id;
345 if ((++cid_len) == max_contact_delete) {
346 if (db_multiple_ucontact_delete(_r->domain, cid_keys,
347 cid_vals, cid_len) < 0) {
348 LM_ERR("failed to delete contacts from database\n");
349 /* pass over these contacts; we will try to delete
350 * them later */
351 cid_len = 0;
352
353 /* do not delete from memory now - if we do, we'll get
354 * a stuck record in DB. Future registrations will not
355 * be able to get inserted due to index collision */
356 continue;
357 }
358 cid_len = 0;
359 }
360 }
361
362 mem_delete_ucontact(_r, t);
363 } else {
364 /* Determine the operation we have to do */
365 old_state = ptr->state;
366 op = st_flush_ucontact(ptr);
367
368 switch(op) {
369 case 0: /* do nothing, contact is synchronized */
370 break;
371

Callers 2

db_only_timerFunction · 0.85
timer_urecordFunction · 0.85

Calls 9

persist_urecord_kv_storeFunction · 0.85
run_ul_callbacksFunction · 0.85
have_mem_storageFunction · 0.85
st_expired_ucontactFunction · 0.85
mem_delete_ucontactFunction · 0.85
st_flush_ucontactFunction · 0.85
db_insert_ucontactFunction · 0.85
db_update_ucontactFunction · 0.85

Tested by

no test coverage detected