本文整理汇总了C++中dlg_unlock函数的典型用法代码示例。如果您正苦于以下问题:C++ dlg_unlock函数的具体用法?C++ dlg_unlock怎么用?C++ dlg_unlock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dlg_unlock函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: link_dlg
void link_dlg(struct dlg_cell *dlg, int n)
{
struct dlg_entry *d_entry;
d_entry = &(d_table->entries[dlg->h_entry]);
dlg_lock( d_table, d_entry);
dlg->h_id = d_entry->next_id++;
if (d_entry->first==0) {
d_entry->first = d_entry->last = dlg;
} else {
d_entry->last->next = dlg;
dlg->prev = d_entry->last;
d_entry->last = dlg;
}
dlg->ref += 1 + n;
d_entry->cnt++;
LM_DBG("ref dlg %p with %d -> %d in h_entry %p - %d \n", dlg, n+1, dlg->ref,
d_entry,dlg->h_entry);
dlg_unlock( d_table, d_entry);
return;
}
开发者ID:WuKongQC,项目名称:opensips,代码行数:26,代码来源:dlg_hash.c
示例2: dlg_hash_release
/*!
* \brief Release hash table slot by call-id
* \param callid call-id value
*/
void dlg_hash_release(str *callid)
{
unsigned int he;
struct dlg_entry *d_entry;
he = core_hash(callid, 0, d_table->size);
d_entry = &(d_table->entries[he]);
dlg_unlock(d_table, d_entry);
}
开发者ID:AlessioCasco,项目名称:kamailio,代码行数:13,代码来源:dlg_hash.c
示例3: internal_mi_print_dlgs
static int internal_mi_print_dlgs(struct mi_root *rpl_tree,struct mi_node *rpl,
int with_context, unsigned int idx, unsigned int cnt)
{
struct dlg_cell *dlg;
unsigned int i;
unsigned int n;
unsigned int total;
char *p;
total = 0;
if (cnt) {
for(i=0;i<d_table->size ; total+=d_table->entries[i++].cnt );
p = int2str((unsigned long)total, (int*)&n);
if (add_mi_node_child(rpl,MI_DUP_VALUE,"dlg_counter",11,p,n)==0)
return -1;
}
LM_DBG("printing %i dialogs, idx=%d, cnt=%d\n", total,idx,cnt);
rpl->flags |= MI_NOT_COMPLETED;
for( i=0,n=0 ; i<d_table->size ; i++ ) {
dlg_lock( d_table, &(d_table->entries[i]) );
for( dlg=d_table->entries[i].first ; dlg ; dlg=dlg->next ) {
if (cnt && n<idx) {n++;continue;}
if (internal_mi_print_dlg(rpl, dlg, with_context)!=0)
goto error;
n++;
if (cnt && n>=idx+cnt) {
dlg_unlock( d_table, &(d_table->entries[i]) );
return 0;
}
if ( (n % 50) == 0 )
flush_mi_tree(rpl_tree);
}
dlg_unlock( d_table, &(d_table->entries[i]) );
}
return 0;
error:
dlg_unlock( d_table, &(d_table->entries[i]) );
LM_ERR("failed to print dialog\n");
return -1;
}
开发者ID:andrey-vorobiev,项目名称:opensips,代码行数:44,代码来源:dlg_hash.c
示例4: dlg_unref
/*!
* \brief Unreference a dialog with locking
* \see unref_dlg_unsafe
* \param dlg dialog
* \param cnt decrement for the reference counter
*/
void dlg_unref(dlg_cell_t *dlg, unsigned int cnt)
{
dlg_entry_t *d_entry;
d_entry = &(d_table->entries[dlg->h_entry]);
dlg_lock( d_table, d_entry);
unref_dlg_unsafe( dlg, cnt, d_entry);
dlg_unlock( d_table, d_entry);
}
开发者ID:AlessioCasco,项目名称:kamailio,代码行数:16,代码来源:dlg_hash.c
示例5: unref_dlg
void unref_dlg(struct dlg_cell *dlg, unsigned int cnt)
{
struct dlg_entry *d_entry;
d_entry = &(d_table->entries[dlg->h_entry]);
dlg_lock( d_table, d_entry);
unref_dlg_unsafe( dlg, cnt, d_entry);
dlg_unlock( d_table, d_entry);
}
开发者ID:andrey-vorobiev,项目名称:opensips,代码行数:10,代码来源:dlg_hash.c
示例6: pv_get_dlg_variable
int pv_get_dlg_variable(struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
{
dlg_cell_t *dlg;
str * value;
str spv;
if (param==NULL || param->pvn.type!=PV_NAME_INTSTR
|| param->pvn.u.isname.type!=AVP_NAME_STR
|| param->pvn.u.isname.name.s.s==NULL) {
LM_CRIT("BUG - bad parameters\n");
return -1;
}
/* Retrieve the dialog for current message */
dlg=dlg_get_msg_dialog( msg);
if (dlg) {
/* Lock the dialog */
dlg_lock(d_table, &(d_table->entries[dlg->h_entry]));
} else {
/* Verify the local list */
get_local_varlist_pointer(msg, 0);
}
/* dcm: todo - the value should be cloned for safe usage */
value = get_dlg_variable_unsafe(dlg, ¶m->pvn.u.isname.name.s);
spv.s = NULL;
if(value) {
spv.len = pv_get_buffer_size();
if(spv.len<value->len+1) {
LM_ERR("pv buffer too small (%d) - needed %d\n", spv.len, value->len);
} else {
spv.s = pv_get_buffer();
strncpy(spv.s, value->s, value->len);
spv.len = value->len;
spv.s[spv.len] = '\0';
}
}
print_lists(dlg);
/* unlock dialog */
if (dlg) {
dlg_unlock(d_table, &(d_table->entries[dlg->h_entry]));
dlg_release(dlg);
}
if (spv.s)
return pv_get_strval(msg, param, res, &spv);
return pv_get_null(msg, param, res);
}
开发者ID:TheGrandWazoo,项目名称:kamailio,代码行数:55,代码来源:dlg_var.c
示例7: is_dlg_in_profile
/*!
* \brief Check if a dialog belongs to a profile
* \param msg SIP message
* \param profile dialog profile table
* \param value value
* \return 1 on success, -1 on failure
*/
int is_dlg_in_profile(struct sip_msg *msg, struct dlg_profile_table *profile,
str *value)
{
struct dlg_cell *dlg;
struct dlg_profile_link *linker;
struct dlg_entry *d_entry;
int ret;
/* get current dialog */
dlg = dlg_get_msg_dialog(msg);
if (dlg==NULL)
return -1;
ret = -1;
/* check the dialog linkers */
d_entry = &d_table->entries[dlg->h_entry];
dlg_lock( d_table, d_entry);
for( linker=dlg->profile_links ; linker ; linker=linker->next) {
if (linker->profile==profile) {
if (profile->has_value==0) {
dlg_unlock( d_table, d_entry);
ret = 1;
goto done;
} else if (value && value->len==linker->hash_linker.value.len &&
memcmp(value->s,linker->hash_linker.value.s,value->len)==0){
dlg_unlock( d_table, d_entry);
ret = 1;
goto done;
}
/* allow further search - maybe the dialog is inserted twice in
* the same profile, but with different values -bogdan
*/
}
}
dlg_unlock( d_table, d_entry);
done:
dlg_release(dlg);
return ret;
}
开发者ID:TheGrandWazoo,项目名称:kamailio,代码行数:48,代码来源:dlg_profile.c
示例8: dlg_unref_helper
/*!
* \brief Unreference a dialog with locking
* \see unref_dlg_unsafe
* \param dlg dialog
* \param cnt decrement for the reference counter
*/
void dlg_unref_helper(dlg_cell_t *dlg, unsigned int cnt, const char *fname,
int fline)
{
dlg_entry_t *d_entry;
LM_DBG("unref op on %p with %d from %s:%d\n", dlg, cnt, fname, fline);
d_entry = &(d_table->entries[dlg->h_entry]);
dlg_lock( d_table, d_entry);
unref_dlg_unsafe( dlg, cnt, d_entry);
dlg_unlock( d_table, d_entry);
}
开发者ID:GreenfieldTech,项目名称:kamailio,代码行数:18,代码来源:dlg_hash.c
示例9: dlg_update_contact
/*!
* \brief Update or set the Contact for an existing dialog
* \param dlg dialog
* \param leg must be either DLG_CALLER_LEG, or DLG_CALLEE_LEG
* \param ct Contact of caller or callee
* \return 0 on success, -1 on failure
*/
int dlg_update_contact(struct dlg_cell * dlg, unsigned int leg, str *ct)
{
dlg_entry_t *d_entry;
d_entry = &(d_table->entries[dlg->h_entry]);
dlg_lock(d_table, d_entry);
if ( dlg->contact[leg].s ) {
if(dlg->contact[leg].len == ct->len
&& memcmp(dlg->contact[leg].s, ct->s, ct->len)==0) {
LM_DBG("same contact for leg[%d] - [%.*s]\n", leg,
dlg->contact[leg].len, dlg->contact[leg].s);
goto done;
}
if (dlg->contact[leg].len < ct->len) {
shm_free(dlg->contact[leg].s);
dlg->contact[leg].s = (char*)shm_malloc(ct->len);
if (dlg->contact[leg].s==NULL)
goto error;
}
} else {
dlg->contact[leg].s = (char*)shm_malloc(ct->len);
if (dlg->contact[leg].s==NULL)
goto error;
}
memcpy( dlg->contact[leg].s, ct->s, ct->len );
dlg->contact[leg].len = ct->len;
LM_DBG("contact of leg[%d] is %.*s\n", leg,
dlg->contact[leg].len, dlg->contact[leg].s);
done:
dlg_unlock(d_table, d_entry);
return 0;
error:
dlg_unlock(d_table, d_entry);
LM_ERR("not more shm mem\n");
return -1;
}
开发者ID:GreenfieldTech,项目名称:kamailio,代码行数:47,代码来源:dlg_hash.c
示例10: internal_rpc_print_dlgs
/*!
* \brief Helper function that outputs all dialogs via the RPC interface
* \see rpc_print_dlgs
* \param rpc RPC node that should be filled
* \param c RPC void pointer
* \param with_context if 1 then the dialog context will be also printed
*/
static void internal_rpc_print_dlgs(rpc_t *rpc, void *c, int with_context)
{
dlg_cell_t *dlg;
unsigned int i;
for( i=0 ; i<d_table->size ; i++ ) {
dlg_lock( d_table, &(d_table->entries[i]) );
for( dlg=d_table->entries[i].first ; dlg ; dlg=dlg->next ) {
internal_rpc_print_dlg(rpc, c, dlg, with_context);
}
dlg_unlock( d_table, &(d_table->entries[i]) );
}
}
开发者ID:kingsumos,项目名称:kamailio,代码行数:21,代码来源:dialog.c
示例11: internal_mi_print_dlgs
/*!
* \brief Helper function that output all dialogs via the MI interface
* \see mi_print_dlgs
* \param rpl MI node that should be filled
* \param with_context if 1 then the dialog context will be also printed
* \return 0 on success, -1 on failure
*/
static int internal_mi_print_dlgs(struct mi_node *rpl, int with_context)
{
struct dlg_cell *dlg;
unsigned int i;
LM_DBG("printing %i dialogs\n", d_table->size);
for( i=0 ; i<d_table->size ; i++ ) {
dlg_lock( d_table, &(d_table->entries[i]) );
for( dlg=d_table->entries[i].first ; dlg ; dlg=dlg->next ) {
if (internal_mi_print_dlg(rpl, dlg, with_context)!=0)
goto error;
}
dlg_unlock( d_table, &(d_table->entries[i]) );
}
return 0;
error:
dlg_unlock( d_table, &(d_table->entries[i]) );
LM_ERR("failed to print dialog\n");
return -1;
}
开发者ID:AlessioCasco,项目名称:kamailio,代码行数:30,代码来源:dlg_hash.c
示例12: set_dlg_variable
int set_dlg_variable(struct dlg_cell *dlg, str *key, str *val)
{
if( !dlg || !key || key->len > strlen(key->s) || (val && val->len > strlen(val->s)))
{
LM_ERR("BUG - bad parameters\n");
return -1;
}
dlg_lock(d_table, &(d_table->entries[dlg->h_entry]));
if( !val)
{
if (set_dlg_variable_unsafe(dlg, key, NULL)!=0) {
LM_ERR("failed to delete dialog variable <%.*s>\n", key->len,key->s);
goto error;
}
} else {
if (set_dlg_variable_unsafe(dlg, key, val)!=0) {
LM_ERR("failed to store dialog values <%.*s>\n",key->len,key->s);
goto error;
}
}
dlg->dflags &= DLG_FLAG_CHANGED_VARS;
dlg_unlock(d_table, &(d_table->entries[dlg->h_entry]));
if ( dlg_db_mode==DB_MODE_REALTIME )
update_dialog_dbinfo(dlg);
print_lists(dlg);
return 0;
error:
dlg_unlock(d_table, &(d_table->entries[dlg->h_entry]));
return -1;
}
开发者ID:TheGrandWazoo,项目名称:kamailio,代码行数:37,代码来源:dlg_var.c
示例13: get_dlg_variable
str * get_dlg_variable(struct dlg_cell *dlg, str *key)
{
str* var = NULL;
if( !dlg || !key || key->len > strlen(key->s))
{
LM_ERR("BUG - bad parameters\n");
return NULL;
}
dlg_lock(d_table, &(d_table->entries[dlg->h_entry]));
var = get_dlg_variable_unsafe( dlg, key);
dlg_unlock(d_table, &(d_table->entries[dlg->h_entry]));
return var;
}
开发者ID:TheGrandWazoo,项目名称:kamailio,代码行数:17,代码来源:dlg_var.c
示例14: internal_rpc_print_single_dlg
/*!
* \brief Helper function that outputs a dialog via the RPC interface
* \see rpc_print_dlgs
* \param rpc RPC node that should be filled
* \param c RPC void pointer
* \param with_context if 1 then the dialog context will be also printed
*/
static void internal_rpc_print_single_dlg(rpc_t *rpc, void *c, int with_context) {
str callid, from_tag;
dlg_entry_t *d_entry;
dlg_cell_t *dlg;
unsigned int h_entry;
if (rpc->scan(c, ".S.S", &callid, &from_tag) < 2) return;
h_entry = core_hash( &callid, 0, d_table->size);
d_entry = &(d_table->entries[h_entry]);
dlg_lock( d_table, d_entry);
for( dlg = d_entry->first ; dlg ; dlg = dlg->next ) {
if (match_downstream_dialog( dlg, &callid, &from_tag)==1) {
internal_rpc_print_dlg(rpc, c, dlg, with_context);
}
}
dlg_unlock( d_table, d_entry);
}
开发者ID:kingsumos,项目名称:kamailio,代码行数:25,代码来源:dialog.c
示例15: dlg_clean_run
/**
* clean old unconfirmed dialogs
*
*/
int dlg_clean_run(ticks_t ti)
{
unsigned int i;
unsigned int tm;
dlg_cell_t *dlg;
dlg_cell_t *tdlg;
tm = (unsigned int)time(NULL);
for(i=0; i<d_table->size; i++)
{
dlg_lock(d_table, &d_table->entries[i]);
dlg = d_table->entries[i].first;
while (dlg) {
tdlg = dlg;
dlg = dlg->next;
if(tdlg->state==DLG_STATE_UNCONFIRMED && tdlg->init_ts>0
&& tdlg->init_ts<tm-dlg_early_timeout) {
/* dialog in early state older than 5min */
LM_NOTICE("dialog in early state is too old (%p ref %d)\n",
tdlg, tdlg->ref);
unlink_unsafe_dlg(&d_table->entries[i], tdlg);
destroy_dlg(tdlg);
}
if(tdlg->state==DLG_STATE_CONFIRMED_NA && tdlg->start_ts>0
&& tdlg->start_ts<tm-dlg_noack_timeout) {
if(update_dlg_timer(&tdlg->tl, 10)<0) {
LM_ERR("failed to update dialog lifetime in long non-ack state\n");
}
tdlg->lifetime = 10;
tdlg->dflags |= DLG_FLAG_CHANGED;
}
if(tdlg->state==DLG_STATE_DELETED && tdlg->end_ts>0
&& tdlg->end_ts<tm-dlg_end_timeout) {
/* dialog in deleted state older than 5min */
LM_NOTICE("dialog in delete state is too old (%p ref %d)\n",
tdlg, tdlg->ref);
unlink_unsafe_dlg(&d_table->entries[i], tdlg);
destroy_dlg(tdlg);
}
}
dlg_unlock(d_table, &d_table->entries[i]);
}
return 0;
}
开发者ID:GreenfieldTech,项目名称:kamailio,代码行数:48,代码来源:dlg_hash.c
示例16: link_dlg_profile
/*!
* \brief Link a dialog profile
* \param linker dialog linker
* \param dlg dialog cell
*/
static void link_dlg_profile(struct dlg_profile_link *linker, struct dlg_cell *dlg)
{
unsigned int hash;
struct dlg_profile_entry *p_entry;
struct dlg_entry *d_entry;
/* add the linker to the dialog */
/* FIXME zero h_id is not 100% for testing if the dialog is inserted
* into the hash table -> we need circular lists -bogdan */
if (dlg->h_id) {
d_entry = &d_table->entries[dlg->h_entry];
dlg_lock( d_table, d_entry);
linker->next = dlg->profile_links;
dlg->profile_links =linker;
linker->hash_linker.dlg = dlg;
dlg_unlock( d_table, d_entry);
} else {
linker->next = dlg->profile_links;
dlg->profile_links =linker;
linker->hash_linker.dlg = dlg;
}
/* calculate the hash position */
hash = calc_hash_profile(&linker->hash_linker.value, dlg, linker->profile);
linker->hash_linker.hash = hash;
/* insert into profile hash table */
p_entry = &linker->profile->entries[hash];
lock_get( &linker->profile->lock );
if (p_entry->first) {
linker->hash_linker.prev = p_entry->first->prev;
linker->hash_linker.next = p_entry->first;
p_entry->first->prev->next = &linker->hash_linker;
p_entry->first->prev = &linker->hash_linker;
} else {
p_entry->first = linker->hash_linker.next
= linker->hash_linker.prev = &linker->hash_linker;
}
p_entry->content ++;
lock_release( &linker->profile->lock );
}
开发者ID:aallamaa,项目名称:kamailio,代码行数:46,代码来源:dlg_profile.c
示例17: print_all_dlgs
void print_all_dlgs() {
//print all dialog information - this is just for testing and is set to happen every 10 seconds
struct dlg_cell *dlg;
unsigned int i;
LM_DBG("********************");
LM_DBG("printing %i dialogs\n", d_table->size);
for (i = 0; i < d_table->size; i++) {
dlg_lock(d_table, &(d_table->entries[i]));
for (dlg = d_table->entries[i].first; dlg; dlg = dlg->next) {
internal_print_all_dlg(dlg);
}
dlg_unlock(d_table, &(d_table->entries[i]));
}
LM_DBG("********************");
}
开发者ID:Jared-Prime,项目名称:kamailio,代码行数:21,代码来源:dlg_handlers.c
示例18: dmq_send_all_dlgs
int dmq_send_all_dlgs(dmq_node_t* dmq_node) {
int index;
dlg_entry_t entry;
dlg_cell_t *dlg;
LM_DBG("sending all dialogs \n");
for(index = 0; index< d_table->size; index++){
/* lock the whole entry */
entry = (d_table->entries)[index];
dlg_lock( d_table, &entry);
for(dlg = entry.first; dlg != NULL; dlg = dlg->next){
dlg->dflags |= DLG_FLAG_CHANGED_PROF;
dlg_dmq_replicate_action(DLG_DMQ_UPDATE, dlg, 0, dmq_node);
}
dlg_unlock( d_table, &entry);
}
return 0;
}
开发者ID:SipSeb,项目名称:kamailio,代码行数:22,代码来源:dlg_dmq.c
示例19: link_dlg_profile
/*!
* \brief Link a dialog profile
* \param linker dialog linker
* \param dlg dialog cell
*/
static void link_dlg_profile(struct dlg_profile_link *linker, struct dlg_cell *dlg)
{
struct dlg_entry *d_entry;
/* add the linker to the dialog */
/* FIXME zero h_id is not 100% for testing if the dialog is inserted
* into the hash table -> we need circular lists -bogdan */
if (dlg->h_id) {
d_entry = &d_table->entries[dlg->h_entry];
dlg_lock( d_table, d_entry);
linker->next = dlg->profile_links;
dlg->profile_links =linker;
linker->hash_linker.dlg = dlg;
dlg_unlock( d_table, d_entry);
} else {
linker->next = dlg->profile_links;
dlg->profile_links =linker;
linker->hash_linker.dlg = dlg;
}
atomic_or_int((volatile int*)&dlg->dflags, DLG_FLAG_CHANGED_PROF);
link_profile(linker, &dlg->callid);
}
开发者ID:TheGrandWazoo,项目名称:kamailio,代码行数:28,代码来源:dlg_profile.c
示例20: dlg_replicated_update
/**
* replicates the remote update of an ongoing dialog locally
* by reading the relevant information using the Binary Packet Interface
*/
int dlg_replicated_update(void)
{
struct dlg_cell *dlg;
str call_id, from_tag, to_tag, from_uri, to_uri, vars, profiles;
unsigned int dir, dst_leg;
int timeout, h_entry;
str st;
struct dlg_entry *d_entry;
bin_pop_str(&call_id);
bin_pop_str(&from_tag);
bin_pop_str(&to_tag);
bin_pop_str(&from_uri);
bin_pop_str(&to_uri);
LM_DBG("replicated update for ['%.*s' '%.*s' '%.*s' '%.*s' '%.*s']\n",
call_id.len, call_id.s, from_tag.len, from_tag.s, to_tag.len, to_tag.s,
from_uri.len, from_uri.s, to_uri.len, to_uri.s);
dlg = get_dlg(&call_id, &from_tag, &to_tag, &dir, &dst_leg);
h_entry = dlg_hash(&call_id);
d_entry = &d_table->entries[h_entry];
dlg_lock(d_table, d_entry);
if (!dlg) {
/* TODO: change to LM_DBG */
LM_ERR("dialog not found, building new\n");
dlg = build_new_dlg(&call_id, &from_uri, &to_uri, &from_tag);
if (!dlg) {
LM_ERR("Failed to create replicated dialog!\n");
goto error;
}
return dlg_replicated_create(dlg, &from_tag, &to_tag, 0);
}
bin_skip_int(2);
bin_pop_int(&dlg->state);
bin_skip_str(2);
bin_pop_str(&st);
if (dlg_update_cseq(dlg, DLG_CALLER_LEG, &st, 0) != 0) {
LM_ERR("failed to update caller cseq\n");
goto error;
}
bin_pop_str(&st);
if (dlg_update_cseq(dlg, callee_idx(dlg), &st, 0) != 0) {
LM_ERR("failed to update callee cseq\n");
goto error;
}
bin_skip_str(6);
bin_pop_str(&vars);
bin_pop_str(&profiles);
bin_pop_int(&dlg->user_flags);
bin_pop_int(&dlg->flags);
bin_pop_int(&timeout);
bin_skip_int(2);
timeout -= time(0);
LM_DBG("Received updated timeout of %d for dialog %.*s\n",timeout,call_id.len,call_id.s);
if (dlg->lifetime != timeout) {
dlg->lifetime = timeout;
if (update_dlg_timer(&dlg->tl, dlg->lifetime) == -1)
LM_ERR("failed to update dialog lifetime!\n");
}
unref_dlg_unsafe(dlg, 1, d_entry);
if (vars.s && vars.len != 0)
read_dialog_vars(vars.s, vars.len, dlg);
dlg_unlock(d_table, d_entry);
if (profiles.s && profiles.len != 0)
read_dialog_profiles(profiles.s, profiles.len, dlg, 1, 1);
return 0;
error:
dlg_unlock(d_table, d_entry);
return -1;
}
开发者ID:austin98x,项目名称:opensips,代码行数:94,代码来源:dlg_replication.c
注:本文中的dlg_unlock函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论