*BSD News Article 16428


Return to BSD News archive

Newsgroups: comp.os.386bsd.bugs
Path: sserve!newshost.anu.edu.au!munnari.oz.au!uunet!email!mbirgmei
From: mbirgmei@email.tuwien.ac.at (Martin BIRGMEIER)
Subject: Re: FIFOs cause lockup
Message-ID: <1993May24.064242.16966@email.tuwien.ac.at>
Organization: Technical University of Vienna
References: <C7DtDE.4A@rokkaku.atl.ga.us>
Date: Mon, 24 May 1993 06:42:42 GMT
Lines: 87

In article <C7DtDE.4A@rokkaku.atl.ga.us> kml@rokkaku.atl.ga.us (Kevin Lahey) writes:
[...]
>I rebuilt the kernel to support FIFOs using the 'options FIFO' line in the
>config file.  It built fine, and the mkfifo command now works.  The following
>sequence of commands will lock up the system:
>
>% mkfifo /tmp/goop
>% cat > /tmp/goop < /etc/passwd &
>% cat /tmp/goop &
>% cat > /tmp/goop < /etc/passwd &
>% cat > /tmp/goop < /etc/passwd &
[...]

I once posted the following patch, although I don't know if it is correct:

============================== cut here ==============================
*** /usr/src/sys.386bsd/kern/fifo_vnops.c.FIFO_ORIG	Tue Dec 24 23:24:07 1991
--- /usr/src/sys.386bsd/kern/fifo_vnops.c	Mon Mar 29 12:27:30 1993
***************
*** 150,155 ****
--- 150,156 ----
  			vp->v_fifoinfo = NULL;
  			return (error);
  		}
+ 		fip->fi_writers = fip->fi_readers = 0;
  		wso->so_state |= SS_CANTRCVMORE;
  		rso->so_state |= SS_CANTSENDMORE;
  	}
***************
*** 163,172 ****
  		}
  		if (mode & O_NONBLOCK)
  			return (0);
! 		while (fip->fi_writers == 0)
! 			if (error = tsleep((caddr_t)&fip->fi_readers, PSOCK,
! 			    openstr, 0))
  				break;
  	} else {
  		fip->fi_writers++;
  		if (fip->fi_readers == 0 && (mode & O_NONBLOCK)) {
--- 164,177 ----
  		}
  		if (mode & O_NONBLOCK)
  			return (0);
! 		while (fip->fi_writers == 0) {
! 			VOP_UNLOCK(vp);
! 			error = tsleep((caddr_t)&fip->fi_readers, PSOCK,
! 			    openstr, 0);
! 			VOP_LOCK(vp);
! 			if (error)
  				break;
+ 		}
  	} else {
  		fip->fi_writers++;
  		if (fip->fi_readers == 0 && (mode & O_NONBLOCK)) {
***************
*** 177,186 ****
  				if (fip->fi_readers > 0)
  					wakeup((caddr_t)&fip->fi_readers);
  			}
! 			while (fip->fi_readers == 0)
! 				if (error = tsleep((caddr_t)&fip->fi_writers,
! 				    PSOCK, openstr, 0))
  					break;
  		}
  	}
  	if (error)
--- 182,195 ----
  				if (fip->fi_readers > 0)
  					wakeup((caddr_t)&fip->fi_readers);
  			}
! 			while (fip->fi_readers == 0) {
! 				VOP_UNLOCK(vp);
! 				error = tsleep((caddr_t)&fip->fi_writers,
! 				    PSOCK, openstr, 0);
! 				VOP_LOCK(vp);
! 				if (error)
  					break;
+ 			}
  		}
  	}
  	if (error)
============================== cut here ==============================

Cheers,

Martin