Ejemplo n.º 1
0
/**
 * Creates and Adds a new r_public record. 
 * \note Must be called with a lock on the domain to avoid races
 * \note When calling be sure that get_r_public(d,aor) returns 0, 
 * to avoid unreachable duplicates
 * @param c - the r_contact to add to
 * @param aor - the address of record
 * @param is_default - if this is the default contact
 * @returns the newly added r_public, 0 on error
 */
r_public* add_r_public(r_contact *c,str aor,int is_default)
{
	r_public *p;
	if (!c) return 0;
	p = new_r_public(aor,is_default);
	if (!p) return 0;
	p->next=0;
	p->prev=c->tail;
	if (c->tail) c->tail->next = p;
	c->tail = p;
	if (!c->head) c->head=p;
	
	return p;
}
Ejemplo n.º 2
0
/**
 * Creates and Adds a new r_public record. 
 * \note Aquires the lock on the hash_slot on success, so release it when you are done.
 * \note When calling be sure that get_r_public(aor) returns 0, to avoid unreachable duplicates
 * @param aor - the address of record
 * @param reg_state - current registration state
 * @param s - the subscription attached
 * @returns the newly added r_public or NULL on error
 */
r_public* add_r_public(str aor,enum Reg_States reg_state,ims_subscription *s)
{
	r_public *p;
	unsigned int hash;

	p = new_r_public(aor,reg_state,s);
	hash = p->hash;
	if (!p) return 0;	
	p->next=0;
	r_lock(hash);
		p->prev=registrar[hash].tail;
		if (p->prev) p->prev->next = p;
		registrar[hash].tail = p;
		if (!registrar[hash].head) registrar[hash].head=p;
	return p;
}