svn commit: r263309 - in stable: 8/sys/fs/fifofs 9/sys/fs/fifofs
John Baldwin
jhb at FreeBSD.org
Tue Mar 18 17:17:43 UTC 2014
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);
More information about the svn-src-stable-9
mailing list