Esempio n. 1
0
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);
}
Esempio n. 2
0
/*
 * 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);
}
Esempio n. 3
0
File: mttest.c Progetto: dhaley/dcp
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
}
Esempio n. 4
0
static void
sender_disconnect(void)
{

	rw_wlock(&adist_remote_lock);
	/*
	 * Check for a race between dropping rlock and acquiring wlock -
	 * another thread can close connection in-between.
	 */
	if (adhost->adh_remote == NULL) {
		rw_unlock(&adist_remote_lock);
		return;
	}
	pjdlog_debug(2, "Closing connection to %s.", adhost->adh_remoteaddr);
	proto_close(adhost->adh_remote);
	mtx_lock(&adist_remote_mtx);
	adhost->adh_remote = NULL;
	adhost->adh_reset = true;
	adhost->adh_trail_name[0] = '\0';
	adhost->adh_trail_offset = 0;
	mtx_unlock(&adist_remote_mtx);
	rw_unlock(&adist_remote_lock);

	pjdlog_warning("Disconnected from %s.", adhost->adh_remoteaddr);

	/* Move all in-flight requests back onto free list. */
	mtx_lock(&adist_free_list_lock);
	mtx_lock(&adist_send_list_lock);
	TAILQ_CONCAT(&adist_free_list, &adist_send_list, adr_next);
	mtx_unlock(&adist_send_list_lock);
	mtx_lock(&adist_recv_list_lock);
	TAILQ_CONCAT(&adist_free_list, &adist_recv_list, adr_next);
	mtx_unlock(&adist_recv_list_lock);
	mtx_unlock(&adist_free_list_lock);
}
Esempio n. 5
0
// ******************************************
// 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;
}
Esempio n. 6
0
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);
}
Esempio n. 7
0
/*
 * 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);
}
Esempio n. 8
0
/*
 * 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);
}
Esempio n. 9
0
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 */
Esempio n. 10
0
void
mntlist_new(char *host, char *path)
{
    (void) rw_wrlock(&rmtab_lock);
    mntlist_insert(host, path);
    (void) rw_unlock(&rmtab_lock);
}
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);
}
Esempio n. 12
0
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);
}
Esempio n. 13
0
int
unlock_rw(struct lock_object *lock)
{
  rw_unlock((struct rwlock *)lock);

  return (0);
}
Esempio n. 14
0
/*
 * 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);
}
Esempio n. 15
0
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
    }
}
Esempio n. 16
0
/*
 * 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);
}
Esempio n. 17
0
/*
 * 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);
}
Esempio n. 18
0
/*
 * This function returns the property information
 */
static void
picld_get_attrinfo(picl_service_t *in)
{
	picl_retattrinfo_t	ret;
	int			err;
	ptree_propinfo_t	pinfo;
	picl_prophdl_t		ptreeh;

	err = cvt_picl2ptree(in->req_attrinfo.attr, &ptreeh);
	if (err != PICL_SUCCESS)
		picld_return_error(in->in.cnum, err);

	ret.cnum = PICL_CNUM_GETATTRINFO;
	ret.attr = in->req_attrinfo.attr;

	err = ptree_get_propinfo(ptreeh, &pinfo);
	if (err != PICL_SUCCESS)
		picld_return_error(in->in.cnum, err);

	ret.type = pinfo.piclinfo.type;
	ret.accessmode = pinfo.piclinfo.accessmode;
	ret.size = (uint32_t)pinfo.piclinfo.size;
	(void) strcpy(ret.name, pinfo.piclinfo.name);
	(void) rw_unlock(&init_lk);
	(void) door_return((char *)&ret, sizeof (picl_retattrinfo_t), NULL, 0);
}
Esempio n. 19
0
void
smb_ipc_get_user(char *buf, size_t buflen)
{
	(void) rw_rdlock(&smb_ipc_lock);
	(void) strlcpy(buf, ipc_info.user, buflen);
	(void) rw_unlock(&smb_ipc_lock);
}
FOREIGN_SERVER *get_server_by_name(MEM_ROOT *mem, const char *server_name,
                                   FOREIGN_SERVER *buff)
{
  size_t server_name_length;
  FOREIGN_SERVER *server;
  DBUG_ENTER("get_server_by_name");
  DBUG_PRINT("info", ("server_name %s", server_name));

  server_name_length= strlen(server_name);

  if (! server_name || !strlen(server_name))
  {
    DBUG_PRINT("info", ("server_name not defined!"));
    DBUG_RETURN((FOREIGN_SERVER *)NULL);
  }

  DBUG_PRINT("info", ("locking servers_cache"));
  rw_rdlock(&THR_LOCK_servers);
  if (!(server= (FOREIGN_SERVER *) hash_search(&servers_cache,
                                               (uchar*) server_name,
                                               server_name_length)))
  {
    DBUG_PRINT("info", ("server_name %s length %u not found!",
                        server_name, (unsigned) server_name_length));
    server= (FOREIGN_SERVER *) NULL;
  }
  /* otherwise, make copy of server */
  else
    server= clone_server(mem, server, buff);

  DBUG_PRINT("info", ("unlocking servers_cache"));
  rw_unlock(&THR_LOCK_servers);
  DBUG_RETURN(server);

}
Esempio n. 21
0
/*
 * This function returns the value of the PICL property specified by
 * its name.
 */
static void
picld_get_attrval_by_name(picl_service_t *in)
{
	picl_retattrvalbyname_t	*ret;
	int			err;
	size_t			vbufsize;
	size_t			len;
	door_cred_t		cred;
	picl_nodehdl_t		ptreeh;
	ptree_propinfo_t	pinfo;

	if (door_cred(&cred) < 0)
		picld_return_error(in->in.cnum, PICL_FAILURE);

	err = cvt_picl2ptree(in->req_attrvalbyname.nodeh, &ptreeh);
	if (err != PICL_SUCCESS)
		picld_return_error(in->in.cnum, err);

	err = xptree_get_propinfo_by_name(ptreeh,
	    in->req_attrvalbyname.propname, &pinfo);
	if (err != PICL_SUCCESS)
		picld_return_error(in->in.cnum, err);

	if (!(pinfo.piclinfo.accessmode & PICL_READ))
		picld_return_error(in->in.cnum, PICL_NOTREADABLE);

	/*
	 * allocate the minimum of piclinfo.size and input bufsize
	 */
	vbufsize = pinfo.piclinfo.size;
	vbufsize = MIN((size_t)in->req_attrvalbyname.bufsize, vbufsize);
	len = sizeof (picl_retattrvalbyname_t) + vbufsize;
	ret = alloca(len);
	if (ret == NULL)
		picld_return_error(in->in.cnum, PICL_FAILURE);
	ret->cnum = PICL_CNUM_GETATTRVALBYNAME;
	ret->nodeh = in->req_attrvalbyname.nodeh;
	(void) strcpy(ret->propname, in->req_attrvalbyname.propname);
	ret->nbytes = (uint32_t)vbufsize;

	err = xptree_get_propval_by_name_with_cred(ptreeh,
	    in->req_attrvalbyname.propname, ret->ret_buf, vbufsize,
	    cred);
	if (err != PICL_SUCCESS)
		picld_return_error(in->in.cnum, err);
	/*
	 * adjust returned value size for charstrings
	 */
	if (pinfo.piclinfo.type == PICL_PTYPE_CHARSTRING)
		ret->nbytes = (uint32_t)strlen(ret->ret_buf) + 1;

	if ((pinfo.piclinfo.type == PICL_PTYPE_TABLE) ||
	    (pinfo.piclinfo.type == PICL_PTYPE_REFERENCE))
		cvt_ptree2picl(&ret->ret_nodeh);

	(void) rw_unlock(&init_lk);
	(void) door_return((char *)ret, sizeof (picl_retattrvalbyname_t) +
	    (size_t)ret->nbytes, NULL, 0);
}
Esempio n. 22
0
void
rw_downgrade(krwlock_t *rwlp)
{
	ASSERT(rwlp->rw_owner == _curthread());
	rwlp->rw_owner = _KTHREAD_INVALID;
	VERIFY(rw_unlock(&rwlp->rw_lock) == 0);
	VERIFY(rw_rdlock(&rwlp->rw_lock) == 0);
}
Esempio n. 23
0
File: mttest.c Progetto: dhaley/dcp
/* read_write: use a global Reader/Writer lock to process array's data */
void
read_write(Workblk *array, struct scripttab *k)
{

#ifdef SOLARIS
	switch (array->tid % NUM_OF_THREADS) {
	case 0:
	case 1:
	default:
	    rw_rdlock(&global_rw_lock);

	    array->ready = gethrtime();
	    array->vready = gethrvtime();

	    array->compute_ready = array->ready;
	    array->compute_vready = array->vready;

	    (k->called_func)(&array->list[0]);
	    array->compute_done = gethrtime();
	    array->compute_vdone = gethrvtime();

	    rw_unlock(&global_rw_lock);
	    break;

	case 2:
	    rw_wrlock(&global_rw_lock);

	    array->ready = gethrtime();
	    array->vready = gethrvtime();

	    array->compute_ready = array->ready;
	    array->compute_vready = array->vready;

	    (k->called_func)(&array->list[0]);

	    array->compute_done = gethrtime();
	    array->compute_vdone = gethrvtime();

	    rw_unlock(&global_rw_lock);
	    break;
	}
#endif

	/* make another call to preclude tail-call optimization on the unlock */
	(void) gethrtime();
}
Esempio n. 24
0
nscd_rc_t
_nscd_alloc_getent_ctx_base()
{

    (void) rw_wrlock(&nscd_getent_ctx_base_lock);

    nscd_getent_ctx_base = calloc(NSCD_NUM_DB,
                                  sizeof (nscd_getent_ctx_base_t *));
    if (nscd_getent_ctx_base == NULL) {
        (void) rw_unlock(&nscd_getent_ctx_base_lock);
        return (NSCD_NO_MEMORY);
    }

    (void) rw_unlock(&nscd_getent_ctx_base_lock);

    return (NSCD_SUCCESS);
}
Esempio n. 25
0
int
mi_rprev(MI_INFO * info, byte * buf, int inx)
{
    int		error     , changed;
    register uint	flag;
    MYISAM_SHARE   *share = info->s;
    DBUG_ENTER("mi_rprev");

    if ((inx = _mi_check_index(info, inx)) < 0)
        DBUG_RETURN(my_errno);
    flag = SEARCH_SMALLER;	/* Read previous */
    if (info->lastpos == HA_OFFSET_ERROR && info->update & HA_STATE_NEXT_FOUND)
        flag = 0;	/* Read last */

    if (_mi_readinfo(info, F_RDLCK, 1))
        DBUG_RETURN(my_errno);
    changed = _mi_test_if_changed(info);
    if (share->concurrent_insert)
        rw_rdlock(&share->key_root_lock[inx]);
    if (!flag)
        error = _mi_search_last(info, share->keyinfo + inx,
                                share->state.key_root[inx]);
    else if (!changed)
        error = _mi_search_next(info, share->keyinfo + inx, info->lastkey,
                                info->lastkey_length, flag,
                                share->state.key_root[inx]);
    else
        error = _mi_search(info, share->keyinfo + inx, info->lastkey,
                           info->lastkey_length, flag, share->state.key_root[inx]);

    if (!error) {
        while (info->lastpos >= info->state->data_file_length) {
            /*
             * Skip rows that are inserted by other threads since
             * we got a lock
             */
            if ((error = _mi_search_next(info, share->keyinfo + inx, info->lastkey,
                                         info->lastkey_length,
                                         SEARCH_SMALLER,
                                         share->state.key_root[inx])))
                break;
        }
    }
    if (share->concurrent_insert)
        rw_unlock(&share->key_root_lock[inx]);
    info->update &= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
    info->update |= HA_STATE_PREV_FOUND;
    if (error) {
        if (my_errno == HA_ERR_KEY_NOT_FOUND)
            my_errno = HA_ERR_END_OF_FILE;
    } else if (!buf) {
        DBUG_RETURN(info->lastpos == HA_OFFSET_ERROR ? my_errno : 0);
    } else if (!(*info->read_record) (info, info->lastpos, buf)) {
        info->update |= HA_STATE_AKTIV;	/* Record is read */
        DBUG_RETURN(0);
    }
    DBUG_RETURN(my_errno);
}				/* mi_rprev */
Esempio n. 26
0
boolean_t
smb_nic_is_same_subnet(smb_inaddr_t *ipaddr)
{
	smb_nic_t *cfg;
	int i;

	(void) rw_rdlock(&smb_niclist.nl_rwl);

	for (i = 0; i < smb_niclist.nl_cnt; i++) {
		cfg = &smb_niclist.nl_nics[i];
		if (smb_inet_same_subnet(ipaddr, &cfg->nic_ip, cfg->nic_mask)) {
			(void) rw_unlock(&smb_niclist.nl_rwl);
			return (B_TRUE);
		}
	}
	(void) rw_unlock(&smb_niclist.nl_rwl);
	return (B_FALSE);
}
Esempio n. 27
0
/* Interface for rpc.nisd and anyone else who wants to know */
int
__nis_group_cache_stats(int *grpcachecall, int *grpcachehits,
    int *grpcachemisses)
{
	(void) rw_rdlock(&g_cache_lock);
	if (groups_cache == 0) {
		*grpcachecall = 0;
		*grpcachehits = 0;
		*grpcachemisses = 0;
		(void) rw_unlock(&g_cache_lock);
		return (0);
	}
	*grpcachecall = groups_cache->ncalls;
	*grpcachehits = groups_cache->nhits;
	*grpcachemisses = groups_cache->nmisses;
	(void) rw_unlock(&g_cache_lock);
	return (1);
}
Esempio n. 28
0
void
rw_exit(krwlock_t *rwlp)
{
	if (_rw_write_held(&rwlp->rw_lock)) {
		ASSERT(rwlp->rw_owner == _curthread());
		rwlp->rw_owner = _KTHREAD_INVALID;
	}
	(void) rw_unlock(&rwlp->rw_lock);
}
Esempio n. 29
0
/*
 * Set the IPC username and password hash in memory.  If the domain
 * join succeeds, the credentials will be committed for use with
 * authenticated IPC.  Otherwise, they should be rolled back.
 */
void
smb_ipc_set(char *plain_user, uint8_t *passwd_hash)
{
	(void) rw_wrlock(&smb_ipc_lock);
	(void) strlcpy(ipc_info.user, plain_user, sizeof (ipc_info.user));
	(void) memcpy(ipc_info.passwd, passwd_hash, SMBAUTH_HASH_SZ);
	(void) rw_unlock(&smb_ipc_lock);

}
Esempio n. 30
0
/*
 * Save the host credentials to be used for authenticated IPC.
 * The credentials are also saved to the original IPC info as
 * rollback data in case the join domain process fails later.
 */
void
smb_ipc_commit(void)
{
	(void) rw_wrlock(&smb_ipc_lock);
	(void) smb_getsamaccount(ipc_info.user, SMB_USERNAME_MAXLEN);
	(void) smb_get_machine_passwd(ipc_info.passwd, SMBAUTH_HASH_SZ);
	(void) memcpy(&ipc_orig_info, &ipc_info, sizeof (smb_ipc_t));
	(void) rw_unlock(&smb_ipc_lock);
}