示例#1
0
bool
OMR::Monitor::init(char *name)
   {
   _name = name;
   MUTEX_INIT(_monitor);
   bool rc = MUTEX_INIT(_monitor);
   TR_ASSERT(rc == true, "error initializing monitor\n");
   return true;
   }
示例#2
0
LoadBalancer::LoadBalancer(){
	logger = new Logger(log_path);   //日志类初始化
	ClientRecvCorrectCount=ClientRecvIncorrectCount=ClientSendCount = 0;
	ServerRecvCorrectCount=ServerRecvIncorrectCount=ServerSendCount = 0;
	initilize(conf_path);
	initilize_socket();
	MUTEX_INIT(mutex_sendto);
	MUTEX_INIT(mutex_print);
	
}
示例#3
0
文件: client.cpp 项目: jk983294/Store
Client::Client(unsigned id,unsigned usr_id, unsigned n){
	this->id = id;	this->usr_id = usr_id;	this->n = n;
	RecvCorrectCount=RecvIncorrectCount=SendCount = 0;
	initilize(conf_path);
	if (! SocketUtil::create_udp_socket(mysocket))
		print_debugInformation("创建client socket错误");
	isdebug = true;
	MUTEX_INIT(mutex_sendto);
	MUTEX_INIT(mutex_print);
}
示例#4
0
/* this is called shortly after the application starts and
   before any other function in the file
   called only from main thread */
int
freerdp_chanman_init(void)
{
	g_init_chan_man = NULL;
	g_chan_man_list = NULL;
	g_open_handle_sequence = 1;
	MUTEX_INIT(g_mutex_init);
	MUTEX_INIT(g_mutex_list);

	return 0;
}
示例#5
0
/* ------------------------------------------------------------------------ */
int ipfsync_init()
{
	RWLOCK_INIT(&ipf_syncstate, "add things to state sync table");
	RWLOCK_INIT(&ipf_syncnat, "add things to nat sync table");
	MUTEX_INIT(&ipf_syncadd, "add things to sync table");
	MUTEX_INIT(&ipsl_mutex, "add things to sync table");
# if SOLARIS && defined(_KERNEL)
	cv_init(&ipslwait, "ipsl condvar", CV_DRIVER, NULL);
# endif

	bzero((char *)syncnattab, sizeof(syncnattab));
	bzero((char *)syncstatetab, sizeof(syncstatetab));

	return 0;
}
VDAgent::VDAgent()
    : _hwnd (NULL)
    , _hwnd_next_viewer (NULL)
    , _user_lib (NULL)
    , _add_clipboard_listener (NULL)
    , _remove_clipboard_listener (NULL)
    , _clipboard_owner (owner_none)
    , _clipboard_tick (0)
    , _buttons_state (0)
    , _mouse_x (0)
    , _mouse_y (0)
    , _input_time (0)
    , _control_event (NULL)
    , _stop_event (NULL)
    , _in_msg (NULL)
    , _in_msg_pos (0)
    , _pending_input (false)
    , _running (false)
    , _desktop_switch (false)
    , _desktop_layout (NULL)
    , _display_setting (VD_AGENT_REGISTRY_KEY)
    , _vio_serial (NULL)
    , _read_pos (0)
    , _write_pos (0)
    , _logon_desktop (false)
    , _display_setting_initialized (false)
    , _max_clipboard (-1)
    , _client_caps (NULL)
    , _client_caps_size (0)
    , _log (NULL)
{
    TCHAR log_path[MAX_PATH];
    TCHAR temp_path[MAX_PATH];

    _system_version = supported_system_version();
    if (GetTempPath(MAX_PATH, temp_path)) {
        swprintf_s(log_path, MAX_PATH, VD_AGENT_LOG_PATH, temp_path);
        _log = VDLog::get(log_path);
    }
    ZeroMemory(&_input, sizeof(_input));
    ZeroMemory(&_read_overlapped, sizeof(_read_overlapped));
    ZeroMemory(&_write_overlapped, sizeof(_write_overlapped));
    ZeroMemory(_read_buf, sizeof(_read_buf));
    MUTEX_INIT(_control_mutex);
    MUTEX_INIT(_message_mutex);

    _singleton = this;
}
示例#7
0
文件: tdisp.c 项目: sam0737/ugfx-rads
void _tdispInit(void) {
	MUTEX_INIT();

	MUTEX_ENTER();
	tdisp_lld_init();
	MUTEX_LEAVE();
}
示例#8
0
/*
* Initialize keeper states
*
* If there is a problem, return an error message (NULL for okay).
*
* Note: Any problems would be design flaws; the created Lua state is left
*       unclosed, because it does not really matter. In production code, this
*       function never fails.
*/
char const* init_keepers( int const _nbKeepers, lua_CFunction _on_state_create)
{
	int i;
	assert( _nbKeepers >= 1);
	GNbKeepers = _nbKeepers;
	GKeepers = malloc( _nbKeepers * sizeof( struct s_Keeper));
	for( i = 0; i < _nbKeepers; ++ i)
	{

		// We need to load all base libraries in the keeper states so that the transfer databases are populated properly
		// 
		// 'io' for debugging messages, 'package' because we need to require modules exporting idfuncs
		// the others because they export functions that we may store in a keeper for transfer between lanes
		lua_State* K = luaG_newstate( "*", _on_state_create);
		if (!K)
			return "out of memory";

		STACK_CHECK( K)
		// to see VM name in Decoda debugger
		lua_pushliteral( K, "Keeper #");
		lua_pushinteger( K, i + 1);
		lua_concat( K, 2);
		lua_setglobal( K, "decoda_name");

#if KEEPER_MODEL == KEEPER_MODEL_C
		// create the fifos table in the keeper state
		lua_pushlightuserdata( K, fifos_key);
		lua_newtable( K);
		lua_rawset( K, LUA_REGISTRYINDEX);
#endif // KEEPER_MODEL == KEEPER_MODEL_C

#if KEEPER_MODEL == KEEPER_MODEL_LUA
		// use package.loaders[2] to find keeper microcode
		lua_getglobal( K, "package");                  // package
		lua_getfield( K, -1, "loaders");               // package package.loaders
		lua_rawgeti( K, -1, 2);                        // package package.loaders package.loaders[2]
		lua_pushliteral( K, "lanes-keeper");           // package package.loaders package.loaders[2] "lanes-keeper"
		STACK_MID( K, 4);
		// first pcall loads lanes-keeper.lua, second one runs the chunk
		if( lua_pcall( K, 1 /*args*/, 1 /*results*/, 0 /*errfunc*/) || lua_pcall( K, 0 /*args*/, 0 /*results*/, 0 /*errfunc*/))
		{
			// LUA_ERRRUN / LUA_ERRMEM / LUA_ERRERR
			//
			char const* err = lua_tostring( K, -1);
			assert( err);
			return err;
		}                                              // package package.loaders
		STACK_MID( K, 2);
		lua_pop( K, 2);
#endif // KEEPER_MODEL == KEEPER_MODEL_LUA
		STACK_END( K, 0)
		MUTEX_INIT( &GKeepers[i].lock_);
		GKeepers[i].L = K;
		//GKeepers[i].count = 0;
	}
#if HAVE_KEEPER_ATEXIT_DESINIT
	atexit( atexit_close_keepers);
#endif // HAVE_KEEPER_ATEXIT_DESINIT
	return NULL;    // ok
}
示例#9
0
文件: mmkey.c 项目: cnangel/hidbase
/* initialize */
MMKEY *mmkey_init(char *file)
{
    MMKEY *mmkey = NULL;
    struct stat st = {0};
    int fd = 0;

    if(file && (fd = open(file, O_CREAT|O_RDWR, 0644)) > 0)
    {
        if((mmkey = (MMKEY *)calloc(1, sizeof(MMKEY))))
        {
            MUTEX_INIT(mmkey->mutex);
            mmkey->fd          = fd;
            fstat(fd, &st);
            mmkey->file_size   = st.st_size;
            MMKEY_MAP_INIT(mmkey);
            mmkey->add         = mmkey_add;
            mmkey->xadd        = mmkey_xadd;
            mmkey->get         = mmkey_get;
            mmkey->del         = mmkey_del;
            mmkey->find        = mmkey_find;
            mmkey->maxfind     = mmkey_maxfind;
            mmkey->radd        = mmkey_radd;
            mmkey->rxadd       = mmkey_rxadd;
            mmkey->rget        = mmkey_rget;
            mmkey->rdel        = mmkey_rdel;
            mmkey->rfind       = mmkey_rfind;
            mmkey->rmaxfind    = mmkey_rmaxfind;
            mmkey->clean       = mmkey_clean;
        }
        else 
            close(fd);
    }
    return mmkey;
}
示例#10
0
perf_datafile_t *
perf_datafile_open(isc_mem_t *mctx, const char *filename)
{
	perf_datafile_t *dfile;
	struct stat buf;

	dfile = isc_mem_get(mctx, sizeof(*dfile));
	if (dfile == NULL)
		perf_log_fatal("out of memory");

	dfile->mctx = mctx;
	MUTEX_INIT(&dfile->lock);
	dfile->pipe_fd = -1;
	dfile->is_file = ISC_FALSE;
	dfile->size = 0;
	dfile->cached = ISC_FALSE;
	dfile->maxruns = 1;
	dfile->nruns = 0;
	dfile->read_any = ISC_FALSE;
	isc_buffer_init(&dfile->data, dfile->databuf, BUFFER_SIZE);
	if (filename == NULL) {
		dfile->fd = STDIN_FILENO;
	} else {
		dfile->fd = open(filename, O_RDONLY);
		if (dfile->fd < 0)
			perf_log_fatal("unable to open file: %s", filename);
		if (fstat(dfile->fd, &buf) == 0 && S_ISREG(buf.st_mode)) {
			dfile->is_file = ISC_TRUE;
			dfile->size = buf.st_size;
		}
	}
	nul_terminate(dfile);

	return dfile;
}
示例#11
0
/**
 * create a thread pool.
 *
 * @param[inout] pool_out  address in which to store pool object pointer.
 * @param[in]    queue     work queue serviced by thread pool
 *
 * @return operation status
 *    @retval 0 success
 *    @retval ENOMEM out of memory
 */
int
afs_tp_create(struct afs_thread_pool ** pool_out,
              struct afs_work_queue * queue)
{
    int ret = 0;
    struct afs_thread_pool * pool;

    ret = _afs_tp_alloc(pool_out);
    if (ret) {
        goto error;
    }
    pool = *pool_out;

    MUTEX_INIT(&pool->lock, "pool", MUTEX_DEFAULT, 0);
    CV_INIT(&pool->shutdown_cv, "pool shutdown", CV_DEFAULT, 0);
    queue_Init(&pool->thread_list);
    pool->work_queue = queue;
    pool->entry = &_afs_tp_worker_default;
    pool->rock = NULL;
    pool->nthreads = 0;
    pool->max_threads = 4;
    pool->state = AFS_TP_STATE_INIT;

error:
    return ret;
}
示例#12
0
static POOL_HANDLE *pool_grow (PERL_INST *inst) {
	POOL_HANDLE *handle;
	time_t	now;

	if (inst->perl_pool->max_clones == inst->perl_pool->current_clones) {
		return NULL;
	}
	if (inst->perl_pool->detach == yes ) {
		return NULL;
	}

	handle = (POOL_HANDLE *)rad_malloc(sizeof(POOL_HANDLE));

	if (!handle) {
		radlog(L_ERR,"Could not find free memory for pool. Aborting");
		return NULL;
	}

	handle->prev = NULL;
	handle->next = NULL;
	handle->status = idle;
	handle->clone = rlm_perl_clone(inst->perl);
	handle->request_count = 0;
	MUTEX_INIT(&handle->lock);
	inst->perl_pool->current_clones++;
	move2tail(handle, inst);

	now = time(NULL);
	inst->perl_pool->time_when_last_added = now;

	return handle;
}
示例#13
0
bool Trace::ConnectToFileAndStart(char *filename, unsigned int trace_index, int register_size, int register_count, bool is_big_endian) {
  trace_index_ = trace_index;
  is_big_endian_ = is_big_endian;
  register_size_ = register_size;
  register_count_ = register_count;
  RWLOCK_INIT(db_lock_);
  MUTEX_INIT(backing_mutex_);

  registers_.resize(register_count_);

#ifdef _WIN32
  fd_ = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
#else
  fd_ = open(filename, O_RDONLY);
  if (fd_ == -1) {
    printf("ERROR: file open failed\n");
    return false;
  }
#endif

  if (!remap_backing(sizeof(struct change))) {
    printf("ERROR: remap backing failed\n");
    return false;
  }

  THREAD_CREATE(thread, thread_entry, this);
  return true;
}
示例#14
0
/*
 * IPSec application proxy initialization.
 */
int ippr_ipsec_init()
{
	bzero((char *)&ipsecfr, sizeof(ipsecfr));
	ipsecfr.fr_ref = 1;
	ipsecfr.fr_flags = FR_OUTQUE|FR_PASS|FR_QUICK|FR_KEEPSTATE;
	MUTEX_INIT(&ipsecfr.fr_lock, "IPsec proxy rule lock");
	ipsec_proxy_init = 1;

	ipsecnattqe = fr_addtimeoutqueue(&nat_utqe, ipsec_proxy_ttl);
	if (ipsecnattqe == NULL)
		return -1;
	ipsecstatetqe = fr_addtimeoutqueue(&ips_utqe, ipsec_proxy_ttl);
	if (ipsecstatetqe == NULL) {
		if (fr_deletetimeoutqueue(ipsecnattqe) == 0)
			fr_freetimeoutqueue(ipsecnattqe);
		ipsecnattqe = NULL;
		return -1;
	}

	ipsecnattqe->ifq_flags |= IFQF_PROXY;
	ipsecstatetqe->ifq_flags |= IFQF_PROXY;

	ipsecfr.fr_age[0] = ipsec_proxy_ttl;
	ipsecfr.fr_age[1] = ipsec_proxy_ttl;
	return 0;
}
示例#15
0
/**
 * allocate a work node.
 *
 * @param[out] node_out  address in which to store new work node
 *
 * @return operation status
 *    @retval 0 success
 *    @retval ENOMEM         out of memory
 */
int
afs_wq_node_alloc(struct afs_work_queue_node ** node_out)
{
    int ret = 0;
    struct afs_work_queue_node * node;

    *node_out = node = (struct afs_work_queue_node *) malloc(sizeof(*node));
    if (node == NULL) {
	ret = ENOMEM;
	goto error;
    }

    queue_NodeInit(&node->node_list);
    node->qidx = AFS_WQ_NODE_LIST_NONE;
    node->cbf = NULL;
    node->rock = node->queue = NULL;
    node->refcount = 1;
    node->block_count = 0;
    node->error_count = 0;
    MUTEX_INIT(&node->lock, "node", MUTEX_DEFAULT, 0);
    CV_INIT(&node->state_cv, "node state", CV_DEFAULT, 0);
    node->state = AFS_WQ_NODE_STATE_INIT;
    queue_Init(&node->dep_children);

 error:
    return ret;
}
示例#16
0
文件: ip_log.c 项目: AhmadTux/freebsd
/* ------------------------------------------------------------------------ */
int fr_loginit()
{
	int	i;

	for (i = IPL_LOGMAX; i >= 0; i--) {
		iplt[i] = NULL;
		ipll[i] = NULL;
		iplh[i] = &iplt[i];
		iplused[i] = 0;
		bzero((char *)&iplcrc[i], sizeof(iplcrc[i]));
# ifdef	IPL_SELECT
		iplog_ss[i].read_waiter = 0;
		iplog_ss[i].state = 0;
# endif
# if defined(linux) && defined(_KERNEL)
		init_waitqueue_head(iplh_linux + i);
# endif
	}

# if SOLARIS && defined(_KERNEL)
	cv_init(&iplwait, "ipl condvar", CV_DRIVER, NULL);
# endif
	MUTEX_INIT(&ipl_mutex, "ipf log mutex");

	ipl_log_init = 1;

	return 0;
}
示例#17
0
Logging::Logging(bool debug) {
	mDebug = debug;
	MUTEX_INIT();

	strcpy(mErrBuf, "Unknown Error");
	strcpy(mLogBuf, "Unknown Message");
}
示例#18
0
TEST(Mutex, test) {
    MUTEX mx;
    MUTEX_INIT(mx);
    MUTEX_LOCK(mx);
    MUTEX_UNLOCK(mx);
    MUTEX_DESTROY(mx);
}
示例#19
0
文件: atomic.c 项目: salmito/leda
atomic atomic_new(long int x) {
   atomic a;
   a=malloc(sizeof(struct atomicInt));
   a->i=x;
   MUTEX_INIT(&a->lock);
   return a;
}
示例#20
0
文件: task.c 项目: houweifeng/sbase
/* Initialize tasktable */
TASKTABLE *tasktable_init(char *taskfile, char *statusfile, char *logfile)
{
    TASKTABLE *tasktable = NULL;

    if(taskfile && (tasktable = (TASKTABLE *)calloc(1, sizeof(TASKTABLE))))
    {
        tasktable->add              = tasktable_add;
        tasktable->discard          = tasktable_discard;
        tasktable->ready            = tasktable_ready;
        tasktable->check_status     = tasktable_check_status;
        tasktable->check_timeout    = tasktable_check_timeout;
        tasktable->statusout        = tasktable_statusout;
        tasktable->md5sum           = tasktable_md5sum;
        tasktable->dump_task        = tasktable_dump_task;
        tasktable->resume_task      = tasktable_resume_task;
        tasktable->dump_status      = tasktable_dump_status;
        tasktable->resume_status    = tasktable_resume_status;
        tasktable->pop_block        = tasktable_pop_block;
        tasktable->update_status    = tasktable_update_status;
        tasktable->free_status      = tasktable_free_status;
        tasktable->clean            = tasktable_clean;
        tasktable->running_task_id = -1;
        tasktable->running_task.id = -1;
        LOGGER_INIT(tasktable->logger, logfile);
        strcpy(tasktable->taskfile, taskfile);
        tasktable->resume_task(tasktable);
        strcpy(tasktable->statusfile, statusfile);
        tasktable->resume_status(tasktable);
        MUTEX_INIT(tasktable->mutex);
    }
    return tasktable;
}
示例#21
0
static int init_pool (CONF_SECTION *conf, PERL_INST *inst) {
	POOL_HANDLE 	*handle;
	int t;
	PERL_POOL	*pool;

	pool = rad_malloc(sizeof(PERL_POOL));
	memset(pool,0,sizeof(PERL_POOL));

	inst->perl_pool = pool;

	MUTEX_INIT(&pool->mutex);

	/*
	 * Read The Config
	 *
	 */

	cf_section_parse(conf,pool,pool_conf);
	inst->perl_pool = pool;
	inst->perl_pool->detach = no;

	for(t = 0;t < inst->perl_pool->start_clones ;t++){
		if ((handle = pool_grow(inst)) == NULL) {
			return -1;
		}

	}

	return 1;
}
示例#22
0
TSS_RESULT
tcsd_threads_init(void)
{
	/* allocate the thread mgmt structure */
	tm = calloc(1, sizeof(struct tcsd_thread_mgr));
	if (tm == NULL) {
		LogError("malloc of %zd bytes failed.", sizeof(struct tcsd_thread_mgr));
		return TCSERR(TSS_E_OUTOFMEMORY);
	}
	/* initialize mutex */
	MUTEX_INIT(tm->lock);

	/* set the max threads variable from config */
	tm->max_threads = tcsd_options.num_threads;

	/* allocate each thread's data structure */
	tm->thread_data = calloc(tcsd_options.num_threads, sizeof(struct tcsd_thread_data));
	if (tm->thread_data == NULL) {
		LogError("malloc of %zu bytes failed.",
			 tcsd_options.num_threads * sizeof(struct tcsd_thread_data));
		free(tm);
		return TCSERR(TSS_E_OUTOFMEMORY);
	}

	return TSS_SUCCESS;
}
/**
 * Initialize a new lock object.
 * A lock must be initialized before it may be used.
 *
 * @param env
 * @param options
 * @param name Lock name
 * @return TRUE on success
 * @note Creates a store barrier.
 */
bool
MM_LightweightNonReentrantLock::initialize(MM_EnvironmentBase *env, ModronLnrlOptions *options, const char * name)
{
	OMRPORT_ACCESS_FROM_OMRPORT(env->getPortLibrary());

	/* initialize variables in case constructor was not called */
	_initialized = false;
	_tracing = NULL;
	_extensions = env->getExtensions();

	if (NULL != _extensions) {
		J9Pool* tracingPool = _extensions->_lightweightNonReentrantLockPool;
		if (NULL != tracingPool) {
			omrthread_monitor_enter(_extensions->_lightweightNonReentrantLockPoolMutex);
			_tracing = (J9ThreadMonitorTracing *)pool_newElement(tracingPool);
			omrthread_monitor_exit(_extensions->_lightweightNonReentrantLockPoolMutex);

			if (NULL == _tracing) {
				goto error_no_memory;
			}
			_tracing->monitor_name = NULL;

			if (NULL != name) {
				uintptr_t length = omrstr_printf(NULL, 0, "[%p] %s", this, name) + 1;
				if (length > MAX_LWNR_LOCK_NAME_SIZE) {
					goto error_no_memory;
				}
				_tracing->monitor_name = _nameBuf;
				if (NULL == _tracing->monitor_name) {
					goto error_no_memory;
				}
				omrstr_printf(_tracing->monitor_name, length, "[%p] %s", this, name);
			}
		}
	}

#if defined(OMR_ENV_DATA64)
	if(0 != (((uintptr_t)this) % sizeof(uintptr_t))) {
		omrtty_printf("GC FATAL: LWNRL misaligned.\n");
		abort();
	}
#endif

#if defined(J9MODRON_USE_CUSTOM_SPINLOCKS)

	_initialized = omrgc_spinlock_init(&_spinlock) ? false : true;

	_spinlock.spinCount1 = options->spinCount1;
	_spinlock.spinCount2 = options->spinCount2;
	_spinlock.spinCount3 = options->spinCount3;
#else /* J9MODRON_USE_CUSTOM_SPINLOCKS */
	_initialized = MUTEX_INIT(_mutex) ? true : false;
#endif /* J9MODRON_USE_CUSTOM_SPINLOCKS */

	return _initialized;

error_no_memory:
	return false;
}
示例#24
0
TSS_RESULT
__tspi_add_table_entry(TSS_HCONTEXT tspContext, BYTE *host, int type, struct host_table_entry **ret)
{
    struct host_table_entry *entry, *tmp;
    int hostlen;

    entry = calloc(1, sizeof(struct host_table_entry));
    if (entry == NULL) {
            LogError("malloc of %zd bytes failed.", sizeof(struct host_table_entry));
            return TSPERR(TSS_E_OUTOFMEMORY);
    }

    entry->tspContext = tspContext;

    hostlen = strlen((char *)host)+1;
    entry->hostname = (BYTE *)calloc(1, hostlen);
    if (entry->hostname == NULL) {
        LogError("malloc of %u bytes failed.", hostlen);
        free(entry);
        return TSPERR(TSS_E_OUTOFMEMORY);
    }
    memcpy(entry->hostname, host, hostlen);

    entry->type = type;
    entry->comm.buf_size = TCSD_INIT_TXBUF_SIZE;
    entry->comm.buf = calloc(1, entry->comm.buf_size);
    if (entry->comm.buf == NULL) {
            LogError("malloc of %u bytes failed.", entry->comm.buf_size);
            free(entry);
            return TSPERR(TSS_E_OUTOFMEMORY);
    }
    MUTEX_INIT(entry->lock);

	MUTEX_LOCK(ht->lock);

	for (tmp = ht->entries; tmp; tmp = tmp->next) {
		if (tmp->tspContext == tspContext) {
			LogError("Tspi_Context_Connect attempted on an already connected context!");
			MUTEX_UNLOCK(ht->lock);
			free(entry->hostname);
			free(entry->comm.buf);
			free(entry);
			return TSPERR(TSS_E_CONNECTION_FAILED);
		}
	}

	if( ht->entries == NULL ) {
		ht->entries = entry;
	} else {
		for (tmp = ht->entries; tmp->next; tmp = tmp->next)
			;
		tmp->next = entry;
	}
	MUTEX_UNLOCK(ht->lock);

	*ret = entry;

	return TSS_SUCCESS;
}
示例#25
0
static void InitStats(UDPIO_STATS *stats)
{
    MUTEX_INIT(&stats->mutex);
    stats->total.bytes = stats->total.pkts = (UINT64) 0;
    stats->len.min = stats->len.max = 0;
    stats->tstamp = utilTimeStamp();
    stats->error.count = stats->error.tstamp = 0;
}
示例#26
0
/**
 * initialize a struct VLockFile.
 *
 * @param[in] lf   struct VLockFile to initialize
 * @param[in] path Full path to the file to use for locks. The string contents
 *                 are copied.
 */
void
VLockFileInit(struct VLockFile *lf, const char *path)
{
    memset(lf, 0, sizeof(*lf));
    lf->path = strdup(path);
    lf->fd = INVALID_FD;
    MUTEX_INIT(&lf->mutex, "vlockfile", MUTEX_DEFAULT, 0);
}
示例#27
0
文件: alarm.c 项目: Vidmich/parrot
void
Parrot_alarm_init(void)
{
    ASSERT_ARGS(Parrot_alarm_init)
    Parrot_thread thread;
    MUTEX_INIT(alarm_lock);
    COND_INIT(sleep_cond);
    THREAD_CREATE_JOINABLE(thread, Parrot_alarm_runloop, NULL);
}
示例#28
0
perl_mutex* get_shutdown_mutex() {
	static int inited = 0;
	static perl_mutex mutex;
	if (!inited) {
		MUTEX_INIT(&mutex);
		inited = 1;
	}
	return &mutex;
}
示例#29
0
/*
 * Initialize local structures.
 */
void
ipf_p_irc_main_load()
{
	bzero((char *)&ircnatfr, sizeof(ircnatfr));
	ircnatfr.fr_ref = 1;
	ircnatfr.fr_flags = FR_INQUE|FR_PASS|FR_QUICK|FR_KEEPSTATE;
	MUTEX_INIT(&ircnatfr.fr_lock, "IRC proxy rule lock");
	irc_proxy_init = 1;
}
示例#30
0
 lmdb_source_id_manager_t(const std::string& p_hashdb_dir,
                          const hashdb::file_mode_type_t p_file_mode) :
      hashdb_dir(p_hashdb_dir),
      file_mode(p_file_mode),
      env(lmdb_helper::open_env(hashdb_dir + "/lmdb_source_id_store",
                                                           file_mode)),
      M() {
   MUTEX_INIT(&M);
 }