Lines Matching refs:sp
75 sess_rele(sess_t *sp, boolean_t pidlock_held)
79 mutex_enter(&sp->s_lock);
81 ASSERT(sp->s_ref != 0);
82 if (--sp->s_ref > 0) {
83 mutex_exit(&sp->s_lock);
86 ASSERT(sp->s_ref == 0);
103 if (sp == &session0)
104 panic("sp == &session0");
107 ASSERT(sp->s_cnt == 0);
110 ASSERT(!sp->s_exit);
113 ASSERT(sp->s_vp == NULL);
114 ASSERT(sp->s_dev == NODEV);
118 PID_RELE(sp->s_sidp);
122 mutex_destroy(&sp->s_lock);
123 cv_destroy(&sp->s_cnt_cv);
124 kmem_free(sp, sizeof (sess_t));
131 sess_t *sp;
139 sp = p->p_sessp;
140 mutex_enter(&sp->s_lock); /* protect sp->* */
143 ASSERT((sp->s_vp == NULL) ||
144 MUTEX_NOT_HELD(&sp->s_vp->v_stream->sd_lock));
155 if (!sp->s_exit)
159 sp->s_ref++;
163 if (!cv_wait_sig(&sp->s_exit_cv, &sp->s_lock))
171 mutex_exit(&sp->s_lock);
172 sess_rele(sp, B_FALSE);
179 sp->s_cnt++;
180 sp->s_ref++;
181 mutex_exit(&sp->s_lock);
183 return (sp);
187 tty_rele(sess_t *sp)
192 mutex_enter(&sp->s_lock);
193 if ((--sp->s_cnt) == 0)
194 cv_broadcast(&sp->s_cnt_cv);
195 mutex_exit(&sp->s_lock);
197 sess_rele(sp, B_FALSE);
204 sess_t *sp, *old_sp;
206 sp = kmem_zalloc(sizeof (sess_t), KM_SLEEP);
208 mutex_init(&sp->s_lock, NULL, MUTEX_DEFAULT, NULL);
209 cv_init(&sp->s_cnt_cv, NULL, CV_DEFAULT, NULL);
225 sp->s_sidp = p->p_pidp;
226 sp->s_ref = 1;
227 sp->s_dev = NODEV;
230 p->p_sessp = sp;
249 sess_ctty_clear(sess_t *sp, stdata_t *stp)
258 MUTEX_HELD(&sp->s_lock));
261 sp->s_sighuped = B_FALSE;
262 sp->s_dev = NODEV;
263 sp->s_vp = NULL;
264 sp->s_cred = NULL;
272 sess_ctty_set(proc_t *p, sess_t *sp, stdata_t *stp)
278 MUTEX_HELD(&p->p_splock) && MUTEX_HELD(&sp->s_lock));
284 PID_HOLD(sp->s_sidp); /* requires pidlock */
285 PID_HOLD(sp->s_sidp); /* requires pidlock */
288 sp->s_vp = makectty(stp->sd_vnode);
289 sp->s_dev = sp->s_vp->v_rdev;
290 sp->s_cred = crp;
294 stp->sd_sidp = sp->s_sidp;
295 stp->sd_pgidp = sp->s_sidp;
301 sess_t *sp;
320 sp = p->p_sessp;
321 mutex_enter(&sp->s_lock); /* protects sp->* */
325 (p->p_pidp != sp->s_sidp) || /* we're not leader? */
326 (sp->s_vp != NULL)) { /* session has ctty? */
327 mutex_exit(&sp->s_lock);
335 ASSERT(!sp->s_exit);
342 if (sp->s_cnt == 0)
346 sp->s_ref++;
353 if (!cv_wait_sig(&sp->s_cnt_cv, &sp->s_lock))
355 mutex_exit(&sp->s_lock);
356 sess_rele(sp, B_FALSE);
363 sess_ctty_set(p, sp, stp);
365 mutex_exit(&sp->s_lock);
386 sess_t *sp;
392 sp = p->p_sessp;
393 mutex_enter(&sp->s_lock); /* protect sp->* */
395 if ((sp->s_sidp != p->p_pidp) || /* we're not leader? */
396 (sp->s_vp == NULL)) { /* no ctty? */
397 mutex_exit(&sp->s_lock);
403 vp = sp->s_vp;
404 stp = sp->s_vp->v_stream;
408 sp->s_exit = B_TRUE;
415 * the current ctty (vp) there by making sp or stp invalid.
424 sp->s_ref++; /* hold the session structure */
425 sp->s_cnt++; /* protect vp and stp */
429 mutex_exit(&sp->s_lock);
437 mutex_enter(&sp->s_lock); /* protects sp->* */
440 if (sp != p->p_sessp) {
449 mutex_exit(&sp->s_lock);
453 tty_rele(sp);
461 ASSERT(sp->s_sidp == p->p_pidp); /* we're the leader */
462 ASSERT(sp->s_vp != NULL); /* a ctty exists */
463 ASSERT(vp == sp->s_vp);
464 ASSERT(stp == sp->s_vp->v_stream);
468 if ((--(sp)->s_cnt) == 0)
469 cv_broadcast(&sp->s_cnt_cv);
470 sp->s_ref--;
471 ASSERT(sp->s_ref > 0);
475 *spp = sp;
489 freectty_signal(proc_t *p, sess_t *sp, stdata_t *stp, boolean_t at_exit)
493 MUTEX_HELD(&p->p_splock) && MUTEX_HELD(&sp->s_lock));
496 if (sp->s_sighuped)
499 sp->s_sighuped = B_TRUE;
504 * don't want sp or stp to be freed. (see the comment in
507 sp->s_ref++; /* hold the session structure */
508 sp->s_cnt++; /* protect vp and stp */
512 mutex_exit(&sp->s_lock);
527 tty_rele(sp);
539 sess_t *sp;
555 if (!freectty_lock(p, &sp, &vp, &stp, at_exit))
558 if (freectty_signal(p, sp, stp, at_exit)) {
571 ASSERT(at_exit || !sp->s_exit);
578 if (sp->s_cnt == 0)
583 sp->s_ref++;
607 cv_wait(&sp->s_cnt_cv, &sp->s_lock);
608 mutex_exit(&sp->s_lock);
612 if (!cv_wait_sig(&sp->s_cnt_cv, &sp->s_lock)) {
616 mutex_exit(&sp->s_lock);
617 sess_rele(sp, B_FALSE);
622 ASSERT(sp->s_cnt == 0);
625 cred = sp->s_cred;
630 sess_ctty_clear(sp, stp);
634 ASSERT(sp->s_exit);
635 sp->s_exit = B_FALSE;
636 cv_broadcast(&sp->s_exit_cv);
640 mutex_exit(&sp->s_lock);
683 sess_t *sp;
687 sp = pp->p_sessp;
690 mutex_enter(&sp->s_lock); /* protects sp->* */
691 if (sp->s_vp == NULL)
692 ASSERT(sp->s_dev == NODEV);
694 ASSERT(sp->s_dev != NODEV);
695 mutex_exit(&sp->s_lock);
698 dev = sp->s_dev;