597 mutex_enter(&fn_lock->flk_lock);
598 ASSERT(MUTEX_HELD(&fnp->fn_lock->flk_lock));
599
600 /*
601 * FIFO is in the process of opening. Wait for it
602 * to complete before starting another open on it
603 * This prevents races associated with connld open
604 */
605 while (fnp->fn_flag & FIFOOPEN) {
606 if (!cv_wait_sig(&fnp->fn_wait_cv, &fn_lock->flk_lock)) {
607 fifo_cleanup(oldvp, flag);
608 if (!lockheld)
609 mutex_exit(&fn_lock->flk_lock);
610 return (EINTR);
611 }
612 }
613
614 /*
615 * The other end of the pipe is almost closed so
616 * reject any other open on this end of the pipe
617 * This only happens with a pipe mounted under namefs
618 */
619 if ((fnp->fn_flag & (FIFOCLOSE|ISPIPE)) == (FIFOCLOSE|ISPIPE)) {
620 fifo_cleanup(oldvp, flag);
621 cv_broadcast(&fnp->fn_wait_cv);
622 if (!lockheld)
623 mutex_exit(&fn_lock->flk_lock);
624 return (ENXIO);
625 }
626
627 fnp->fn_flag |= FIFOOPEN;
628
629 /*
630 * can't allow close to happen while we are
631 * in the middle of stropen().
632 * M_HANGUP and M_ERROR could leave the stream in a strange state
633 */
634 while (fn_lock->flk_ocsync)
635 cv_wait(&fn_lock->flk_wait_cv, &fn_lock->flk_lock);
636
637 fn_lock->flk_ocsync = 1;
638
639 if (fnp->fn_flag & FIFOCONNLD) {
|
597 mutex_enter(&fn_lock->flk_lock);
598 ASSERT(MUTEX_HELD(&fnp->fn_lock->flk_lock));
599
600 /*
601 * FIFO is in the process of opening. Wait for it
602 * to complete before starting another open on it
603 * This prevents races associated with connld open
604 */
605 while (fnp->fn_flag & FIFOOPEN) {
606 if (!cv_wait_sig(&fnp->fn_wait_cv, &fn_lock->flk_lock)) {
607 fifo_cleanup(oldvp, flag);
608 if (!lockheld)
609 mutex_exit(&fn_lock->flk_lock);
610 return (EINTR);
611 }
612 }
613
614 /*
615 * The other end of the pipe is almost closed so
616 * reject any other open on this end of the pipe
617 * This normally only happens with a pipe mounted under namefs, but
618 * we can also see an open via proc/fd, which should still succeed.
619 * To indicate the proc/fd case the FKLYR flag is passed.
620 */
621 if ((fnp->fn_flag & (FIFOCLOSE|ISPIPE)) == (FIFOCLOSE|ISPIPE) &&
622 (flag & FKLYR) == 0) {
623 fifo_cleanup(oldvp, flag);
624 cv_broadcast(&fnp->fn_wait_cv);
625 if (!lockheld)
626 mutex_exit(&fn_lock->flk_lock);
627 return (ENXIO);
628 }
629
630 fnp->fn_flag |= FIFOOPEN;
631
632 /*
633 * can't allow close to happen while we are
634 * in the middle of stropen().
635 * M_HANGUP and M_ERROR could leave the stream in a strange state
636 */
637 while (fn_lock->flk_ocsync)
638 cv_wait(&fn_lock->flk_wait_cv, &fn_lock->flk_lock);
639
640 fn_lock->flk_ocsync = 1;
641
642 if (fnp->fn_flag & FIFOCONNLD) {
|