本文整理汇总了C++中rwlock_unlock函数的典型用法代码示例。如果您正苦于以下问题:C++ rwlock_unlock函数的具体用法?C++ rwlock_unlock怎么用?C++ rwlock_unlock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rwlock_unlock函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: sys_chdir
int sys_chdir (char *pathname)
{
register error_t err = 0;
register struct thread_s *this;
register struct task_s *task;
this = current_thread;
task = current_task;
if(!pathname)
{
this->info.errno = EINVAL;
return -1;
}
rwlock_wrlock(&task->cwd_lock);
if((err = vfs_chdir(pathname, task->vfs_cwd, &task->vfs_cwd)))
{
rwlock_unlock(&task->cwd_lock);
this->info.errno = (err < 0) ? -err : err;
return -1;
}
rwlock_unlock(&task->cwd_lock);
return 0;
}
开发者ID:Masshat,项目名称:almos,代码行数:27,代码来源:sys_chdir.c
示例2: rpc_dplx_lookup_rec
struct rpc_dplx_rec *
rpc_dplx_lookup_rec(int fd, uint32_t iflags, uint32_t *oflags)
{
struct rbtree_x_part *t;
struct rpc_dplx_rec rk, *rec = NULL;
struct opr_rbtree_node *nv;
cond_init_rpc_dplx();
rk.fd_k = fd;
t = rbtx_partition_of_scalar(&(rpc_dplx_rec_set.xt), fd);
rwlock_rdlock(&t->lock);
nv = opr_rbtree_lookup(&t->t, &rk.node_k);
/* XXX rework lock+insert case, so that new entries are inserted
* locked, and t->lock critical section is reduced */
if (! nv) {
rwlock_unlock(&t->lock);
rwlock_wrlock(&t->lock);
nv = opr_rbtree_lookup(&t->t, &rk.node_k);
if (! nv) {
rec = alloc_dplx_rec();
if (! rec) {
__warnx(TIRPC_DEBUG_FLAG_LOCK,
"%s: failed allocating rpc_dplx_rec", __func__);
goto unlock;
}
/* tell the caller */
*oflags = RPC_DPLX_LKP_OFLAG_ALLOC;
rec->fd_k = fd;
if (opr_rbtree_insert(&t->t, &rec->node_k)) {
/* cant happen */
__warnx(TIRPC_DEBUG_FLAG_LOCK,
"%s: collision inserting in locked rbtree partition",
__func__);
free_dplx_rec(rec);
}
}
}
else {
rec = opr_containerof(nv, struct rpc_dplx_rec, node_k);
*oflags = RPC_DPLX_LKP_FLAG_NONE;
}
rpc_dplx_ref(rec, (iflags & RPC_DPLX_LKP_IFLAG_LOCKREC) ?
RPC_DPLX_FLAG_LOCK :
RPC_DPLX_FLAG_NONE);
unlock:
rwlock_unlock(&t->lock);
return (rec);
}
开发者ID:vganapathi,项目名称:ntirpc,代码行数:58,代码来源:rpc_dplx.c
示例3: check_args
/* TODO: don't use locks to lookup region as if address has been accessed it must be in kyesdb */
static error_t check_args(struct vmm_s *vmm, uint_t start, uint_t len, struct vm_region_s **reg)
{
error_t err;
struct vm_region_s *region;
err = 0;
rwlock_rdlock(&vmm->rwlock);
region = vmm->last_region;
if((start >= region->vm_limit) || (start < region->vm_start))
{
region = vm_region_find(vmm, start);
if((region == NULL) || (start < region->vm_start))
err = EINVAL;
}
if((err == 0) && ((start + len) >= region->vm_limit))
err = EINVAL;
rwlock_unlock(&vmm->rwlock);
*reg = region;
return 0;
}
开发者ID:Masshat,项目名称:almos,代码行数:27,代码来源:sys_madvise.c
示例4: get_user_by_sockaddr
int get_user_by_sockaddr(struct sockaddr_storage *sa, size_t sa_len,
struct curve25519_proto **proto)
{
int ret = -1;
struct sockaddr_map_entry *entry;
unsigned int hash = hash_name((char *) sa, sa_len);
errno = 0;
rwlock_rd_lock(&sockaddr_map_lock);
entry = lookup_hash(hash, &sockaddr_mapper);
while (entry && entry->sa_len == sa_len &&
memcmp(sa, entry->sa, entry->sa_len))
entry = entry->next;
if (entry && entry->sa_len == sa_len &&
!memcmp(sa, entry->sa, entry->sa_len)) {
(*proto) = entry->proto;
ret = 0;
} else {
(*proto) = NULL;
errno = ENOENT;
}
rwlock_unlock(&sockaddr_map_lock);
return ret;
}
开发者ID:hhatto,项目名称:netsniff-ng,代码行数:28,代码来源:ct_usermgmt.c
示例5: remove_user_by_sockaddr
void remove_user_by_sockaddr(struct sockaddr_storage *sa, size_t sa_len)
{
struct sockaddr_map_entry *pos;
struct sockaddr_map_entry *entry;
unsigned int hash = hash_name((char *) sa, sa_len);
entry = sockaddr_to_sockaddr_map_entry(sa, sa_len);
if (!entry)
return;
rwlock_wr_lock(&sockaddr_map_lock);
pos = remove_hash(hash, entry, entry->next, &sockaddr_mapper);
while (pos && pos->next && pos->next != entry)
pos = pos->next;
if (pos && pos->next && pos->next == entry)
pos->next = entry->next;
memset(entry->proto->enonce, 0, sizeof(entry->proto->enonce));
memset(entry->proto->dnonce, 0, sizeof(entry->proto->dnonce));
entry->proto = NULL;
entry->next = NULL;
xfree(entry->sa);
xfree(entry);
rwlock_unlock(&sockaddr_map_lock);
}
开发者ID:hhatto,项目名称:netsniff-ng,代码行数:29,代码来源:ct_usermgmt.c
示例6: register_user_by_sockaddr
static int register_user_by_sockaddr(struct sockaddr_storage *sa,
size_t sa_len,
struct curve25519_proto *proto)
{
void **pos;
struct sockaddr_map_entry *entry;
unsigned int hash = hash_name((char *) sa, sa_len);
rwlock_wr_lock(&sockaddr_map_lock);
entry = xzmalloc(sizeof(*entry));
entry->sa = xmemdupz(sa, sa_len);
entry->sa_len = sa_len;
entry->proto = proto;
pos = insert_hash(hash, entry, &sockaddr_mapper);
if (pos) {
entry->next = (*pos);
(*pos) = entry;
}
rwlock_unlock(&sockaddr_map_lock);
return 0;
}
开发者ID:hhatto,项目名称:netsniff-ng,代码行数:25,代码来源:ct_usermgmt.c
示例7: svc_run
void
svc_run()
{
fd_set readfds, cleanfds;
struct timeval timeout;
timeout.tv_sec = 30;
timeout.tv_usec = 0;
for (;;) {
rwlock_rdlock(&svc_fd_lock);
readfds = svc_fdset;
cleanfds = svc_fdset;
rwlock_unlock(&svc_fd_lock);
switch (_select(svc_maxfd+1, &readfds, NULL, NULL, &timeout)) {
case -1:
FD_ZERO(&readfds);
if (errno == EINTR) {
continue;
}
_warn("svc_run: - select failed");
return;
case 0:
__svc_clean_idle(&cleanfds, 30, FALSE);
continue;
default:
svc_getreqset(&readfds);
}
}
}
开发者ID:AhmadTux,项目名称:freebsd,代码行数:30,代码来源:svc_run.c
示例8: sys_getcwd
int sys_getcwd (char *buff, size_t size)
{
register struct thread_s *this;
register struct task_s *task;
register error_t err;
struct ku_obj ku_buff;
this = current_thread;
task = current_task;
if((size < VFS_MAX_NAME_LENGTH) || (!buff))
{
err = ERANGE;
goto SYS_GETCWD_ERROR;
}
if(vmm_check_address("usr cwd buffer", task, buff, size))
{
err = EFAULT;
goto SYS_GETCWD_ERROR;
}
KU_SZ_BUFF(ku_buff, buff, size);
rwlock_rdlock(&task->cwd_lock);
err = vfs_get_path(&task->vfs_cwd, &ku_buff);
rwlock_unlock(&task->cwd_lock);
SYS_GETCWD_ERROR:
this->info.errno = err;
return (int)buff;
}
开发者ID:walafc0,项目名称:almos-mk,代码行数:35,代码来源:sys_getcwd.c
示例9: svc_exit
/*
* This function causes svc_run() to exit by telling it that it has no
* more work to do.
*/
void
svc_exit()
{
rwlock_wrlock(&svc_fd_lock);
FD_ZERO(&svc_fdset);
rwlock_unlock(&svc_fd_lock);
}
开发者ID:AhmadTux,项目名称:freebsd,代码行数:11,代码来源:svc_run.c
示例10: trie_cleanup
void trie_cleanup(void)
{
rwlock_wr_lock(&tree_lock);
ptree_free(tree);
rwlock_unlock(&tree_lock);
rwlock_destroy(&tree_lock);
}
开发者ID:Bracksun,项目名称:netsniff-ng,代码行数:7,代码来源:trie.c
示例11: elf_rawfile
char *
elf_rawfile (Elf *elf, size_t *ptr)
{
char *result;
if (elf == NULL)
{
/* No valid descriptor. */
__libelf_seterrno (ELF_E_INVALID_HANDLE);
error_out:
if (ptr != NULL)
*ptr = 0;
return NULL;
}
/* If the file is not mmap'ed and not previously loaded, do it now. */
if (elf->map_address == NULL && __libelf_readall (elf) == NULL)
goto error_out;
rwlock_rdlock (elf->lock);
if (ptr != NULL)
*ptr = elf->maximum_size;
result = (char *) elf->map_address + elf->start_offset;
rwlock_unlock (elf->lock);
return result;
}
开发者ID:Distrotech,项目名称:elfutils,代码行数:28,代码来源:elf_rawfile.c
示例12: remove_user_by_socket
void remove_user_by_socket(int fd)
{
struct sock_map_entry *pos;
struct sock_map_entry *entry = socket_to_sock_map_entry(fd);
if (!entry)
return;
rwlock_wr_lock(&sock_map_lock);
pos = remove_hash(entry->fd, entry, entry->next, &sock_mapper);
while (pos && pos->next && pos->next != entry)
pos = pos->next;
if (pos && pos->next && pos->next == entry)
pos->next = entry->next;
memset(entry->proto->enonce, 0, sizeof(entry->proto->enonce));
memset(entry->proto->dnonce, 0, sizeof(entry->proto->dnonce));
entry->proto = NULL;
entry->next = NULL;
xfree(entry);
rwlock_unlock(&sock_map_lock);
}
开发者ID:hhatto,项目名称:netsniff-ng,代码行数:26,代码来源:ct_usermgmt.c
示例13: thread_func
static void* thread_func(void* arg)
{
int i;
int sum = 0;
for (i = 0; i < 1000; i++)
{
rwlock_rdlock(&s_rwlock);
sum += s_counter;
rwlock_unlock(&s_rwlock);
rwlock_wrlock(&s_rwlock);
s_counter++;
rwlock_unlock(&s_rwlock);
}
return 0;
}
开发者ID:cherry-wb,项目名称:SmartFuzz,代码行数:17,代码来源:annotate_rwlock.c
示例14: pclose
/*
* pclose --
* Pclose returns -1 if stream is not associated with a `popened' command,
* if already `pclosed', or waitpid returns an error.
*/
int
pclose(FILE *iop)
{
struct pid *cur, *last;
int pstat;
pid_t pid;
_DIAGASSERT(iop != NULL);
rwlock_wrlock(&pidlist_lock);
/* Find the appropriate file pointer. */
for (last = NULL, cur = pidlist; cur; last = cur, cur = cur->next)
if (cur->fp == iop)
break;
if (cur == NULL) {
#if defined(__minix)
rwlock_unlock(&pidlist_lock);
#else
(void)rwlock_unlock(&pidlist_lock);
#endif /* defined(__minix) */
return (-1);
}
(void)fclose(iop);
/* Remove the entry from the linked list. */
if (last == NULL)
pidlist = cur->next;
else
last->next = cur->next;
#if defined(__minix)
rwlock_unlock(&pidlist_lock);
#else
(void)rwlock_unlock(&pidlist_lock);
#endif /* defined(__minix) */
do {
pid = waitpid(cur->pid, &pstat, 0);
} while (pid == -1 && errno == EINTR);
free(cur);
return (pid == -1 ? -1 : pstat);
}
开发者ID:Hooman3,项目名称:minix,代码行数:51,代码来源:popen.c
示例15: parse_userfile_and_generate_user_store_or_die
void parse_userfile_and_generate_user_store_or_die(char *homedir)
{
FILE *fp;
char path[PATH_MAX], buff[512];
int line = 1, ret, fd;
memset(path, 0, sizeof(path));
slprintf(path, sizeof(path), "%s/%s", homedir, FILE_CLIENTS);
rwlock_init(&store_lock);
rwlock_wr_lock(&store_lock);
fp = fopen(path, "r");
if (!fp)
panic("Cannot open client file!\n");
memset(buff, 0, sizeof(buff));
while (fgets(buff, sizeof(buff), fp) != NULL) {
buff[sizeof(buff) - 1] = 0;
/* A comment. Skip this line */
if (buff[0] == '#' || buff[0] == '\n') {
memset(buff, 0, sizeof(buff));
line++;
continue;
}
ret = parse_line(buff, homedir);
if (ret < 0)
panic("Cannot parse line %d from clients!\n", line);
line++;
memset(buff, 0, sizeof(buff));
}
fclose(fp);
if (store == NULL)
panic("No registered clients found!\n");
rwlock_unlock(&store_lock);
init_sock_mapper();
init_sockaddr_mapper();
/*
* Pubkey is also used as a hmac of the initial packet to check
* the integrity of the packet, so that we know if it's just random
* garbage or a 'valid' packet. Again, just for the integrity!
*/
memset(path, 0, sizeof(path));
slprintf(path, sizeof(path), "%s/%s", homedir, FILE_PUBKEY);
fd = open_or_die(path, O_RDONLY);
ret = read(fd, token, sizeof(token));
if (ret != crypto_auth_hmacsha512256_KEYBYTES)
panic("Cannot read public key!\n");
close(fd);
}
开发者ID:hhatto,项目名称:netsniff-ng,代码行数:58,代码来源:ct_usermgmt.c
示例16: kern_semaphore_create
/** Create a new semaphore.
* @param name Optional name for the semaphore, for debugging purposes.
* @param count Initial count of the semaphore.
* @param security Security attributes for the ACL. If NULL, default
* attributes will be constructed which grant full access
* to the semaphore to the calling process' user.
* @param rights Access rights for the handle.
* @param handlep Where to store handle to the semaphore.
* @return Status code describing result of the operation. */
status_t kern_semaphore_create(const char *name, size_t count,
const object_security_t *security, object_rights_t rights,
handle_t *handlep)
{
object_security_t ksecurity = { -1, -1, NULL };
user_semaphore_t *sem;
status_t ret;
if(!handlep)
return STATUS_INVALID_ARG;
if(security) {
ret = object_security_from_user(&ksecurity, security, true);
if(ret != STATUS_SUCCESS)
return ret;
}
/* Construct a default ACL if required. */
if(!ksecurity.acl) {
ksecurity.acl = kmalloc(sizeof(*ksecurity.acl), MM_WAIT);
object_acl_init(ksecurity.acl);
object_acl_add_entry(ksecurity.acl, ACL_ENTRY_USER, -1, SEMAPHORE_RIGHT_USAGE);
}
sem = kmalloc(sizeof(user_semaphore_t), MM_WAIT);
sem->id = id_allocator_alloc(&semaphore_id_allocator);
if(sem->id < 0) {
kfree(sem);
object_security_destroy(&ksecurity);
return STATUS_NO_SEMAPHORES;
}
if(name) {
ret = strndup_from_user(name, SEMAPHORE_NAME_MAX, &sem->name);
if(ret != STATUS_SUCCESS) {
id_allocator_free(&semaphore_id_allocator, sem->id);
kfree(sem);
object_security_destroy(&ksecurity);
return ret;
}
} else {
sem->name = NULL;
}
object_init(&sem->obj, &semaphore_object_type, &ksecurity, NULL);
object_security_destroy(&ksecurity);
semaphore_init(&sem->sem, (sem->name) ? sem->name : "user_semaphore", count);
refcount_set(&sem->count, 1);
rwlock_write_lock(&semaphore_tree_lock);
avl_tree_insert(&semaphore_tree, &sem->tree_link, sem->id, sem);
rwlock_unlock(&semaphore_tree_lock);
ret = object_handle_create(&sem->obj, NULL, rights, NULL, 0, NULL, NULL, handlep);
if(ret != STATUS_SUCCESS)
user_semaphore_release(sem);
return ret;
}
开发者ID:jiangxilong,项目名称:kiwi,代码行数:67,代码来源:semaphore.c
示例17: pe_begin
Pe *
pe_begin(int fildes, Pe_Cmd cmd, Pe *ref)
{
Pe *retval = NULL;
if (ref != NULL) {
rwlock_rdlock(ref->lock);
} else if (fcntl(fildes, F_GETFL) == -1 && errno == EBADF) {
__libpe_seterrno(PE_E_INVALID_FILE);
return NULL;
}
switch (cmd) {
case PE_C_NULL:
break;
case PE_C_READ_MMAP_PRIVATE:
if (ref != NULL && ref->cmd != PE_C_READ_MMAP_PRIVATE) {
__libpe_seterrno(PE_E_INVALID_CMD);
break;
}
/* fall through */
case PE_C_READ:
case PE_C_READ_MMAP:
if (ref != NULL)
retval = dup_pe(fildes, cmd, ref);
else
retval = read_file(fildes, ~((size_t)0), cmd,
NULL);
break;
case PE_C_RDWR:
case PE_C_RDWR_MMAP:
if (ref != NULL) {
if (ref->cmd != PE_C_RDWR &&
ref->cmd != PE_C_RDWR_MMAP &&
ref->cmd != PE_C_WRITE &&
ref->cmd != PE_C_WRITE_MMAP) {
__libpe_seterrno(PE_E_INVALID_CMD);
retval = NULL;
}
} else {
retval = read_file(fildes, ~((size_t) 0), cmd,
NULL);
}
break;
case PE_C_WRITE:
case PE_C_WRITE_MMAP:
retval = write_file(fildes, cmd);
break;
default:
__libpe_seterrno(PE_E_INVALID_CMD);
break;
}
if (ref != NULL)
rwlock_unlock(ref->lock);
return retval;
}
开发者ID:Caesius31,项目名称:pesign,代码行数:58,代码来源:pe_begin.c
示例18: neue_unlock
/**
* @brief This function is not called from anywhere and may be removed.
*/
void neue_unlock(neue_t *neue) {
if (neue) {
rwlock_unlock(&(neue->lock));
//log_pedantic("%20.li unlocking", thread_get_thread_id());
}
return;
}
开发者ID:503serviceunavailable,项目名称:magma,代码行数:12,代码来源:neue.c
示例19: destroy_sockaddr_mapper
static void destroy_sockaddr_mapper(void)
{
rwlock_wr_lock(&sockaddr_map_lock);
for_each_hash(&sockaddr_mapper, cleanup_batch_sockaddr_mapper);
free_hash(&sockaddr_mapper);
rwlock_unlock(&sockaddr_map_lock);
rwlock_destroy(&sockaddr_map_lock);
}
开发者ID:hhatto,项目名称:netsniff-ng,代码行数:9,代码来源:ct_usermgmt.c
示例20: get_serv_store_entry_by_alias
void get_serv_store_entry_by_alias(char *alias, size_t len,
char **host, char **port, int *udp)
{
struct server_store *elem;
rwlock_rd_lock(&store_lock);
elem = store;
if (!alias) {
while (elem && elem->next)
elem = elem->next;
if (elem) {
(*host) = elem->host;
(*port) = elem->port;
(*udp) = elem->udp;
selected = elem;
} else {
rwlock_unlock(&store_lock);
goto nothing;
}
} else {
while (elem) {
if (!strncmp(elem->alias, alias,
min(len, strlen(elem->alias) + 1)))
break;
elem = elem->next;
}
if (elem) {
(*host) = elem->host;
(*port) = elem->port;
(*udp) = elem->udp;
selected = elem;
} else {
rwlock_unlock(&store_lock);
goto nothing;
}
}
rwlock_unlock(&store_lock);
return;
nothing:
(*host) = NULL;
(*port) = NULL;
(*udp) = -1;
}
开发者ID:markusa,项目名称:netsniff-ng_filter,代码行数:44,代码来源:ct_servmgmt.c
注:本文中的rwlock_unlock函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论