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

Function insert_htable

modules/pua/hash.c:388–429  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

386}
387
388unsigned long insert_htable(ua_pres_t* presentity, int mem_only)
389{
390 unsigned int hash_code;
391 str* s1;
392 unsigned long pres_id;
393 ua_pres_t* p;
394
395 if(presentity->to_uri.s)
396 s1 = &presentity->to_uri;
397 else
398 s1 = presentity->pres_uri;
399
400 LM_DBG("to_uri= %.*s, watcher_uri= %.*s\n", s1->len, s1->s,
401 (presentity->watcher_uri?presentity->watcher_uri->len:0),
402 (presentity->watcher_uri?presentity->watcher_uri->s:0));
403
404 hash_code= core_hash(s1, presentity->watcher_uri,
405 HASH_SIZE);
406 presentity->hash_index = hash_code;
407 LM_DBG("hash_code = %d\n", hash_code);
408
409 lock_get(&HashT->p_records[hash_code].lock);
410
411 p= HashT->p_records[hash_code].entity;
412
413 presentity->db_flag= mem_only ? NO_UPDATEDB_FLAG : INSERTDB_FLAG;
414 presentity->next= p->next;
415 p->next= presentity;
416
417 p->local_index++;
418 /* local_index cannot be larger than half long, to be sure it will
419 * not overflow the pres_id */
420 if (p->local_index == (((unsigned long)1)<<(sizeof(long)*8/2))-1)
421 p->local_index = 0;
422 presentity->local_index = p->local_index;
423
424 pres_id = PRES_HASH_ID(presentity);
425
426 lock_release(&HashT->p_records[hash_code].lock);
427
428 return pres_id;
429}
430
431
432static void pua_db_delete(ua_pres_t* pres)

Callers 3

db_restoreFunction · 0.85
new_publ_recordFunction · 0.85
subs_cback_funcFunction · 0.85

Calls 3

core_hashFunction · 0.85
lock_getFunction · 0.85
lock_releaseFunction · 0.85

Tested by

no test coverage detected