Lines Matching refs:groupp
79 free_group(vntsd_group_t *groupp) in free_group() argument
81 assert(groupp); in free_group()
82 (void) mutex_destroy(&groupp->lock); in free_group()
83 (void) cond_destroy(&groupp->cvp); in free_group()
84 if (groupp->sockfd != -1) in free_group()
85 (void) close(groupp->sockfd); in free_group()
86 free(groupp); in free_group()
96 vntsd_group_t *groupp; in cleanup_cons() local
103 groupp = consp->group; in cleanup_cons()
104 assert(groupp); in cleanup_cons()
126 (void) mutex_lock(&groupp->lock); in cleanup_cons()
127 assert(groupp->num_cons > 0); in cleanup_cons()
128 groupp->num_cons--; in cleanup_cons()
129 (void) mutex_unlock(&groupp->lock); in cleanup_cons()
138 find_clean_cons_group(vntsd_group_t *groupp) in find_clean_cons_group() argument
140 if (groupp->status & VNTSD_GROUP_CLEAN_CONS) { in find_clean_cons_group()
162 vntsd_group_t *groupp; in vntsd_delete_cons() local
168 groupp = vntsd_que_walk(vntsdp->grouppq, in vntsd_delete_cons()
170 if (groupp == NULL) { in vntsd_delete_cons()
175 (void) mutex_lock(&groupp->lock); in vntsd_delete_cons()
176 groupp->status &= ~VNTSD_GROUP_CLEAN_CONS; in vntsd_delete_cons()
177 (void) mutex_unlock(&groupp->lock); in vntsd_delete_cons()
182 (void) mutex_lock(&groupp->lock); in vntsd_delete_cons()
185 if (groupp->conspq != NULL) { in vntsd_delete_cons()
186 consp = vntsd_que_walk(groupp->conspq, in vntsd_delete_cons()
190 (void) mutex_unlock(&groupp->lock); in vntsd_delete_cons()
195 (void) vntsd_que_rm(&groupp->conspq, consp); in vntsd_delete_cons()
196 (void) mutex_unlock(&groupp->lock); in vntsd_delete_cons()
203 if (groupp->conspq == NULL) { in vntsd_delete_cons()
205 assert(groupp->vntsd); in vntsd_delete_cons()
207 (void) mutex_lock(&groupp->vntsd->lock); in vntsd_delete_cons()
208 (void) vntsd_que_rm(&groupp->vntsd->grouppq, in vntsd_delete_cons()
209 groupp); in vntsd_delete_cons()
210 (void) mutex_unlock(&groupp->vntsd->lock); in vntsd_delete_cons()
213 vntsd_clean_group(groupp); in vntsd_delete_cons()
222 vntsd_clean_group(vntsd_group_t *groupp) in vntsd_clean_group() argument
228 groupp->group_name, groupp->tcp_port); in vntsd_clean_group()
230 (void) mutex_lock(&groupp->lock); in vntsd_clean_group()
233 if (groupp->status & VNTSD_GROUP_IN_CLEANUP) { in vntsd_clean_group()
234 (void) mutex_unlock(&groupp->lock); in vntsd_clean_group()
237 groupp->status |= VNTSD_GROUP_IN_CLEANUP; in vntsd_clean_group()
240 groupp->status |= VNTSD_GROUP_SIG_WAIT; in vntsd_clean_group()
241 (void) mutex_unlock(&groupp->lock); in vntsd_clean_group()
243 vntsd_free_que(&groupp->conspq, (clean_func_t)cleanup_cons); in vntsd_clean_group()
245 (void) mutex_lock(&groupp->lock); in vntsd_clean_group()
247 while (groupp->no_cons_clientpq != NULL) { in vntsd_clean_group()
248 (void) vntsd_que_walk(groupp->no_cons_clientpq, in vntsd_clean_group()
252 (void) cond_reltimedwait(&groupp->cvp, &groupp->lock, &to); in vntsd_clean_group()
256 while (groupp->status & VNTSD_GROUP_SIG_WAIT) { in vntsd_clean_group()
258 (void) thr_kill(groupp->listen_tid, SIGUSR1); in vntsd_clean_group()
262 (void) cond_reltimedwait(&groupp->cvp, &groupp->lock, &to); in vntsd_clean_group()
265 (void) mutex_unlock(&groupp->lock); in vntsd_clean_group()
266 (void) thr_join(groupp->listen_tid, NULL, NULL); in vntsd_clean_group()
268 free_group(groupp); in vntsd_clean_group()
273 alloc_cons(vntsd_group_t *groupp, vcc_console_t *consolep) in alloc_cons() argument
298 (void) mutex_lock(&groupp->lock); in alloc_cons()
300 if ((rv = vntsd_que_append(&groupp->conspq, consp)) != in alloc_cons()
302 (void) mutex_unlock(&groupp->lock); in alloc_cons()
307 groupp->num_cons++; in alloc_cons()
308 consp->group = groupp; in alloc_cons()
310 (void) mutex_unlock(&groupp->lock); in alloc_cons()
320 grp_by_tcp(vntsd_group_t *groupp, uint64_t *tcp_port) in grp_by_tcp() argument
322 assert(groupp); in grp_by_tcp()
324 return (groupp->tcp_port == *tcp_port); in grp_by_tcp()
331 vntsd_group_t *groupp; in alloc_group() local
334 groupp = (vntsd_group_t *)malloc(sizeof (vntsd_group_t)); in alloc_group()
335 if (groupp == NULL) { in alloc_group()
341 bzero(groupp, sizeof (vntsd_group_t)); in alloc_group()
343 (void) mutex_init(&groupp->lock, USYNC_THREAD|LOCK_ERRORCHECK, NULL); in alloc_group()
344 (void) cond_init(&groupp->cvp, USYNC_THREAD, NULL); in alloc_group()
347 (void) memcpy(groupp->group_name, group_name, MAXPATHLEN); in alloc_group()
350 groupp->tcp_port = tcp_port; in alloc_group()
351 groupp->listen_tid = (thread_t)-1; in alloc_group()
352 groupp->sockfd = -1; in alloc_group()
353 groupp->vntsd = vntsdp; in alloc_group()
355 D1(stderr, "t@%d alloc_group@%lld:%s\n", thr_self(), groupp->tcp_port, in alloc_group()
356 groupp->group_name); in alloc_group()
358 return (groupp); in alloc_group()
379 vntsd_group_t *groupp = NULL; in alloc_cons_with_group() local
388 groupp = vntsd_que_find(vntsdp->grouppq, in alloc_cons_with_group()
390 if (groupp != NULL) in alloc_cons_with_group()
391 (void) mutex_lock(&groupp->lock); in alloc_cons_with_group()
395 if (groupp != NULL) { in alloc_cons_with_group()
415 if (vntsd_chk_group_total_cons(groupp) == 0) { in alloc_cons_with_group()
418 (void) vntsd_que_walk(groupp->conspq, in alloc_cons_with_group()
420 groupp->status |= VNTSD_GROUP_CLEAN_CONS; in alloc_cons_with_group()
421 (void) mutex_unlock(&groupp->lock); in alloc_cons_with_group()
422 groupp = NULL; in alloc_cons_with_group()
424 } else if (strcmp(groupp->group_name, consp->group_name)) { in alloc_cons_with_group()
428 (void) mutex_unlock(&groupp->lock); in alloc_cons_with_group()
433 (void) mutex_unlock(&groupp->lock); in alloc_cons_with_group()
438 if (groupp == NULL) { in alloc_cons_with_group()
440 groupp = alloc_group(vntsdp, consp->group_name, in alloc_cons_with_group()
442 if (groupp == NULL) { in alloc_cons_with_group()
446 assert(groupp->conspq == NULL); in alloc_cons_with_group()
449 rv = vntsd_que_append(&vntsdp->grouppq, groupp); in alloc_cons_with_group()
456 *new_groupp = groupp; in alloc_cons_with_group()
460 if (alloc_cons(groupp, consp) == NULL) { in alloc_cons_with_group()
464 free_group(groupp); in alloc_cons_with_group()
477 create_listen_thread(vntsd_group_t *groupp) in create_listen_thread() argument
483 assert(groupp); in create_listen_thread()
485 (void) mutex_lock(&groupp->lock); in create_listen_thread()
486 assert(groupp->num_cons); in create_listen_thread()
488 D1(stderr, "t@%d create_listen:%lld\n", thr_self(), groupp->tcp_port); in create_listen_thread()
491 (void *)groupp, THR_DETACHED, &groupp->listen_tid)) in create_listen_thread()
495 "group %s tcp %llx\n", groupp->group_name, in create_listen_thread()
496 groupp->tcp_port); in create_listen_thread()
500 vntsd_free_que(&groupp->conspq, (clean_func_t)free_cons); in create_listen_thread()
501 groupp->listen_tid = (thread_t)-1; in create_listen_thread()
504 (void) mutex_unlock(&groupp->lock); in create_listen_thread()
540 find_cons_group_by_cons_no(vntsd_group_t *groupp, uint_t *cons_no) in find_cons_group_by_cons_no() argument
544 consp = vntsd_que_find(groupp->conspq, in find_cons_group_by_cons_no()
554 vntsd_group_t *groupp; in delete_cons_before_add() local
559 groupp = vntsd_que_find(vntsdp->grouppq, in delete_cons_before_add()
564 if (groupp == NULL) { in delete_cons_before_add()
570 (void) mutex_lock(&groupp->lock); in delete_cons_before_add()
571 consp = vntsd_que_find(groupp->conspq, in delete_cons_before_add()
576 (void) mutex_unlock(&groupp->lock); in delete_cons_before_add()
586 (void) mutex_unlock(&groupp->lock); in delete_cons_before_add()
591 groupp->status |= VNTSD_GROUP_CLEAN_CONS; in delete_cons_before_add()
594 (void) mutex_unlock(&groupp->lock); in delete_cons_before_add()
603 vntsd_group_t *groupp; in do_add_cons() local
624 if ((rv = alloc_cons_with_group(vntsdp, &console, &groupp)) != in do_add_cons()
631 if (groupp != NULL) { in do_add_cons()
634 if (create_listen_thread(groupp)) { in do_add_cons()
636 free_group(groupp); in do_add_cons()
685 vntsd_group_t *groupp; in vntsd_get_config() local
719 if (alloc_cons_with_group(vntsdp, &consp[i], &groupp) in vntsd_get_config()
729 groupp = vntsd_que_walk(vntsdp->grouppq, in vntsd_get_config()
731 if (groupp == NULL) { in vntsd_get_config()