本文整理汇总了C++中shm_free函数的典型用法代码示例。如果您正苦于以下问题:C++ shm_free函数的具体用法?C++ shm_free怎么用?C++ shm_free使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了shm_free函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: vq_free_call_id
void
vq_free_call_id (queueID_t *call)
{
shm_free (call);
}
开发者ID:BackupTheBerlios,项目名称:openimscore-svn,代码行数:5,代码来源:vq_queueid.c
示例2: mem_copy_subs
subs_t* mem_copy_subs(subs_t* s, int mem_type)
{
int size;
subs_t* dest;
size= sizeof(subs_t)+ (s->pres_uri.len+ s->to_user.len
+ s->to_domain.len+ s->from_user.len+ s->from_domain.len+ s->callid.len
+ s->to_tag.len+ s->from_tag.len+s->sockinfo_str.len+s->event_id.len
+ s->local_contact.len+ s->contact.len+ s->record_route.len
+ s->reason.len+ s->watcher_user.len+ s->watcher_domain.len
+ 1)*sizeof(char);
if(mem_type & PKG_MEM_TYPE)
dest= (subs_t*)pkg_malloc(size);
else
dest= (subs_t*)shm_malloc(size);
if(dest== NULL)
{
ERR_MEM((mem_type==PKG_MEM_TYPE)?PKG_MEM_STR:SHARE_MEM);
}
memset(dest, 0, size);
size= sizeof(subs_t);
CONT_COPY(dest, dest->pres_uri, s->pres_uri)
CONT_COPY(dest, dest->to_user, s->to_user)
CONT_COPY(dest, dest->to_domain, s->to_domain)
CONT_COPY(dest, dest->from_user, s->from_user)
CONT_COPY(dest, dest->from_domain, s->from_domain)
CONT_COPY(dest, dest->watcher_user, s->watcher_user)
CONT_COPY(dest, dest->watcher_domain, s->watcher_domain)
CONT_COPY(dest, dest->to_tag, s->to_tag)
CONT_COPY(dest, dest->from_tag, s->from_tag)
CONT_COPY(dest, dest->callid, s->callid)
CONT_COPY(dest, dest->sockinfo_str, s->sockinfo_str)
CONT_COPY(dest, dest->local_contact, s->local_contact)
CONT_COPY(dest, dest->contact, s->contact)
CONT_COPY(dest, dest->record_route, s->record_route)
if(s->event_id.s)
CONT_COPY(dest, dest->event_id, s->event_id)
if(s->reason.s)
CONT_COPY(dest, dest->reason, s->reason)
dest->event= s->event;
dest->local_cseq= s->local_cseq;
dest->remote_cseq= s->remote_cseq;
dest->status= s->status;
dest->version= s->version;
dest->send_on_cback= s->send_on_cback;
dest->expires= s->expires;
dest->db_flag= s->db_flag;
return dest;
error:
if(dest)
{
if(mem_type & PKG_MEM_TYPE)
pkg_free(dest);
else
shm_free(dest);
}
return NULL;
}
开发者ID:AlessioCasco,项目名称:kamailio,代码行数:64,代码来源:hash.c
示例3: free_ims_subscription_data
/**
* Deallocates memory used by a subscription.
* \note Must be called with the lock got to avoid races
* @param s - the ims_subscription to free
*/
void free_ims_subscription_data(ims_subscription *s) {
int i, j, k;
if (!s) return;
/* lock_get(s->lock); - must be called with the lock got */
for (i = 0; i < s->service_profiles_cnt; i++) {
for (j = 0; j < s->service_profiles[i].public_identities_cnt; j++) {
if (s->service_profiles[i].public_identities[j].public_identity.s)
shm_free(s->service_profiles[i].public_identities[j].public_identity.s);
if (s->service_profiles[i].public_identities[j].wildcarded_psi.s)
shm_free(s->service_profiles[i].public_identities[j].wildcarded_psi.s);
}
if (s->service_profiles[i].public_identities)
shm_free(s->service_profiles[i].public_identities);
for (j = 0; j < s->service_profiles[i].filter_criteria_cnt; j++) {
if (s->service_profiles[i].filter_criteria[j].trigger_point) {
for (k = 0; k < s->service_profiles[i].filter_criteria[j].trigger_point->spt_cnt; k++) {
switch (s->service_profiles[i].filter_criteria[j].trigger_point->spt[k].type) {
case IFC_REQUEST_URI:
if (s->service_profiles[i].filter_criteria[j].trigger_point->spt[k].request_uri.s)
shm_free(s->service_profiles[i].filter_criteria[j].trigger_point->spt[k].request_uri.s);
break;
case IFC_METHOD:
if (s->service_profiles[i].filter_criteria[j].trigger_point->spt[k].method.s)
shm_free(s->service_profiles[i].filter_criteria[j].trigger_point->spt[k].method.s);
break;
case IFC_SIP_HEADER:
if (s->service_profiles[i].filter_criteria[j].trigger_point->spt[k].sip_header.header.s)
shm_free(s->service_profiles[i].filter_criteria[j].trigger_point->spt[k].sip_header.header.s);
if (s->service_profiles[i].filter_criteria[j].trigger_point->spt[k].sip_header.content.s)
shm_free(s->service_profiles[i].filter_criteria[j].trigger_point->spt[k].sip_header.content.s);
break;
case IFC_SESSION_CASE:
break;
case IFC_SESSION_DESC:
if (s->service_profiles[i].filter_criteria[j].trigger_point->spt[k].session_desc.line.s)
shm_free(s->service_profiles[i].filter_criteria[j].trigger_point->spt[k].session_desc.line.s);
if (s->service_profiles[i].filter_criteria[j].trigger_point->spt[k].session_desc.content.s)
shm_free(s->service_profiles[i].filter_criteria[j].trigger_point->spt[k].session_desc.content.s);
break;
}
}
if (s->service_profiles[i].filter_criteria[j].trigger_point->spt)
shm_free(s->service_profiles[i].filter_criteria[j].trigger_point->spt);
shm_free(s->service_profiles[i].filter_criteria[j].trigger_point);
}
if (s->service_profiles[i].filter_criteria[j].application_server.server_name.s)
shm_free(s->service_profiles[i].filter_criteria[j].application_server.server_name.s);
if (s->service_profiles[i].filter_criteria[j].application_server.service_info.s)
shm_free(s->service_profiles[i].filter_criteria[j].application_server.service_info.s);
if (s->service_profiles[i].filter_criteria[j].profile_part_indicator)
shm_free(s->service_profiles[i].filter_criteria[j].profile_part_indicator);
}
if (s->service_profiles[i].filter_criteria)
shm_free(s->service_profiles[i].filter_criteria);
if (s->service_profiles[i].cn_service_auth)
shm_free(s->service_profiles[i].cn_service_auth);
if (s->service_profiles[i].shared_ifc_set)
shm_free(s->service_profiles[i].shared_ifc_set);
}
if (s->service_profiles) shm_free(s->service_profiles);
if (s->private_identity.s) shm_free(s->private_identity.s);
// ul.unlock_subscription(s);
#ifdef EXTRA_DEBUG
LM_DBG("SUBSCRIPTION LOCK %p destroyed\n", s->lock);
#endif
lock_destroy(s->lock);
lock_dealloc(s->lock);
shm_free(s);
}
开发者ID:AndreiPlesa,项目名称:kamailio,代码行数:81,代码来源:impurecord.c
示例4: update_phtable
int update_phtable(presentity_t* presentity, str pres_uri, str body)
{
char* sphere= NULL;
unsigned int hash_code;
pres_entry_t* p;
int ret= 0;
str* xcap_doc= NULL;
/* get new sphere */
sphere= extract_sphere(body);
if(sphere==NULL)
{
LM_DBG("no sphere defined in new body\n");
return 0;
}
/* search for record in hash table */
hash_code= core_case_hash(&pres_uri, NULL, phtable_size);
lock_get(&pres_htable[hash_code].lock);
p= search_phtable(&pres_uri, presentity->event->evp->type, hash_code);
if(p== NULL)
{
lock_release(&pres_htable[hash_code].lock);
goto done;
}
if(p->sphere)
{
if(strcmp(p->sphere, sphere)!= 0)
{
/* new sphere definition */
shm_free(p->sphere);
}
else
{
/* no change in sphere definition */
lock_release(&pres_htable[hash_code].lock);
pkg_free(sphere);
return 0;
}
}
p->sphere= (char*)shm_malloc((strlen(sphere)+ 1)*sizeof(char));
if(p->sphere== NULL)
{
lock_release(&pres_htable[hash_code].lock);
ret= -1;
goto done;
}
strcpy(p->sphere, sphere);
lock_release(&pres_htable[hash_code].lock);
/* call for watchers status update */
if(presentity->event->get_rules_doc(&presentity->user, &presentity->domain,
&xcap_doc)< 0)
{
LM_ERR("failed to retrieve xcap document\n");
ret= -1;
goto done;
}
update_watchers_status(pres_uri, presentity->event, xcap_doc);
done:
if(xcap_doc)
{
if(xcap_doc->s)
pkg_free(xcap_doc->s);
pkg_free(xcap_doc);
}
if(sphere)
pkg_free(sphere);
return ret;
}
开发者ID:kelchy,项目名称:kamailio,代码行数:83,代码来源:hash.c
示例5: xmlrpc_free
static void xmlrpc_free(evi_reply_sock *sock)
{
/* nothing special here */
shm_free(sock);
}
开发者ID:lemenkov,项目名称:opensips,代码行数:5,代码来源:event_xmlrpc.c
示例6: b2bl_insert_new
//.........这里部分代码省略.........
tuple->scenario_params[i].s = (char*)shm_malloc(args[i]->len);
if(tuple->scenario_params[i].s == NULL)
{
LM_ERR("No more shared memory\n");
goto error;
}
memcpy(tuple->scenario_params[i].s, args[i]->s, args[i]->len);
tuple->scenario_params[i].len = args[i]->len;
}
}
}
tuple->scenario_state = B2B_NOTDEF_STATE;
lock_get(&b2bl_htable[hash_index].lock);
if(local_index>= 0) /* a local index specified */
{
tuple->id = local_index;
if(b2bl_htable[hash_index].first == NULL)
{
b2bl_htable[hash_index].first = tuple;
tuple->prev = tuple->next = NULL;
}
else
{
prev_it = 0;
/*insert it in the proper place */
for(it = b2bl_htable[hash_index].first; it && it->id<local_index; it=it->next)
{
prev_it = it;
}
if(!prev_it)
{
b2bl_htable[hash_index].first = tuple;
tuple->prev = 0;
tuple->next = it;
it->prev = tuple;
}
else
{
tuple->prev = prev_it;
prev_it->next = tuple;
tuple->next = it;
if(it)
it->prev = tuple;
}
}
}
else
{
it = b2bl_htable[hash_index].first;
if(it == NULL)
{
b2bl_htable[hash_index].first = tuple;
tuple->prev = tuple->next = NULL;
tuple->id = 0;
}
else
{
while(it)
{
prev_it = it;
it = it->next;
}
prev_it->next = tuple;
tuple->prev = prev_it;
tuple->id = prev_it->id +1;
}
}
LM_DBG("hash index [%d]:\n", hash_index);
for(it = b2bl_htable[hash_index].first; it; it=it->next)
{
LM_DBG("id [%d]", it->id);
}
b2bl_key = b2bl_generate_key(hash_index, tuple->id);
if(b2bl_key == NULL)
{
LM_ERR("failed to generate b2b logic key\n");
goto error;
}
tuple->key = b2bl_key;
*b2bl_key_s = b2bl_key;
tuple->db_flag = db_flag;
LM_DBG("new tuple [%p]->[%.*s]\n", tuple, b2bl_key->len, b2bl_key->s);
return tuple;
error:
if (tuple) {
if (tuple->sdp.s)
shm_free(tuple->sdp.s);
shm_free(tuple);
}
lock_release(&b2bl_htable[hash_index].lock);
return 0;
}
开发者ID:Parantido,项目名称:opensips,代码行数:101,代码来源:records.c
示例7: uac_reg_free_ht
int uac_reg_free_ht(void)
{
int i;
reg_item_t *it = NULL;
reg_item_t *it0 = NULL;
if(_reg_htable_gc_lock != NULL)
{
lock_destroy(_reg_htable_gc_lock);
shm_free((void*)_reg_htable_gc_lock);
_reg_htable_gc_lock = NULL;
}
if(_reg_htable_gc!=NULL)
{
for(i=0; i<_reg_htable_gc->htsize; i++)
{
it = _reg_htable_gc->entries[i].byuuid;
while(it)
{
it0 = it;
it = it->next;
shm_free(it0);
}
it = _reg_htable_gc->entries[i].byuser;
while(it)
{
it0 = it;
it = it->next;
shm_free(it0->r);
shm_free(it0);
}
}
shm_free(_reg_htable_gc->entries);
shm_free(_reg_htable_gc);
_reg_htable_gc = NULL;
}
if(_reg_htable==NULL)
{
LM_DBG("no hash table\n");
return -1;
}
for(i=0; i<_reg_htable->htsize; i++)
{
lock_get(&_reg_htable->entries[i].lock);
/* free entries */
it = _reg_htable->entries[i].byuuid;
while(it)
{
it0 = it;
it = it->next;
shm_free(it0);
}
it = _reg_htable->entries[i].byuser;
while(it)
{
it0 = it;
it = it->next;
shm_free(it0->r);
shm_free(it0);
}
lock_destroy(&_reg_htable->entries[i].lock);
}
shm_free(_reg_htable->entries);
shm_free(_reg_htable);
_reg_htable = NULL;
return 0;
}
开发者ID:WilliamRen,项目名称:kamailio,代码行数:68,代码来源:uac_reg.c
示例8: uac_reg_tm_callback
//.........这里部分代码省略.........
LM_ERR("failed to parse auth hdr body\n");
goto error;
}
if (ri->realm.len>0) {
/* only check if realms match if it is non-empty */
if(auth.realm.len!=ri->realm.len
|| strncmp(auth.realm.s, ri->realm.s, ri->realm.len)!=0)
{
LM_ERR("realms do not match. requested realm: [%.*s]\n",
auth.realm.len, auth.realm.s);
goto error;
}
}
cred.realm = auth.realm;
cred.user = ri->auth_username;
cred.passwd = ri->auth_password;
cred.next = NULL;
snprintf(b_ruri, MAX_URI_SIZE, "sip:%.*s",
ri->r_domain.len, ri->r_domain.s);
s_ruri.s = b_ruri; s_ruri.len = strlen(s_ruri.s);
do_uac_auth(&method, &s_ruri, &cred, &auth, response);
new_auth_hdr=build_authorization_hdr(ps->code, &s_ruri, &cred,
&auth, response);
if (new_auth_hdr==0)
{
LM_ERR("failed to build authorization hdr\n");
goto error;
}
#ifdef UAC_OLD_AUTH
snprintf(b_turi, MAX_URI_SIZE, "sip:%.*[email protected]%.*s",
ri->r_username.len, ri->r_username.s,
ri->r_domain.len, ri->r_domain.s);
s_turi.s = b_turi; s_turi.len = strlen(s_turi.s);
#endif
snprintf(b_hdrs, MAX_UACH_SIZE,
"Contact: <sip:%.*[email protected]%.*s>\r\n"
"Expires: %d\r\n"
"%.*s",
ri->l_uuid.len, ri->l_uuid.s,
reg_contact_addr.len, reg_contact_addr.s,
ri->expires,
new_auth_hdr->len, new_auth_hdr->s);
s_hdrs.s = b_hdrs; s_hdrs.len = strlen(s_hdrs.s);
pkg_free(new_auth_hdr->s);
memset(&uac_r, 0, sizeof(uac_r));
if(uac_reg_tmdlg(&tmdlg, ps->rpl)<0)
{
LM_ERR("failed to build tm dialog\n");
goto error;
}
tmdlg.rem_target = s_ruri;
if(ri->auth_proxy.len)
tmdlg.dst_uri = ri->auth_proxy;
uac_r.method = &method;
uac_r.headers = &s_hdrs;
uac_r.dialog = &tmdlg;
uac_r.cb_flags = TMCB_LOCAL_COMPLETED;
/* Callback function */
uac_r.cb = uac_reg_tm_callback;
/* Callback parameter */
uac_r.cbp = (void*)uuid;
#ifdef UAC_OLD_AUTH
ret = uac_tmb.t_request(&uac_r, /* UAC Req */
&s_ruri, /* Request-URI */
&s_turi, /* To */
&s_turi, /* From */
(ri->auth_proxy.len)?&ri->auth_proxy:NULL /* outbound uri */
);
#endif
ret = uac_tmb.t_request_within(&uac_r);
if(ret<0) {
LM_ERR("failed to send request with authentication for [%.*s]",
ri->l_uuid.len, ri->l_uuid.s);
goto error;
}
ri->flags |= UAC_REG_AUTHSENT;
return;
} else
{
LM_ERR("got sip response %d while registering [%.*s]\n",
ps->code, ri->l_uuid.len, ri->l_uuid.s);
goto error;
}
error:
if(reg_retry_interval)
ri->timer_expires = time(NULL) + reg_retry_interval;
else
ri->flags |= UAC_REG_DISABLED;
done:
if(ri)
ri->flags &= ~(UAC_REG_ONGOING|UAC_REG_AUTHSENT);
shm_free(uuid);
}
开发者ID:WilliamRen,项目名称:kamailio,代码行数:101,代码来源:uac_reg.c
示例9: update_pua
int update_pua(ua_pres_t* p)
{
str* str_hdr= NULL;
int expires;
int result;
uac_req_t uac_r;
int ret_code = 0;
dlg_t* td = NULL;
if(p->desired_expires== 0)
expires= 3600;
else
expires= p->desired_expires- (int)time(NULL);
if(p->watcher_uri == NULL || p->watcher_uri->len == 0)
{
str met= {"PUBLISH", 7};
ua_pres_t* cb_param;
str_hdr = publ_build_hdr(expires, get_event(p->event), NULL,
&p->etag, p->extra_headers, 0);
if(str_hdr == NULL)
{
LM_ERR("while building extra_headers\n");
ret_code = -1;
goto done;
}
LM_DBG("str_hdr:\n%.*s\n ", str_hdr->len, str_hdr->s);
cb_param= build_uppubl_cbparam(p);
if(cb_param== NULL)
{
LM_ERR("while constructing publ callback param\n");
ret_code = -1;
goto done;
}
set_uac_req(&uac_r, &met, str_hdr, 0, 0, TMCB_LOCAL_COMPLETED,
publ_cback_func, (void*)cb_param);
result= tmb.t_request(&uac_r,
p->pres_uri, /* Request-URI */
p->pres_uri, /* To */
p->pres_uri, /* From */
&outbound_proxy /* Outbound proxy*/
);
if(result< 0)
{
LM_ERR("in t_request function\n");
shm_free(cb_param);
ret_code = -1;
goto done;
}
}
else
{
str met= {"SUBSCRIBE", 9};
ua_pres_t* cb_param= NULL;
td= pua_build_dlg_t(p);
if(td== NULL)
{
LM_ERR("while building tm dlg_t structure");
ret_code = -1;
goto done;
};
str_hdr= subs_build_hdr(&p->contact, expires,p->event,p->extra_headers);
if(str_hdr== NULL || str_hdr->s== NULL)
{
if(p->event!=0)
LM_ERR("while building extra headers\n");
ret_code = -1;
goto done;
}
cb_param= subs_cbparam_indlg(p, expires, REQ_ME);
if(cb_param== NULL)
{
LM_ERR("while constructing subs callback param\n");
ret_code = -1;
goto done;
}
set_uac_req(&uac_r, &met, str_hdr, 0, td, TMCB_LOCAL_COMPLETED,
subs_cback_func, (void*)cb_param);
result= tmb.t_request_within(&uac_r);
if(result< 0)
{
LM_ERR("in t_request function\n");
shm_free(cb_param);
ret_code = -1;
goto done;
}
}
done:
if(td!=NULL)
{
if(td->route_set)
free_rr(&td->route_set);
pkg_free(td);
//.........这里部分代码省略.........
开发者ID:GreenfieldTech,项目名称:kamailio,代码行数:101,代码来源:pua.c
示例10: uac_reg_init_ht
int uac_reg_init_ht(unsigned int sz)
{
int i;
_reg_htable_gc_lock = (gen_lock_t*)shm_malloc(sizeof(gen_lock_t));
if(_reg_htable_gc_lock == NULL)
{
LM_ERR("no more shm for lock\n");
return -1;
}
if(lock_init(_reg_htable_gc_lock)==0)
{
LM_ERR("cannot init global lock\n");
shm_free((void*)_reg_htable_gc_lock);
return -1;
}
_reg_htable_gc = (reg_ht_t*)shm_malloc(sizeof(reg_ht_t));
if(_reg_htable_gc==NULL)
{
LM_ERR("no more shm\n");
lock_destroy(_reg_htable_gc_lock);
shm_free((void*)_reg_htable_gc_lock);
return -1;
}
memset(_reg_htable_gc, 0, sizeof(reg_ht_t));
_reg_htable_gc->htsize = sz;
_reg_htable_gc->entries =
(reg_entry_t*)shm_malloc(_reg_htable_gc->htsize*sizeof(reg_entry_t));
if(_reg_htable_gc->entries==NULL)
{
LM_ERR("no more shm.\n");
shm_free(_reg_htable_gc);
lock_destroy(_reg_htable_gc_lock);
shm_free((void*)_reg_htable_gc_lock);
return -1;
}
memset(_reg_htable_gc->entries, 0, _reg_htable_gc->htsize*sizeof(reg_entry_t));
_reg_htable = (reg_ht_t*)shm_malloc(sizeof(reg_ht_t));
if(_reg_htable==NULL)
{
LM_ERR("no more shm\n");
shm_free(_reg_htable_gc->entries);
shm_free(_reg_htable_gc);
lock_destroy(_reg_htable_gc_lock);
shm_free((void*)_reg_htable_gc_lock);
return -1;
}
memset(_reg_htable, 0, sizeof(reg_ht_t));
_reg_htable->htsize = sz;
_reg_htable->entries =
(reg_entry_t*)shm_malloc(_reg_htable->htsize*sizeof(reg_entry_t));
if(_reg_htable->entries==NULL)
{
LM_ERR("no more shm.\n");
shm_free(_reg_htable_gc->entries);
shm_free(_reg_htable_gc);
shm_free(_reg_htable);
lock_destroy(_reg_htable_gc_lock);
shm_free((void*)_reg_htable_gc_lock);
return -1;
}
memset(_reg_htable->entries, 0, _reg_htable->htsize*sizeof(reg_entry_t));
for(i=0; i<_reg_htable->htsize; i++)
{
if(lock_init(&_reg_htable->entries[i].lock)==0)
{
LM_ERR("cannot initalize lock[%d] n", i);
i--;
while(i>=0)
{
lock_destroy(&_reg_htable->entries[i].lock);
i--;
}
shm_free(_reg_htable->entries);
shm_free(_reg_htable);
shm_free(_reg_htable_gc->entries);
shm_free(_reg_htable_gc);
lock_destroy(_reg_htable_gc_lock);
shm_free((void*)_reg_htable_gc_lock);
return -1;
}
}
return 0;
}
开发者ID:WilliamRen,项目名称:kamailio,代码行数:89,代码来源:uac_reg.c
示例11: db_restore
//.........这里部分代码省略.........
memcpy(p->to_tag.s, to_tag.s, to_tag.len);
p->to_tag.len= to_tag.len;
size+= to_tag.len;
p->from_tag.s= (char*)p+ size;
memcpy(p->from_tag.s, from_tag.s, from_tag.len);
p->from_tag.len= from_tag.len;
size+= from_tag.len;
p->call_id.s= (char*)p + size;
memcpy(p->call_id.s, call_id.s, call_id.len);
p->call_id.len= call_id.len;
size+= call_id.len;
if(record_route.s && record_route.len)
{
p->record_route.s= (char*)p + size;
memcpy(p->record_route.s, record_route.s, record_route.len);
p->record_route.len= record_route.len;
size+= record_route.len;
}
p->contact.s= (char*)p + size;
memcpy(p->contact.s, contact.s, contact.len);
p->contact.len= contact.len;
size+= contact.len;
p->cseq= row_vals[cseq_col].val.int_val;
p->remote_contact.s= (char*)shm_malloc(remote_contact.len* sizeof(char));
if(p->remote_contact.s== NULL)
{
LM_ERR("No more shared memory\n");
goto error;
}
memcpy(p->remote_contact.s, remote_contact.s, remote_contact.len);
p->remote_contact.len= remote_contact.len;
p->version= row_vals[version_col].val.int_val;
}
if(extra_headers.s)
{
p->extra_headers= (str*)((char*)p+ size);
size+= sizeof(str);
p->extra_headers->s= (char*)p+ size;
memcpy(p->extra_headers->s, extra_headers.s, extra_headers.len);
p->extra_headers->len= extra_headers.len;
size+= extra_headers.len;
}
LM_DBG("size= %d\n", size);
p->event= row_vals[event_col].val.int_val;
p->expires= row_vals[expires_col].val.int_val;
p->desired_expires= row_vals[desired_expires_col].val.int_val;
p->flag|= row_vals[flag_col].val.int_val;
memset(&p->etag, 0, sizeof(str));
if(etag.s && etag.len)
{
/* alloc separately */
p->etag.s= (char*)shm_malloc(etag.len* sizeof(char));
if(p->etag.s== NULL)
{
LM_ERR("no more share memory\n");
goto error;
}
memcpy(p->etag.s, etag.s, etag.len);
p->etag.len= etag.len;
}
print_ua_pres(p);
hash_code= core_hash(p->pres_uri, p->watcher_uri, HASH_SIZE);
lock_get(&HashT->p_records[hash_code].lock);
insert_htable(p, hash_code);
lock_release(&HashT->p_records[hash_code].lock);
}
} while((db_fetch_next(&pua_dbf, pua_fetch_rows, pua_db, &res)==1)
&& (RES_ROW_N(res)>0));
pua_dbf.free_result(pua_db, res);
res = NULL;
if(pua_dbf.delete(pua_db, 0, 0 , 0, 0) < 0)
{
LM_ERR("while deleting information from db\n");
goto error;
}
return 0;
error:
if(res)
pua_dbf.free_result(pua_db, res);
if(p)
shm_free(p);
return -1;
}
开发者ID:GreenfieldTech,项目名称:kamailio,代码行数:101,代码来源:pua.c
示例12: write_log
static inline void write_log( struct cpl_cmd *cmd)
{
struct iovec wr_vec[5];
time_t now;
char *time_ptr;
int fd;
int ret;
/* build file name (cmd->s1 is the user name)*/
if (cmd->s1.len>MAX_LOG_FILE_NAME)
cmd->s1.len = MAX_LOG_FILE_NAME;
memcpy(file_ptr, cmd->s1.s, cmd->s1.len );
memcpy(file_ptr+cmd->s1.len,FILE_NAME_SUFIX,FILE_NAME_SUFIX_LEN);
file_ptr[cmd->s1.len+FILE_NAME_SUFIX_LEN] = 0;
/* get current date+time -> wr_vec[0] */
time( &now );
time_ptr = ctime( &now );
wr_vec[0].iov_base = time_ptr;
wr_vec[0].iov_len = strlen( time_ptr );
/* ctime_r adds a \n at the end -> overwrite it with space */
time_ptr[ wr_vec[0].iov_len-1 ] = ' ';
/* log name (cmd->s2) -> wr_vec[1] */
if (cmd->s2.s==0 || cmd->s2.len==0) {
wr_vec[1].iov_base = DEFAULT_LOG_NAME;
wr_vec[1].iov_len = DEFAULT_LOG_NAME_LEN;
} else {
wr_vec[1].iov_base = cmd->s2.s;
wr_vec[1].iov_len = cmd->s2.len;
}
/* log separator -> wr_vec[2] */
wr_vec[2].iov_base = LOG_SEPARATOR;
wr_vec[2].iov_len = LOG_SEPARATOR_LEN;
/* log comment (cmd->s3) -> wr_vec[3] */
wr_vec[3].iov_base = cmd->s3.s;
wr_vec[3].iov_len = cmd->s3.len;
/* log terminator -> wr_vec[2] */
wr_vec[4].iov_base = LOG_TERMINATOR;
wr_vec[4].iov_len = LOG_TERMINATOR_LEN;
/* [create+]open the file */
fd = open( file, O_CREAT|O_APPEND|O_WRONLY, 0664);
if (fd==-1) {
LOG(L_ERR,"ERROR:cpl_c:write_log: cannot open file [%s] : %s\n",
file, strerror(errno) );
return;
}
/* get the log */
DBG("DEBUG:cpl_c:write_log: logging into [%s]... \n",file);
/* I'm really not interested in the return code for write ;-) */
while ( (ret=writev( fd, wr_vec, 5))==-1 ) {
if (errno==EINTR)
continue;
LOG(L_ERR,"ERROR:cpl_c:write_log: writing to log file [%s] : %s\n",
file, strerror(errno) );
}
close (fd);
shm_free( cmd->s1.s );
}
开发者ID:BackupTheBerlios,项目名称:ser,代码行数:64,代码来源:cpl_nonsig.c
示例13: send_mail
static inline void send_mail( struct cpl_cmd *cmd)
{
char *argv[5];
int pfd[2];
pid_t pid;
int i;
if (pipe(pfd) < 0) {
LOG(L_ERR,"ERROR:cpl_c:send_mail: pipe failed: %s\n",strerror(errno));
return;
}
/* even if I haven't fork yet, I push the date on the pipe just to get
* rid of one more malloc + copy */
if (cmd->s3.len && cmd->s3.s) {
if ( (i=write( pfd[1], cmd->s3.s, cmd->s3.len ))!=cmd->s3.len ) {
LOG(L_ERR,"ERROR:cpl_c:send_mail: write returned error %s\n",
strerror(errno));
goto error;
}
}
if ( (pid = fork()) < 0) {
LOG(L_ERR,"ERROR:cpl_c:send_mail: fork failed: %s\n",strerror(errno));
goto error;
} else if (pid==0) {
/* child -> close all descriptors excepting pfd[0] */
for (i=3; i < MAX_FD; i++)
if (i!=pfd[0])
close(i);
if (pfd[0] != STDIN_FILENO) {
dup2(pfd[0], STDIN_FILENO);
close(pfd[0]);
}
/* set the argument vector*/
argv[0] = "mail";
argv[1] = "-s";
if (cmd->s2.s && cmd->s2.len) {
/* put the subject in this format : <"$subject"\0> */
if ( (argv[2]=(char*)pkg_malloc(1+cmd->s2.len+1+1))==0) {
LOG(L_ERR,"ERROR:cpl_c:send_mail: cannot get pkg memory\n");
goto child_exit;
}
argv[2][0] = '\"';
memcpy(argv[2]+1,cmd->s2.s,cmd->s2.len);
argv[2][cmd->s2.len+1] = '\"';
argv[2][cmd->s2.len+2] = 0;
} else {
argv[2] = "\"[CPL notification]\"";
}
/* put the TO in <$to\0> format*/
if ( (argv[3]=(char*)pkg_malloc(cmd->s1.len+1))==0) {
LOG(L_ERR,"ERROR:cpl_c:send_mail: cannot get pkg memory\n");
goto child_exit;
}
memcpy(argv[3],cmd->s1.s,cmd->s1.len);
argv[3][cmd->s1.len] = 0;
/* last element in vector mist be a null pointer */
argv[4] = (char*)0;
/* just debug */
for(i=0;i<sizeof(argv)/sizeof(char*);i++)
DBG(" argv[%d] = %s\n",i,argv[i]);
/* once I copy localy all the data from shm mem -> free the shm */
shm_free( cmd->s1.s );
/* set an alarm -> sending the email shouldn't take more than 10 sec */
alarm(10);
/* run the external mailer */
DBG("DEBUG:cpl_c:send_mail: new forked process created -> "
"doing execv..\n");
execv("/usr/bin/mail",argv);
/* if we got here means execv exit with error :-( */
LOG(L_ERR,"ERROR:cpl_c:send_mail: execv failed! (%s)\n",
strerror(errno));
child_exit:
_exit(127);
}
/* parent -> close both ends of pipe */
close(pfd[0]);
close(pfd[1]);
return;
error:
shm_free( cmd->s1.s );
close(pfd[0]);
close(pfd[1]);
return;
}
开发者ID:BackupTheBerlios,项目名称:ser,代码行数:89,代码来源:cpl_nonsig.c
示例14: mod_init
int mod_init (void)
{
/**********
* o allocate shared mem and init
* o init configuration data
* o init DB
**********/
pmod_data = (mod_data *) shm_malloc (sizeof (mod_data));
if (!pmod_data)
{
LM_ERR ("Unable to allocate shared memory");
return -1;
}
memset (pmod_data, 0, sizeof (mod_data));
if (!init_cfg ())
{ goto initerr; }
if (!init_db ())
{ goto initerr; }
/**********
* o bind to SL/TM/RR modules
* o bind to RTPPROXY functions
**********/
if (sl_load_api (pmod_data->psl))
{
LM_ERR ("Unable to load SL module\n");
goto initerr;
}
if (load_tm_api (pmod_data->ptm))
{
LM_ERR ("Unable to load TM module\n");
goto initerr;
}
if (load_rr_api (pmod_data->prr))
{
LM_ERR ("Unable to load RR module\n");
goto initerr;
}
pmod_data->fn_rtp_answer = find_export ("rtpproxy_answer", 0, 0);
if (!pmod_data->fn_rtp_answer)
{
LM_ERR ("Unable to load rtpproxy_answer\n");
goto initerr;
}
pmod_data->fn_rtp_offer = find_export ("rtpproxy_offer", 0, 0);
if (!pmod_data->fn_rtp_offer)
{
LM_ERR ("Unable to load rtpproxy_offer\n");
goto initerr;
}
pmod_data->fn_rtp_stream_c = find_export ("rtpproxy_stream2uac", 2, 0);
if (!pmod_data->fn_rtp_stream_c)
{
LM_ERR ("Unable to load rtpproxy_stream2uac\n");
goto initerr;
}
pmod_data->fn_rtp_stream_s = find_export ("rtpproxy_stream2uas", 2, 0);
if (!pmod_data->fn_rtp_stream_s)
{
LM_ERR ("Unable to load rtpproxy_stream2uas\n");
goto initerr;
}
pmod_data->fn_rtp_destroy = find_export ("rtpproxy_destroy", 0, 0);
if (!pmod_data->fn_rtp_destroy)
{
LM_ERR ("Unable to load rtpproxy_destroy\n");
goto initerr;
}
/**********
* init MOH and call queue locks
**********/
if (!mohq_lock_init (pmod_data->pmohq_lock))
{ goto initerr; }
if (!mohq_lock_init (pmod_data->pcall_lock))
{ goto initerr; }
return 0;
/**********
* o release shared mem
* o exit with error
**********/
initerr:
if (pmod_data->mohq_cnt)
{ shm_free (pmod_data->pmohq_lst); }
if (pmod_data->pcall_lock->plock)
{ mohq_lock_destroy (pmod_data->pcall_lock); }
shm_free (pmod_data);
pmod_data = NULL;
return -1;
}
开发者ID:apogrebennyk,项目名称:kamailio,代码行数:96,代码来源:mohq.c
示例15: uac_reg_update
int uac_reg_update(reg_uac_t *reg, time_t tn)
{
char *uuid;
uac_req_t uac_r;
str method = {"REGISTER", 8};
int ret;
char b_ruri[MAX_URI_SIZE];
str s_ruri;
char b_turi[MAX_URI_SIZE];
str s_turi;
char b_hdrs[MAX_UACH_SIZE];
str s_hdrs;
if(uac_tmb.t_request==NULL)
return -1;
if(reg->expires==0)
return 1;
if(reg->flags&UAC_REG_ONGOING)
return 2;
if(reg->flags&UAC_REG_DISABLED)
return 4;
if(reg->timer_expires > tn + reg_timer_interval + 3)
return 3;
reg->timer_expires = tn;
reg->flags |= UAC_REG_ONGOING;
reg->flags &= ~UAC_REG_ONLINE;
uuid = (char*)shm_malloc(reg->l_uuid.len+1);
if(uuid==NULL)
{
LM_ERR("no more shm\n");
return -1;
}
memcpy(uuid, reg->l_uuid.s, reg->l_uuid.len);
uuid[reg->l_uuid.len] = '\0';
snprintf(b_ruri, MAX_URI_SIZE, "sip:%.*s",
reg->r_domain.len, reg->r_domain.s);
s_ruri.s = b_ruri; s_ruri.len = strlen(s_ruri.s);
snprintf(b_turi, MAX_URI_SIZE, "sip:%.*[email protected]%.*s",
reg->r_username.len, reg->r_username.s,
reg->r_domain.len, reg->r_domain.s);
s_turi.s = b_turi; s_turi.len = strlen(s_turi.s);
snprintf(b_hdrs, MAX_UACH_SIZE,
"Contact: <sip:%.*[email protected]%.*s>\r\n"
"Expires: %d\r\n",
reg->l_uuid.len, reg->l_uuid.s,
reg_contact_addr.len, reg_contact_addr.s,
reg->expires);
s_hdrs.s = b_hdrs; s_hdrs.len = strlen(s_hdrs.s);
memset(&uac_r, '\0', sizeof(uac_r));
uac_r.method = &method;
uac_r.headers = &s_hdrs;
uac_r.cb_flags = TMCB_LOCAL_COMPLETED;
/* Callback function */
uac_r.cb = uac_reg_tm_callback;
/* Callback parameter */
uac_r.cbp = (void*)uuid;
ret = uac_tmb.t_request(&uac_r, /* UAC Req */
&s_ruri, /* Request-URI */
&s_turi, /* To */
&s_turi, /* From */
(reg->auth_proxy.len)?®->auth_proxy:NULL /* outbound uri */
);
if(ret<0)
{
LM_ERR("failed to send request for [%.*s]", reg->l_uuid.len, reg->l_uuid.s);
shm_free(uuid);
if (reg_retry_interval)
reg->timer_expires = (tn ? tn : time(NULL)) + reg_retry_interval;
else
reg->flags |= UAC_REG_DISABLED;
reg->flags &= ~UAC_REG_ONGOING;
return -1;
}
return 0;
}
开发者ID:WilliamRen,项目名称:kamailio,代码行数:80,代码来源:uac_reg.c
示例16: xmlrpc_parse
//.........这里部分代码省略.........
socket.len -= ((path.s+path.len)-socket.s);
socket.s = path.s+path.len;
}
/* will use this later for allocation */
http_buf_len=LENOF(XMLRPC_HTTP_METHOD) + path.len +
LENOF(XMLRPC_HTTP_PROTO_HOST);
}
/* jump over ':' */
socket.len = socket.len - (p - socket.s + 1);
socket.s = p + 1;
LM_DBG("port is %hu - remains <%.*s>[%d]\n",
port, socket.len, socket.s, socket.len);
if (socket.len <= 0 || *socket.s == '\0') {
LM_ERR("invalid method name\n");
return NULL;
}
len = sizeof(evi_reply_sock) + host.len
+ sizeof(struct xmlrpc_sock_param)
+ socket.len /* this is method */+ http_buf_len;
sock = shm_malloc(len);
if (!sock) {
LM_ERR("no more memory for socket\n");
return NULL;
}
memset(sock, 0, len);
/* only UDP has port */
sock->flags = EVI_PORT;
sock->port = port;
/* also build sockaddr */
hentity = resolvehost(host.s, 0);
if (!hentity) {
LM_ERR("cannot resolve host %s\n", host.s);
goto error;
}
if(hostent2su(&sock->src_addr.udp_addr, hentity, 0, port)){
LM_ERR("failed to resolve %s\n", host.s);
goto error;
}
sock->flags |= EVI_SOCKET;
/* address */
sock->address.s = (char*)(sock+1);
sock->address.len = host.len;
memcpy(sock->address.s, host.s, host.len);
sock->flags |= EVI_ADDRESS;
/* copy parameters: path and method */
params = (struct xmlrpc_sock_param*)(sock->address.s + host.len);
params->method.s = (char*)(params+1);
memcpy(params->method.s, socket.s, socket.len);
params->method.len = socket.len;
if (http_buf_len) {
/* build only once; not for every message */
params->first_line.s = (char*)(params->method.s+socket.len);
memcpy(params->method.s, socket.s, socket.len);
params->first_line.len = 0;
memcpy(params->first_line.s,
XMLRPC_HTTP_METHOD, LENOF(XMLRPC_HTTP_METHOD));
params->first_line.len = LENOF(XMLRPC_HTTP_METHOD);
memcpy(params->first_line.s+params->first_line.len, path.s, path.len);
params->first_line.len += path.len;
memcpy(params->first_line.s+params->first_line.len, XMLRPC_HTTP_PROTO_HOST,
LENOF(XMLRPC_HTTP_PROTO_HOST));
params->first_line.len += LENOF(XMLRPC_HTTP_PROTO_HOST);
} else {
params->first_line.s = XMLRPC_HTTP_CONST;
params->first_line.len = LENOF(XMLRPC_HTTP_CONST);
}
sock->flags |= EVI_PARAMS;
/* needs expire */
sock->flags |= EVI_EXPIRE|XMLRPC_FLAG;
sock->params= params;
return sock;
error:
if (sock)
shm_free(sock);
return NULL;
}
开发者ID:lemenkov,项目名称:opensips,代码行数:101,代码来源:event_xmlrpc.c
示例17: shm_free_x
void shm_free_x(void *ptr)
{
shm_free(ptr);
}
开发者ID:2pac,项目名称:kamailio,代码行数:4,代码来源:memory.c
示例18: b2bl_delete
void b2bl_delete(b2bl_tuple_t* tuple, unsigned int hash_index,
int not_del_b2be)
{
b2bl_entity_id_t *e;
int i;
int index;
b2bl_cb_params_t cb_params;
LM_DBG("Delete record [%p]->[%.*s], hash_index=[%d], local_index=[%d]\n",
tuple, tuple->key->len, tuple->key->s, hash_index, tuple->id);
/*
* razvanc: if the tuple is not actually deleted, we do not have to call
* the DESTROY callback
*/
if(!not_del_b2be && tuple->cbf && tuple->cb_mask&B2B_DESTROY_CB)
{
memset(&cb_params, 0, sizeof(b2bl_cb_params_t));
cb_params.param = tuple->cb_param;
cb_params.stat = NULL;
cb_params.msg = NULL;
/* setting it to 0 but it has no meaning in this callback type */
cb_params.entity = 0;
tuple->cbf(&cb_params, B2B_DESTROY_CB);
}
if(!not_del_b2be)
b2bl_db_delete(tuple);
if(b2bl_htable[hash_index].first == tuple)
{
b2bl_htable[hash_index].first = tuple->next;
if(tuple->next)
tuple->next->prev = NULL;
}
else
{
if(tuple->prev)
tuple->prev->next = tuple->next;
if(tuple->next)
tuple->next->prev = tuple->prev;
}
for (index = 0; index < MAX_B2BL_ENT; index++)
{
e = tuple->servers[index];
if (e)
{
if (e->key.s && e->key.len && !not_del_b2be)
b2b_api.entity_delete(e->type, &e->key, e->dlginfo, 0);
if(e->dlginfo)
shm_free(e->dlginfo);
shm_free(e);
}
e = tuple->clients[index];
if (e)
{
if (e->key.s && e->key.len && !not_del_b2be)
b2b_api.entity_delete(e->type, &e->key, e->dlginfo, 0);
if(e->dlginfo)
shm_free(e->dlginfo);
shm_free(e);
}
}
/* clean up all entities in b2b_entities from db */
if(!not_del_b2be)
b2b_api.entities_db_delete(*tuple->key);
// if(tuple->bridge_entities[1] && tuple->bridge_entities[1]->key.s != NULL)
// shm_free(tuple->bridge_entities[1]->key.s);
for(i = 0; i< MAX_SCENARIO_PARAMS; i++)
{
if(tuple->scenario_params[i].s)
shm_free(tuple->scenario_params[i].s);
}
if(tuple->key)
shm_free(tuple->key);
if(tuple->extra_headers)
shm_free(tuple->extra_headers);
if(tuple->b1_sdp.s)
shm_free(tuple->b1_sdp.s);
if (tuple->sdp.s && tuple->sdp.s != tuple->b1_sdp.s)
shm_free(tuple->sdp.s);
shm_free(tuple);
}
开发者ID:Parantido,项目名称:opensips,代码行数:89,代码来源:records.c
示例19: free_cpl_interpreter
void free_cpl_interpreter(struct cpl_interpreter *intr)
{
if (intr) {
empty_location_set( &(intr->loc_set) );
if (intr->script.s)
shm_free( intr->script.s);
if (intr->user.s)
shm_free(intr->user.s);
if (intr->flags&CPL_RURI_DUPLICATED)
shm_free(intr->ruri);
if (intr->flags&CPL_TO_DUPLICATED)
shm_free(intr->to);
if (intr->flags&CPL_FROM_DUPLICATED)
shm_free(intr->from);
if (intr->flags&CPL_SUBJECT_DUPLICATED)
shm_free(intr->subject);
if (intr->flags&CPL_ORGANIZATION_DUPLICATED)
shm_free(intr->organization);
if (intr->flags&CPL_USERAGENT_DUPLICATED)
shm_free(intr->user_agent);
if (intr->flags&CPL_ACCEPTLANG_DUPLICATED)
shm_free(intr->accept_language);
if (intr->flags&CPL_PRIORITY_DUPLICATED)
shm_free(intr->priority);
shm_free(intr);
}
}
开发者ID:BackupTheBerlios,项目名称:openimscore-svn,代码行数:27,代 |
请发表评论