From owner-svn-src-all@FreeBSD.ORG Tue Mar 18 17:17:43 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D179AE27; Tue, 18 Mar 2014 17:17:43 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id BD4C02B; Tue, 18 Mar 2014 17:17:43 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s2IHHhru053741; Tue, 18 Mar 2014 17:17:43 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s2IHHhmi053740; Tue, 18 Mar 2014 17:17:43 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201403181717.s2IHHhmi053740@svn.freebsd.org> From: John Baldwin Date: Tue, 18 Mar 2014 17:17:43 +0000 (UTC) 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 X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Mar 2014 17:17:43 -0000 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);