/** * Takes on S-CSCF name for the respective Call-ID from the respective name list. * Should shm_free the result.s when no longer needed. * @param call_id - the id of the call * @returns the shm_malloced S-CSCF name if found or empty string if list is empty or does not exists */ str take_scscf_entry(str call_id) { str scscf={0,0}; scscf_list *l=0; scscf_entry *sl; unsigned int hash = get_call_id_hash(call_id,i_hash_size); i_lock(hash); l = i_hash_table[hash].head; while(l){ if (l->call_id.len == call_id.len && strncasecmp(l->call_id.s,call_id.s,call_id.len)==0) { if (l->list){ scscf = l->list->scscf_name; sl = l->list->next; shm_free(l->list); l->list = sl; } break; } l = l->next; } i_unlock(hash); return scscf; }
void print_scscf_list(int log_level) { scscf_list *l; int i; scscf_entry *sl; LOG(log_level,"INF:"M_NAME":---------- S-CSCF Lists begin --------------\n"); for(i=0;i<i_hash_size;i++){ i_lock(i); l = i_hash_table[i].head; while(l){ LOG(log_level,"INF:"M_NAME":[%4d] Call-ID: <%.*s> \n",i, l->call_id.len,l->call_id.s); sl = l->list; while(sl){ LOG(log_level,"INF:"M_NAME": Score:[%4d] S-CSCF: <%.*s> \n", sl->score, sl->scscf_name.len,sl->scscf_name.s); sl = sl->next; } l = l->next; } i_unlock(i); } LOG(log_level,"INF:"M_NAME":---------- S-CSCF Lists end --------------\n"); }
int is_scscf_list(str call_id) { scscf_list *l=0; unsigned int hash = get_call_id_hash(call_id,i_hash_size); i_lock(hash); l = i_hash_table[hash].head; while(l){ if (l->call_id.len == call_id.len && strncasecmp(l->call_id.s,call_id.s,call_id.len)==0) { i_unlock(hash); return 1; } l = l->next; } i_unlock(hash); return 0; }
void del_scscf_list(str call_id) { scscf_list *l=0; unsigned int hash = get_call_id_hash(call_id,i_hash_size); i_lock(hash); l = i_hash_table[hash].head; while(l){ if (l->call_id.len == call_id.len && strncasecmp(l->call_id.s,call_id.s,call_id.len)==0) { if (l->prev) l->prev->next = l->next; else i_hash_table[hash].head = l->next; if (l->next) l->next->prev = l->prev; else i_hash_table[hash].tail = l->prev; i_unlock(hash); free_scscf_list(l); return; } l = l->next; } i_unlock(hash); }
static int do_coo(struct dentry *dentry, aufs_bindex_t bstart) { int err; struct dentry *parent, *h_parent, *h_dentry; aufs_bindex_t bcpup; struct inode *h_dir, *h_inode, *dir; LKTRTrace("%.*s\n", DLNPair(dentry)); DEBUG_ON(IS_ROOT(dentry)); DiMustWriteLock(dentry); parent = dentry->d_parent; // dget_parent() di_write_lock_parent(parent); bcpup = err = find_rw_parent_br(dentry, bstart); //bcpup = err = find_rw_br(sb, bstart); if (unlikely(err < 0)) { err = 0; // stop copyup, it is not an error goto out; } err = 0; h_parent = au_h_dptr_i(parent, bcpup); if (!h_parent) { err = cpup_dirs(dentry, bcpup, NULL); if (unlikely(err)) goto out; h_parent = au_h_dptr_i(parent, bcpup); } h_dir = h_parent->d_inode; h_dentry = au_h_dptr_i(dentry, bstart); h_inode = h_dentry->d_inode; dir = parent->d_inode; hdir_lock(h_dir, dir, bcpup); hi_lock_child(h_inode); DEBUG_ON(au_h_dptr_i(dentry, bcpup)); err = sio_cpup_simple(dentry, bcpup, -1, au_flags_cpup(CPUP_DTIME, parent)); TraceErr(err); i_unlock(h_inode); hdir_unlock(h_dir, dir, bcpup); out: di_write_unlock(parent); TraceErr(err); return err; }
/** * Destroy the hash with S-CSCF lists */ void i_hash_table_destroy() { int i; scscf_list *sl,*nsl; for(i=0;i<i_hash_size;i++){ i_lock(i); sl = i_hash_table[i].head; while(sl){ nsl = sl->next; free_scscf_list(sl); sl = nsl; } i_unlock(i); lock_dealloc(i_hash_table[i].lock); } shm_free(i_hash_table); }
int add_scscf_list(str call_id,scscf_entry *sl) { scscf_list *l; unsigned int hash = get_call_id_hash(call_id,i_hash_size); l = new_scscf_list(call_id,sl); if (!l) return 0; i_lock(hash); l->prev = 0; l->next = i_hash_table[hash].head; if (l->next) l->next->prev = l; i_hash_table[hash].head = l; if (!i_hash_table[hash].tail) i_hash_table[hash].tail = l; i_unlock(hash); return 1; }