From owner-freebsd-net Thu Mar 20 9:14:29 2003 Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9FE4D37B404 for ; Thu, 20 Mar 2003 09:14:27 -0800 (PST) Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by mx1.FreeBSD.org (Postfix) with ESMTP id 21C5E43F3F for ; Thu, 20 Mar 2003 09:14:25 -0800 (PST) (envelope-from bde@zeta.org.au) Received: from katana.zip.com.au (katana.zip.com.au [61.8.7.246]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id EAA00626; Fri, 21 Mar 2003 04:14:04 +1100 Date: Fri, 21 Mar 2003 04:14:03 +1100 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: Luigi Rizzo Cc: Peter Pentchev , "" , Tristan Goode Subject: Re: write(2) SIGPIPE on a closed socket? In-Reply-To: <20030320082954.B15241@xorpc.icir.org> Message-ID: <20030321040924.G13725@gamplex.bde.org> References: <20030319093002.GT468@straylight.oblivion.bg> <20030319013748.A84035@xorpc.icir.org> <20030319094506.GB27330@straylight.oblivion.bg> <20030319215212.V8375@gamplex.bde.org> <20030320082954.B15241@xorpc.icir.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org On Thu, 20 Mar 2003, Luigi Rizzo wrote: > On Wed, Mar 19, 2003 at 10:27:57PM +1100, Bruce Evans wrote: > ... > > > % error = so->so_proto->pr_usrreqs->pru_sosend(so, to, &auio, 0, control, > > % flags, td); > > % if (error) { > > % if (auio.uio_resid != len && (error == ERESTART || > > % error == EINTR || error == EWOULDBLOCK)) > > % error = 0; > > % /* Generation of SIGPIPE can be controlled per socket */ > > % if (error == EPIPE && !(so->so_options & SO_NOSIGPIPE)) { > > % PROC_LOCK(td->td_proc); > > % psignal(td->td_proc, SIGPIPE); > > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > % PROC_UNLOCK(td->td_proc); > > % } > > % } > > > > This code seems to have an interesting version of mishandling short > > i/o counts (auio.uio_resid != len && auio.ui_resid != 0). Short i/o > > counts involving an interrupt are normally the only ones handled > > correctly (by the ERESTART/EINTR/EWOULDBLOCK fixup). However, in the > > case of EPIPE/SIGPIPE, we only notice the SIGPIPE after we do the > > fixup, so we never do the fixup and always return an error instead of > > the short i/o count. > > this is probably harmless because the pipe is gone anyways, > so it matters little how many bytes have been written, right ? Depends what was in the bytes that were written. Of course, with networks even delivery of the bytes doesn't guarantee much. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message