本文整理汇总了C++中shm_lock函数的典型用法代码示例。如果您正苦于以下问题:C++ shm_lock函数的具体用法?C++ shm_lock怎么用?C++ shm_lock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了shm_lock函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: shm_event_raise
void shm_event_raise(long used, long size, long perc)
{
evi_params_p list = 0;
*event_shm_pending = 1;
*event_shm_last = perc;
// event has to be triggered - check for subscribers
if (!evi_probe_event(EVI_SHM_THRESHOLD_ID)) {
goto end;
}
if (!(list = evi_get_params()))
goto end;
if (evi_param_add_int(list, &shm_usage_str, (int *)&perc)) {
LM_ERR("unable to add usage parameter\n");
goto end;
}
if (evi_param_add_int(list, &shm_threshold_str, (int *)&event_shm_threshold)) {
LM_ERR("unable to add threshold parameter\n");
goto end;
}
if (evi_param_add_int(list, &shm_used_str, (int *)&used)) {
LM_ERR("unable to add used parameter\n");
goto end;
}
if (evi_param_add_int(list, &shm_size_str, (int *)&size)) {
LM_ERR("unable to add size parameter\n");
goto end;
}
/*
* event has to be raised without the lock otherwise a deadlock will be
* generated by the transport modules, or by the event_route processing
*/
#ifdef HP_MALLOC
shm_unlock(0);
#else
shm_unlock();
#endif
if (evi_raise_event(EVI_SHM_THRESHOLD_ID, list)) {
LM_ERR("unable to send shm threshold event\n");
}
#ifdef HP_MALLOC
shm_lock(0);
#else
shm_lock();
#endif
list = 0;
end:
if (list)
evi_free_params(list);
*event_shm_pending = 0;
}
开发者ID:AndreiPlesa,项目名称:opensips,代码行数:57,代码来源:shm_mem.c
示例2: qm_shm_info
void qm_shm_info(void* qmp, struct mem_info* info)
{
shm_lock();
qm_info(qmp, info);
shm_unlock();
}
开发者ID:neuhaus,项目名称:kamailio,代码行数:7,代码来源:q_malloc.c
示例3: while
bool
SHMSrc::resize_area()
{
while ((sizeof(SHMHeader) + shm_area_->buffer_size) > shm_area_len_) {
size_t new_size = sizeof(SHMHeader) + shm_area_->buffer_size;
shm_unlock();
if (munmap(shm_area_, shm_area_len_)) {
std::cerr << "Could not unmap shared area" << std::endl;
perror(strerror(errno));
return false;
}
shm_area_ = static_cast<SHMHeader*>(mmap(NULL, new_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd_, 0));
shm_area_len_ = new_size;
if (!shm_area_) {
shm_area_ = 0;
std::cerr << "Could not remap shared area" << std::endl;
return false;
}
shm_area_len_ = new_size;
shm_lock();
}
return true;
}
开发者ID:asadsalman,项目名称:ring-daemon,代码行数:27,代码来源:shm_src.cpp
示例4: shm_unlock
bool SHMSink::resize_area(size_t desired_length)
{
if (desired_length <= shm_area_len_)
return true;
shm_unlock();
if (munmap(shm_area_, shm_area_len_)) {
ERROR("Could not unmap shared area");
strErr();
return false;
}
if (ftruncate(fd_, desired_length)) {
ERROR("Could not resize shared area");
strErr();
return false;
}
shm_area_ = static_cast<SHMHeader*>(mmap(NULL, desired_length, PROT_READ | PROT_WRITE, MAP_SHARED, fd_, 0));
shm_area_len_ = desired_length;
if (shm_area_ == MAP_FAILED) {
shm_area_ = 0;
ERROR("Could not remap shared area");
return false;
}
shm_lock();
return true;
}
开发者ID:ThereIsNoYeti,项目名称:sflphone,代码行数:31,代码来源:shm_sink.cpp
示例5: qm_shm_free
void qm_shm_free(void* qmp, void* p, const char* file, const char* func,
unsigned int line)
{
shm_lock();
qm_free(qmp, p, file, func, line);
shm_unlock();
}
开发者ID:neuhaus,项目名称:kamailio,代码行数:7,代码来源:q_malloc.c
示例6: shm_callback
int shm_callback(int mode, struct kern_ipc_perm *ipc, struct ipc_namespace *ns)
{
switch(mode) {
case 0:
printf("key shmid owner perms bytes nattch status \n");
break;
case 1:
if(id==-1 || id==ipc->id) {
struct shmid_kernel *shp = shm_lock(ns, ipc->id);
printf("0x%08x %-10d %-10d %-10o %-10ld %-10ld %-6s %-6s\n",
ipc->key,
ipc->id,
ipc->uid,
ipc->mode & 0777,
shp->shm_segsz,
shp->shm_nattch,
ipc->mode & SHM_DEST ? "dest" : " ",
ipc->mode & SHM_LOCKED ? "locked" : " ");
}
break;
case 2:
break;
}
return 1;
}
开发者ID:lucchouina,项目名称:eppic,代码行数:26,代码来源:ipcs.c
示例7: shm_available_safe
unsigned long shm_available_safe()
{
unsigned long ret;
shm_lock();
ret = shm_available();
shm_unlock();
return ret;
}
开发者ID:AlessioCasco,项目名称:kamailio,代码行数:8,代码来源:shm_mem.c
示例8: qm_shm_realloc
void* qm_shm_realloc(void* qmp, void* p, unsigned long size)
{
void *r;
shm_lock();
r = qm_realloc(qmp, p, size);
shm_unlock();
return r;
}
开发者ID:neuhaus,项目名称:kamailio,代码行数:8,代码来源:q_malloc.c
示例9: qm_shm_available
unsigned long qm_shm_available(void* qmp)
{
unsigned long r;
shm_lock();
r = qm_available(qmp);
shm_unlock();
return r;
}
开发者ID:neuhaus,项目名称:kamailio,代码行数:8,代码来源:q_malloc.c
示例10: sh_realloc
inline static void* sh_realloc(void* p, unsigned int size)
{
void *r;
shm_lock();
shm_free_unsafe(p);
r=shm_malloc_unsafe(size);
shm_unlock();
return r;
}
开发者ID:BackupTheBerlios,项目名称:openimscore-svn,代码行数:9,代码来源:shm_mem.c
示例11: qm_shm_resize
void* qm_shm_resize(void* qmp, void* p, unsigned long size)
{
void *r;
shm_lock();
if(p) qm_free(qmp, p);
r = qm_malloc(qmp, size);
shm_unlock();
return r;
}
开发者ID:neuhaus,项目名称:kamailio,代码行数:9,代码来源:q_malloc.c
示例12: shm_inc
static inline void shm_inc (int id) {
struct shmid_kernel *shp;
if(!(shp = shm_lock(id)))
BUG();
shp->shm_atim = CURRENT_TIME;
shp->shm_lprid = current->pid;
shp->shm_nattch++;
shm_unlock(id);
}
开发者ID:iPodLinux,项目名称:linux-2.4.24-ipod,代码行数:10,代码来源:shm.c
示例13: shm_inc
static inline void shm_inc (int id) {
struct shmid_kernel *shp;
if(!(shp = shm_lock(id)))
BUG();
shp->shm_atim = get_seconds();
shp->shm_lprid = current->tgid;
shp->shm_nattch++;
shm_unlock(shp);
}
开发者ID:BackupTheBerlios,项目名称:tuxap,代码行数:10,代码来源:shm.c
示例14: shm_lock
void SHMSrc::render(char *dest, size_t len)
{
shm_lock();
while (buffer_gen_ == shm_area_->buffer_gen) {
shm_unlock();
std::cerr << "Waiting for next buffer" << std::endl;;
sem_wait(&shm_area_->notification);
shm_lock();
}
if (!resize_area())
return;
std::cerr << "Reading from buffer!" << std::endl;
memcpy(dest, shm_area_->data, len);
buffer_gen_ = shm_area_->buffer_gen;
shm_unlock();
}
开发者ID:asadsalman,项目名称:ring-daemon,代码行数:20,代码来源:shm_src.cpp
示例15: update_totag_set
/* append a newly received tag from a 200/INVITE to
* transaction's set; (only safe if called from within
* a REPLY_LOCK); it returns 1 if such a to tag already
* exists
*/
inline static int update_totag_set(struct cell *t, struct sip_msg *ok)
{
struct totag_elem *i, *n;
str *tag;
char *s;
if (!ok->to || !ok->to->parsed) {
LM_ERR("to not parsed\n");
return 0;
}
tag=&get_to(ok)->tag_value;
if (!tag->s) {
LM_DBG("no tag in to\n");
return 0;
}
for (i=t->fwded_totags; i; i=i->next) {
if (i->tag.len==tag->len
&& memcmp(i->tag.s, tag->s, tag->len) ==0 ){
/* to tag already recorded */
#ifdef XL_DEBUG
LM_CRIT("totag retransmission\n");
#else
LM_DBG("totag retransmission\n");
#endif
return 1;
}
}
/* that's a new to-tag -- record it */
#ifndef HP_MALLOC
shm_lock();
n=(struct totag_elem*) shm_malloc_unsafe(sizeof(struct totag_elem));
s=(char *)shm_malloc_unsafe(tag->len);
shm_unlock();
#else
n=(struct totag_elem*) shm_malloc(sizeof(struct totag_elem));
s=(char *)shm_malloc(tag->len);
#endif
if (!s || !n) {
LM_ERR("no more share memory \n");
if (n) shm_free(n);
if (s) shm_free(s);
return 0;
}
memset(n, 0, sizeof(struct totag_elem));
memcpy(s, tag->s, tag->len );
n->tag.s=s;n->tag.len=tag->len;
n->next=t->fwded_totags;
t->fwded_totags=n;
LM_DBG("new totag \n");
return 0;
}
开发者ID:dsanders11,项目名称:opensips,代码行数:57,代码来源:t_reply.c
示例16: shm_lock
void SHMSink::render(const std::vector<unsigned char> &data)
{
shm_lock();
if (!resize_area(sizeof(SHMHeader) + data.size()))
return;
memcpy(shm_area_->data, data.data(), data.size());
shm_area_->buffer_size = data.size();
shm_area_->buffer_gen++;
sem_post(&shm_area_->notification);
shm_unlock();
}
开发者ID:ThereIsNoYeti,项目名称:sflphone,代码行数:13,代码来源:shm_sink.cpp
示例17: free_cell
void free_cell( struct cell* dead_cell )
{
char *b;
int i;
struct sip_msg *rpl;
struct totag_elem *tt, *foo;
release_cell_lock( dead_cell );
shm_lock();
/* UA Server */
if ( dead_cell->uas.request )
sip_msg_free_unsafe( dead_cell->uas.request );
if ( dead_cell->uas.response.buffer )
shm_free_unsafe( dead_cell->uas.response.buffer );
/* completion callback */
if (dead_cell->cbp) shm_free_unsafe(dead_cell->cbp);
/* UA Clients */
for ( i =0 ; i<dead_cell->nr_of_outgoings; i++ )
{
/* retransmission buffer */
if ( (b=dead_cell->uac[i].request.buffer) )
shm_free_unsafe( b );
b=dead_cell->uac[i].local_cancel.buffer;
if (b!=0 && b!=BUSY_BUFFER)
shm_free_unsafe( b );
rpl=dead_cell->uac[i].reply;
if (rpl && rpl!=FAKED_REPLY) {
sip_msg_free_unsafe( rpl );
}
}
/* collected to tags */
tt=dead_cell->fwded_totags;
while(tt) {
foo=tt->next;
shm_free_unsafe(tt->tag.s);
shm_free_unsafe(tt);
tt=foo;
}
/* the cell's body */
shm_free_unsafe( dead_cell );
shm_unlock();
}
开发者ID:miettal,项目名称:armadillo420_standard,代码行数:48,代码来源:h_table.c
示例18: copy_buf_to_shm_log_buf
void copy_buf_to_shm_log_buf(logf_t *_logf)
{
if(!_logf || _logf->_inner_log_buf_len < 1) {
return;
}
shm_lock(_logf->_shm_log_buf);
if(*(_logf->log_buf_len) + _logf->_inner_log_buf_len > _logf->log_buf_size) {
write(_logf->LOG_FD, _logf->log_buf, *(_logf->log_buf_len));
*(_logf->log_buf_len) = 0;
}
memcpy(_logf->log_buf + (*_logf->log_buf_len), _logf->_inner_log_buf, _logf->_inner_log_buf_len);
*(_logf->log_buf_len) += _logf->_inner_log_buf_len;
shm_unlock(_logf->_shm_log_buf);
_logf->_inner_log_buf_len = 0;
}
开发者ID:millken,项目名称:merry,代码行数:19,代码来源:log.c
示例19: shm_close
/*
* remove the attach descriptor vma.
* free memory for segment if it is marked destroyed.
* The descriptor has already been removed from the current->mm->mmap list
* and will later be kfree()d.
*/
static void shm_close(struct vm_area_struct *vma)
{
struct file * file = vma->vm_file;
struct shm_file_data *sfd = shm_file_data(file);
struct shmid_kernel *shp;
struct ipc_namespace *ns = sfd->ns;
down_write(&shm_ids(ns).rwsem);
/* remove from the list of attaches of the shm segment */
shp = shm_lock(ns, sfd->id);
BUG_ON(IS_ERR(shp));
shp->shm_lprid = task_tgid_vnr(current);
shp->shm_dtim = get_seconds();
shp->shm_nattch--;
if (shm_may_destroy(ns, shp))
shm_destroy(ns, shp);
else
shm_unlock(shp);
up_write(&shm_ids(ns).rwsem);
}
开发者ID:SiddheshK15,项目名称:kernel_htc_820,代码行数:26,代码来源:shm.c
示例20: sh_realloc
inline static void* sh_realloc(void* p, unsigned int size)
{
void *r;
#ifndef HP_MALLOC
shm_lock();
shm_free_unsafe(p);
r = shm_malloc_unsafe(size);
#else
shm_free(p);
r = shm_malloc(size);
#endif
shm_threshold_check();
#ifndef HP_MALLOC
shm_unlock();
#endif
return r;
}
开发者ID:AndreiPlesa,项目名称:opensips,代码行数:21,代码来源:shm_mem.c
注:本文中的shm_lock函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论