本文整理汇总了C++中shm_unlock函数的典型用法代码示例。如果您正苦于以下问题:C++ shm_unlock函数的具体用法?C++ shm_unlock怎么用?C++ shm_unlock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了shm_unlock函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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);
}
示例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
}
示例4: qm_shm_info
void qm_shm_info(void* qmp, struct mem_info* info)
{
shm_lock();
qm_info(qmp, info);
shm_unlock();
}
示例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();
}
示例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;
}
示例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;
}
示例8: qm_shm_available
unsigned long qm_shm_available(void* qmp)
{
unsigned long r;
shm_lock();
r = qm_available(qmp);
shm_unlock();
return r;
}
示例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;
}
示例10: shm_available_safe
unsigned long shm_available_safe()
{
unsigned long ret;
shm_lock();
ret = shm_available();
shm_unlock();
return ret;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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();
}