Date: Tue, 18 Mar 2014 17:17:43 +0000 (UTC) From: John Baldwin <jhb@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r263309 - in stable: 8/sys/fs/fifofs 9/sys/fs/fifofs Message-ID: <201403181717.s2IHHhmi053740@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jhb Date: Tue Mar 18 17:17:42 2014 New Revision: 263309 URL: http://svnweb.freebsd.org/changeset/base/263309 Log: Increment fi_wgen before awakening threads polling the read socket of a FIFO. Previously, a thread sleeping in poll() could be awakened and re-poll the FIFO with the old value of fi_wgen (and thus improperly setting POLLINIGNEOF) before a thread closing a writable fifo descriptor bumped fi_wgen. The end result was that the reading thread in poll() would never see POLLHUP but could block forever (or until a timeout). This is a direct commit to 8 and 9 since the FIFO code is implemented differently in 10.x and later. The pipe-backed FIFOs in 10 do not have this bug. Modified: stable/9/sys/fs/fifofs/fifo_vnops.c Changes in other areas also in this revision: Modified: stable/8/sys/fs/fifofs/fifo_vnops.c Modified: stable/9/sys/fs/fifofs/fifo_vnops.c ============================================================================== --- stable/9/sys/fs/fifofs/fifo_vnops.c Tue Mar 18 17:00:32 2014 (r263308) +++ stable/9/sys/fs/fifofs/fifo_vnops.c Tue Mar 18 17:17:42 2014 (r263309) @@ -294,10 +294,10 @@ fail1: if (error) { fip->fi_writers--; if (fip->fi_writers == 0) { - socantrcvmore(fip->fi_readsock); mtx_lock(&fifo_mtx); fip->fi_wgen++; mtx_unlock(&fifo_mtx); + socantrcvmore(fip->fi_readsock); fifo_cleanup(vp); } return (error); @@ -415,10 +415,10 @@ fifo_close(ap) if (ap->a_fflag & FWRITE) { fip->fi_writers--; if (fip->fi_writers == 0) { - socantrcvmore(fip->fi_readsock); mtx_lock(&fifo_mtx); fip->fi_wgen++; mtx_unlock(&fifo_mtx); + socantrcvmore(fip->fi_readsock); } } fifo_cleanup(vp);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201403181717.s2IHHhmi053740>