Return to BSD News archive
Newsgroups: comp.unix.bsd Path: sserve!manuel.anu.edu.au!munnari.oz.au!spool.mu.edu!uwm.edu!caen!sol.ctr.columbia.edu!ira.uka.de!math.fu-berlin.de!news.belwue.de!news.uni-stuttgart.de!news.uni-stuttgart.de!nils From: nils@merlin.ims.uni-stuttgart.de (Cornelis van der Laan) Subject: them FIFO's again Message-ID: <NILS.92Nov2194451@merlin.ims.uni-stuttgart.de> Lines: 109 Sender: news@news.uni-stuttgart.de (USENET News System) Reply-To: nils@ims.uni-stuttgart.de Organization: IMS, University of Stuttgart, Germany Date: Mon, 2 Nov 1992 18:48:56 GMT Lines: 109 We now that FIFO's still don't work as expected in 386bsd 0.1. hack@marvin.datacube.com (Jay Fenlason) investigated the problem and sent me a mail containing some patches that I forward to you all. I hadn't time to check but it sure sounds interesting. Here it is: ------ Cut here ------------------------ Cut here ----------------------- From: hack@marvin.datacube.com (Jay Fenlason) To: nils@merlin.ims.uni-stuttgart.de, scott@lopez.marquette.MI.US Subject: There are *two* bugs in the 386BSD fifo code 1: the fi_readers and fi_writers fields of the fifoinfo structure were not being initialized to 0. This caused the driver to not sleep the first process to open the fifo--it thought there was already another process to talk to (most of the time.) 2: fifo_open() was calling tsleep() without unlocking the inode of the fifo file. This caused *any* subsequent access to the file (even an ls (!)) to hang forever. Note that this bug was usually masked by bug #1 above. Here's a patch--If one of you can forward it to the net, I'd appreciate it. Note that this patch is suspect: I think this may result in both the fifo-reader and the fifo-writer locking the inode at the same time (a no-no). The kernel might panic if -DDIAGNOSTIC was used (I haven't checked). I don't know kernel internals well enough to tell. Also note that the structure fifo_vnodeops is completely unused (replaced by the structure fifo_inodeops in ufs/ufs_vnops.c). The same applies to the functions fifo_lock() and fifo_unlock(). *** /sys/kern/fifo_vnops.c Fri Oct 2 20:56:10 1992 --- fifo_vnops.c.new Mon Oct 26 15:24:49 1992 *************** *** 130,135 **** --- 130,137 ---- if ((fip = vp->v_fifoinfo) == NULL) { MALLOC(fip, struct fifoinfo *, sizeof(*fip), M_VNODE, M_WAITOK); vp->v_fifoinfo = fip; + fip->fi_readers=0; + fip->fi_writers=0; if (error = socreate(AF_UNIX, &rso, SOCK_STREAM, 0)) { free(fip, M_VNODE); vp->v_fifoinfo = NULL; *************** *** 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)) { --- 165,178 ---- } 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) --- 183,196 ---- 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) -- Nils. -- ----------------------------------------------------------------------- Cornelis van der Laan --- nils@ims.uni-stuttgart.de IMS Universitaet Stuttgart --- nils@guru.stgt.sub.org #echo "Knusper Knusper Knaeuschen" > /etc/nologin