• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ shm_unlock函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中shm_unlock函数的典型用法代码示例。如果您正苦于以下问题:C++ shm_unlock函数的具体用法?C++ shm_unlock怎么用?C++ shm_unlock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了shm_unlock函数的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: cleanup

/**
 * Clean up on exit. This should be called before exiting.
 * \param show_status set to one to display the mem status
 */
void cleanup(int show_status)
{
	LM_INFO("cleanup\n");
	/*clean-up*/

	/* hack: force-unlock the shared memory lock in case
	   		 some process crashed and let it locked; this will
	   		 allow an almost gracious shutdown */
	if (mem_lock)
#ifdef HP_MALLOC
	{
		int i;

		for (i = 0; i < HP_HASH_SIZE; i++)
			shm_unlock(i);
	}
#else
		shm_unlock();
#endif

	handle_ql_shutdown();
	destroy_modules();
#ifdef USE_TCP
	destroy_tcp();
#endif
#ifdef USE_TLS
	destroy_tls();
#endif
	destroy_timer();
	destroy_stats_collector();
	destroy_script_cb();
	pv_free_extra_list();
	destroy_argv_list();
	destroy_black_lists();
#ifdef PKG_MALLOC
	if (show_status){
		LM_GEN1(memdump, "Memory status (pkg):\n");
		pkg_status();
	}
#endif
#ifdef SHM_MEM
	cleanup_debug();

	if (pt) shm_free(pt);
	pt=0;
	if (show_status){
			LM_GEN1(memdump, "Memory status (shm):\n");
			shm_status();
	}

	/* zero all shmem alloc vars that we still use */
	shm_mem_destroy();
#endif
	if (pid_file) unlink(pid_file);
	if (pgid_file) unlink(pgid_file);
}
开发者ID:zhangzheyuk,项目名称:opensips,代码行数:60,代码来源:main.c


示例3: destroy_memory

/** call it before exiting; if show_status==1, mem status is displayed */
void destroy_memory(int show_status)
{
	/*clean-up*/
	if (mem_lock)
	    shm_unlock(); /* hack: force-unlock the shared memory lock in case
	                             some process crashed and let it locked; this will
	                             allow an almost gracious shutdown */
#ifdef SHM_MEM
	if (show_status){
		LOG(memlog, "Memory status (shm):\n");
		//shm_status();
#ifndef SER_MOD_INTERFACE
		shm_sums();
#endif		
	}
	/* zero all shmem alloc vars that we still use */
#ifdef WHARF	

#else
	shm_mem_destroy();
#endif	
#endif
#ifdef PKG_MALLOC
	if (show_status){
		LOG(memlog, "Memory status (pkg):\n");
		//pkg_status();
#ifndef SER_MOD_INTERFACE
		pkg_sums();
#endif
	}
#endif
}
开发者ID:BackupTheBerlios,项目名称:openimscore-svn,代码行数:33,代码来源:globals.c


示例4: 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


示例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: 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


示例7: 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


示例8: 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


示例9: 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


示例10: 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


示例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: 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


示例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_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


示例15: 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


示例16: 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


示例17: 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


示例18: cleanup

/**
 * Clean up on exit. This should be called before exiting.
 * \param show_status set to one to display the mem status 
 */
void cleanup(int show_status)
{
	LM_INFO("cleanup\n");
	/*clean-up*/
	if (mem_lock) 
		shm_unlock(); /* hack: force-unlock the shared memory lock in case
					 some process crashed and let it locked; this will 
					 allow an almost gracious shutdown */
	handle_ql_shutdown();
	destroy_modules();
#ifdef USE_TCP
	destroy_tcp();
#endif
#ifdef USE_TLS
	destroy_tls();
#endif
	destroy_timer();
	destroy_stats_collector();
	destroy_script_cb();
	pv_free_extra_list();
	destroy_argv_list();
	destroy_black_lists();
#ifdef CHANGEABLE_DEBUG_LEVEL
	if (debug!=&debug_init) {
		reset_proc_debug_level();
		debug_init = *debug;
		shm_free(debug);
		debug = &debug_init;
	}
#endif
#ifdef PKG_MALLOC
	if (show_status){
		LM_GEN1(memdump, "Memory status (pkg):\n");
		pkg_status();
	}
#endif
#ifdef SHM_MEM
	if (pt) shm_free(pt);
	pt=0;
	if (show_status){
			LM_GEN1(memdump, "Memory status (shm):\n");
			shm_status();
	}
	/* zero all shmem alloc vars that we still use */
	shm_mem_destroy();
#endif
	if (pid_file) unlink(pid_file);
	if (pgid_file) unlink(pgid_file);
}
开发者ID:bluemutedwisdom,项目名称:OpenSIPS,代码行数:53,代码来源:main.c


示例19: 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


示例20: shm_destroy

/*
 * shm_destroy - free the struct shmid_kernel
 *
 * @ns: namespace
 * @shp: struct to free
 *
 * It has to be called with shp and shm_ids.rwsem (writer) locked,
 * but returns with shp unlocked and freed.
 */
static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
{
	struct file *shm_file;

	shm_file = shp->shm_file;
	shp->shm_file = NULL;
	ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
	shm_rmid(ns, shp);
	shm_unlock(shp);
	if (!is_file_hugepages(shm_file))
		shmem_lock(shm_file, 0, shp->mlock_user);
	else if (shp->mlock_user)
		user_shm_unlock(file_inode(shm_file)->i_size, shp->mlock_user);
	fput(shm_file);
	ipc_rcu_putref(shp, shm_rcu_free);
}
开发者ID:SiddheshK15,项目名称:kernel_htc_820,代码行数:25,代码来源:shm.c



注:本文中的shm_unlock函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ shmat函数代码示例发布时间:2022-05-30
下一篇:
C++ shm_unlink函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap