当前位置: 首页>>代码示例>>C++>>正文


C++ rw_unlock函数代码示例

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


在下文中一共展示了rw_unlock函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: _nscd_init_all_getent_ctx_base

nscd_rc_t
_nscd_init_all_getent_ctx_base()
{
    int			i;
    nscd_rc_t		rc;
    char			*me = "_nscd_init_all_getent_ctx_base";

    (void) rw_wrlock(&nscd_getent_ctx_base_lock);

    for (i = 0; i < NSCD_NUM_DB; i++) {

        rc = _nscd_init_getent_ctx_base(i, 0);

        if (rc != NSCD_SUCCESS) {
            (void) rw_unlock(&nscd_getent_ctx_base_lock);
            return (rc);
        }
    }

    _NSCD_LOG(NSCD_LOG_GETENT_CTX | NSCD_LOG_CONFIG, NSCD_LOG_LEVEL_DEBUG)
    (me, "all getent context base initialized\n");

    (void) rw_unlock(&nscd_getent_ctx_base_lock);

    return (NSCD_SUCCESS);
}
开发者ID:mikess,项目名称:illumos-gate,代码行数:26,代码来源:nscd_getentctx.c

示例2: dfs_root_setinfo

/*
 * Sets the provided information for the specified root or root target.
 * Root is specified by 'rootdir' and the target is specified by
 * (t_server, t_share) pair. Only information items needed for given
 * information level (infolvl) is valid in the passed DFS info structure
 * 'info'.
 */
uint32_t
dfs_root_setinfo(const char *rootdir, dfs_info_t *info, uint32_t infolvl)
{
	dfs_info_t curinfo;
	uint32_t status = ERROR_SUCCESS;
	int xfd;

	(void) rw_wrlock(&dfs_root_rwl);
	if ((xfd = dfs_root_xopen(rootdir, O_RDWR)) < 0) {
		(void) rw_unlock(&dfs_root_rwl);
		return (ERROR_INTERNAL_ERROR);
	}

	status = dfs_root_xread(xfd, &curinfo, DFS_INFO_ALL);
	if (status != ERROR_SUCCESS) {
		dfs_root_xclose(xfd);
		(void) rw_unlock(&dfs_root_rwl);
		return (status);
	}

	status = dfs_modinfo(DFS_OBJECT_ROOT, &curinfo, info, infolvl);
	if (status == ERROR_SUCCESS)
		status = dfs_root_xwrite(xfd, &curinfo);

	dfs_root_xclose(xfd);
	(void) rw_unlock(&dfs_root_rwl);

	dfs_info_free(&curinfo);
	return (status);
}
开发者ID:bahamas10,项目名称:openzfs,代码行数:37,代码来源:dfs.c

示例3: resolve_symbols

void
resolve_symbols()
{
	void *foo;
	global_cond_flag = TRUE;
#ifdef SOLARIS
	mutex_lock(&queue_lock);
	mutex_trylock(&queue_lock);
	mutex_unlock(&queue_lock);
	foo = (void *)&cond_signal;
	foo = (void *)&cond_wait;
	foo = (void *)&cond_timedwait;
	sema_post(&global_sema_lock);
	sema_wait(&global_sema_lock); 
	rw_rdlock(&global_rw_lock);
	rw_unlock(&global_rw_lock);
	rw_wrlock(&global_rw_lock);
	rw_unlock(&global_rw_lock);
#endif
#ifdef POSIX
	pthread_mutex_lock(&queue_lock);
	pthread_mutex_trylock(&queue_lock);
	pthread_mutex_unlock(&queue_lock);
	foo = (void *)&pthread_cond_signal;
	foo = (void *)&pthread_cond_wait;
	foo = (void *)&pthread_cond_timedwait;
	sem_post(&global_sema_lock);
	sem_wait(&global_sema_lock); 
#endif
}
开发者ID:dhaley,项目名称:dcp,代码行数:30,代码来源:mttest.c

示例4: Traverse

// ******************************************
// O(N) traversal
int Traverse(unsigned long *random_seed, param_t *params)
{
    rbnode_t *new_node, *node;
    long key = -1;

#ifdef DEBUG
    long values[1000];
    index = 0;
    //printf("TRAVERSAL ******************************************\n");
#endif
#ifdef NO_GRACE_PERIOD
    read_lock(My_Tree->lock);
#else
    rw_lock(My_Tree->lock);
#endif
    new_node = rb_first_n(My_Tree);
    assert(new_node->key == -1);

    while (new_node != NULL)
    {
        node = new_node;
        key = node->key;

#ifdef DEBUG
        values[index++] = key;
#endif
        new_node = rb_next(node);
#ifdef DEBUG
        if (new_node != NULL && node->key >= new_node->key)
        {
            printf("******************************************\n"
                   "TRAVERSEAL ERROR key: %ld new: %ld\n"
                   "******************************************\n", 
                   node->key, new_node->key);
            while (--index >= 0)
            {
                printf("%3d: %ld\n", index, values[index]);
            }
#ifdef NO_GRACE_PERIOD
            read_unlock(My_Tree->lock);
#else
            rw_unlock(My_Tree->lock);
#endif
            write_lock(My_Tree->lock);
            rb_output(My_Tree);
            exit(-1);
            return 0;
        }
#endif
    }

#ifdef NO_GRACE_PERIOD
    read_unlock(My_Tree->lock);
#else
    rw_unlock(My_Tree->lock);
#endif

    assert(key == params->scale + 1);
    return 0;
}
开发者ID:philip-w-howard,项目名称:RP-Red-Black-Tree,代码行数:62,代码来源:rbtest.c

示例5: get_g_cache

static g_cache_ptr
get_g_cache(void)
{
	g_cache_ptr gc;

	/* always enter with a READ LOCK and exit with one too */
	ASSERT(RW_READ_HELD(&g_cache_lock));
	if ((gc = groups_cache) != 0) {
		return (gc);
	}
	(void) rw_unlock(&g_cache_lock);

	/* write lock the cache and try again */
	(void) rw_wrlock(&g_cache_lock);
	if ((gc = groups_cache) != 0) {
		(void) rw_unlock(&g_cache_lock);
		(void) rw_rdlock(&g_cache_lock);
		return (gc);
	}

	gc = groups_cache = calloc(1, sizeof (*groups_cache));
	if (groups_cache == 0) {
		(void) rw_unlock(&g_cache_lock);
		(void) rw_rdlock(&g_cache_lock);
		return (0);
	}
	(void) rw_unlock(&g_cache_lock);
	(void) rw_rdlock(&g_cache_lock);
	return (gc);
}
开发者ID:andreiw,项目名称:polaris,代码行数:30,代码来源:nis_groups.c

示例6: _nscd_add_getent_ctx

/*
 * FUNCTION: _nscd_add_getent_ctx
 *
 * Add a getent context to the internal context database.
 */
static nscd_rc_t
_nscd_add_getent_ctx(
    nscd_getent_context_t	*ptr,
    nscd_cookie_num_t	cookie_num)
{
    int			size;
    char			buf[32];
    nscd_db_entry_t		*db_entry;
    nscd_getent_ctx_t	*gnctx;

    if (ptr == NULL)
        return (NSCD_INVALID_ARGUMENT);

    (void) snprintf(buf, sizeof (buf), "%lld", cookie_num);

    size = sizeof (*gnctx);

    db_entry = _nscd_alloc_db_entry(NSCD_DATA_CTX_ADDR,
                                    (const char *)buf, size, 1, 1);
    if (db_entry == NULL)
        return (NSCD_NO_MEMORY);

    gnctx = (nscd_getent_ctx_t *)*(db_entry->data_array);
    gnctx->ptr = ptr;
    gnctx->cookie_num = cookie_num;

    (void) rw_wrlock(&getent_ctxDB_rwlock);
    (void) _nscd_add_db_entry(getent_ctxDB, buf, db_entry,
                              NSCD_ADD_DB_ENTRY_FIRST);
    (void) rw_unlock(&getent_ctxDB_rwlock);

    return (NSCD_SUCCESS);
}
开发者ID:mikess,项目名称:illumos-gate,代码行数:38,代码来源:nscd_getentctx.c

示例7: dfs_root_remove

/*
 * Deletes the specified root information
 */
static uint32_t
dfs_root_remove(const char *rootdir)
{
	int attrdirfd;
	int err = 0;

	(void) rw_wrlock(&dfs_root_rwl);

	if ((attrdirfd = attropen(rootdir, ".", O_RDONLY)) > 0) {
		if (unlinkat(attrdirfd, DFS_ROOT_XATTR, 0) == -1) {
			if (errno != ENOENT)
				err = errno;
		}
		(void) close(attrdirfd);
	} else {
		err = errno;
	}

	(void) rw_unlock(&dfs_root_rwl);

	if (err != 0) {
		syslog(LOG_DEBUG, "dfs: failed to remove root info %s (%d)",
		    rootdir, err);
		return (ERROR_INTERNAL_ERROR);
	}

	return (ERROR_SUCCESS);
}
开发者ID:bahamas10,项目名称:openzfs,代码行数:31,代码来源:dfs.c

示例8: mi_rsame

int 
mi_rsame(MI_INFO * info, byte * record, int inx)
{
	DBUG_ENTER("mi_rsame");

	if (inx != -1 && !(((ulonglong) 1 << inx) & info->s->state.key_map)) {
		DBUG_RETURN(my_errno = HA_ERR_WRONG_INDEX);
	}
	if (info->lastpos == HA_OFFSET_ERROR || info->update & HA_STATE_DELETED) {
		DBUG_RETURN(my_errno = HA_ERR_KEY_NOT_FOUND);	/* No current record */
	}
	info->update &= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);

	/* Read row from data file */
	if (_mi_readinfo(info, F_RDLCK, 1))
		DBUG_RETURN(my_errno);

	if (inx >= 0) {
		info->lastinx = inx;
		info->lastkey_length = _mi_make_key(info, (uint) inx, info->lastkey, record,
						    info->lastpos);
		if (info->s->concurrent_insert)
			rw_rdlock(&info->s->key_root_lock[inx]);
		VOID(_mi_search(info, info->s->keyinfo + inx, info->lastkey, 0, SEARCH_SAME,
				info->s->state.key_root[inx]));
		if (info->s->concurrent_insert)
			rw_unlock(&info->s->key_root_lock[inx]);
	}
	if (!(*info->read_record) (info, info->lastpos, record))
		DBUG_RETURN(0);
	if (my_errno == HA_ERR_RECORD_DELETED)
		my_errno = HA_ERR_KEY_NOT_FOUND;
	DBUG_RETURN(my_errno);
}				/* mi_rsame */
开发者ID:NickeyWoo,项目名称:mysql-3.23.49,代码行数:34,代码来源:mi_rsame.c

示例9: mntlist_new

void
mntlist_new(char *host, char *path)
{
    (void) rw_wrlock(&rmtab_lock);
    mntlist_insert(host, path);
    (void) rw_unlock(&rmtab_lock);
}
开发者ID:CoryXie,项目名称:opensolaris,代码行数:7,代码来源:rmtab.c

示例10: create_server

int create_server(THD *thd, LEX_SERVER_OPTIONS *server_options)
{
  int error= ER_FOREIGN_SERVER_EXISTS;
  FOREIGN_SERVER *server;

  DBUG_ENTER("create_server");
  DBUG_PRINT("info", ("server_options->server_name %s",
                      server_options->server_name));

  rw_wrlock(&THR_LOCK_servers);

  /* hit the memory first */
  if (hash_search(&servers_cache, (uchar*) server_options->server_name,
				   server_options->server_name_length))
    goto end;


  if (!(server= prepare_server_struct_for_insert(server_options)))
  {
    /* purecov: begin inspected */
    error= ER_OUT_OF_RESOURCES;
    goto end;
    /* purecov: end */
  }

  error= insert_server(thd, server);

  DBUG_PRINT("info", ("error returned %d", error));

end:
  rw_unlock(&THR_LOCK_servers);
  DBUG_RETURN(error);
}
开发者ID:Abner-Sun,项目名称:mysql5.1-vx6-export22,代码行数:33,代码来源:sql_servers.cpp

示例11: mntlist_delete_all

void
mntlist_delete_all(char *host)
{
    HASHSET_ITERATOR iterator;
    struct mntentry *m;

    (void) rw_wrlock(&rmtab_lock);

    iterator = h_iterator(mntlist);

    while (m = (struct mntentry *)h_next(iterator)) {
        if (strcasecmp(m->m_host, host))
            continue;

        rmtab_delete(m->m_pos);

        (void) h_delete(mntlist, m);

        free(m->m_path);
        free(m->m_host);
        free(m);
    }

    if (RMTAB_TOOMANY_DELETED())
        rmtab_rewrite();

    (void) rw_unlock(&rmtab_lock);

    if (iterator != NULL)
        free(iterator);
}
开发者ID:CoryXie,项目名称:opensolaris,代码行数:31,代码来源:rmtab.c

示例12: picld_wait

/*
 * picld_wait is called when a picl_wait request is received
 */
static void
picld_wait(picl_service_t *in)
{
	picl_retwait_t	ret;
	int		err;
	ucred_t	*puc = NULL;
	uid_t uid;

	ret.cnum = in->req_wait.cnum;
	if (door_ucred(&puc) != 0)
		ret.retcode = PICL_FAILURE;
	else {
		uid = ucred_geteuid(puc);
		if (enter_picld_wait(uid) == PICL_FAILURE)
			ret.retcode = PICL_FAILURE;
		else {
			err = xptree_refresh_notify(in->req_wait.secs);
			ret.retcode = err;
			exit_picld_wait(uid);
		}
		ucred_free(puc);
	}
	(void) rw_unlock(&init_lk);
	(void) door_return((char *)&ret, sizeof (picl_retwait_t), NULL, 0);
}
开发者ID:AlainODea,项目名称:illumos-gate,代码行数:28,代码来源:picld.c

示例13: solaris_locking_callback

void solaris_locking_callback(int mode, int type, char *file, int line)
{
# if 0
    fprintf(stderr, "thread=%4d mode=%s lock=%s %s:%d\n",
            CRYPTO_thread_id(),
            (mode & CRYPTO_LOCK) ? "l" : "u",
            (type & CRYPTO_READ) ? "r" : "w", file, line);
# endif

# if 0
    if (CRYPTO_LOCK_SSL_CERT == type)
        fprintf(stderr, "(t,m,f,l) %ld %d %s %d\n",
                CRYPTO_thread_id(), mode, file, line);
# endif
    if (mode & CRYPTO_LOCK) {
# ifdef USE_MUTEX
        mutex_lock(&(lock_cs[type]));
# else
        if (mode & CRYPTO_READ)
            rw_rdlock(&(lock_cs[type]));
        else
            rw_wrlock(&(lock_cs[type]));
# endif
        lock_count[type]++;
    } else {
# ifdef USE_MUTEX
        mutex_unlock(&(lock_cs[type]));
# else
        rw_unlock(&(lock_cs[type]));
# endif
    }
}
开发者ID:asb,项目名称:frankenlibc,代码行数:32,代码来源:th-lock.c

示例14: smb_nic_fini

/*
 * smb_nic_fini
 *
 * Destroys the interface list.
 */
void
smb_nic_fini(void)
{
	(void) rw_wrlock(&smb_niclist.nl_rwl);
	smb_nic_list_destroy();
	(void) rw_unlock(&smb_niclist.nl_rwl);
}
开发者ID:bahamas10,项目名称:openzfs,代码行数:12,代码来源:smb_nic.c

示例15: smb_nic_getnext

/*
 * smb_nic_getnext
 *
 * Returns the next NIC information based on the passed
 * iterator (ni). The iterator must have previously been
 * initialized by calling smb_nic_getfirst().
 *
 * Returns SMB_NIC_SUCCESS upon successfully finding the specified NIC
 * or the following:
 * 	SMB_NIC_INVALID_ARG - the specified iterator is invalid
 * 	SMB_NIC_NO_MORE - reaches the end of the NIC list
 * 	SMB_NIC_CHANGED - sequence number in the iterator is different from
 *	  the sequence number in the NIC list which means
 *	  the list has been changed between getfirst/getnext
 *	  calls.
 */
int
smb_nic_getnext(smb_niciter_t *ni)
{
	int rc = SMB_NIC_SUCCESS;

	if ((ni == NULL) || (ni->ni_cookie < 1))
		return (SMB_NIC_INVALID_ARG);

	(void) rw_rdlock(&smb_niclist.nl_rwl);

	if ((smb_niclist.nl_cnt > ni->ni_cookie) &&
	    (smb_niclist.nl_seqnum == ni->ni_seqnum)) {
		ni->ni_nic = smb_niclist.nl_nics[ni->ni_cookie];
		ni->ni_cookie++;
	} else {
		if (smb_niclist.nl_seqnum != ni->ni_seqnum)
			rc = SMB_NIC_CHANGED;
		else
			rc = SMB_NIC_NO_MORE;
	}

	(void) rw_unlock(&smb_niclist.nl_rwl);

	return (rc);
}
开发者ID:bahamas10,项目名称:openzfs,代码行数:41,代码来源:smb_nic.c


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