From owner-freebsd-net Thu Mar 20 8:30: 1 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 2B8C237B401 for ; Thu, 20 Mar 2003 08:30:00 -0800 (PST) Received: from xorpc.icir.org (xorpc.icir.org [192.150.187.68]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8CEBD43F3F for ; Thu, 20 Mar 2003 08:29:59 -0800 (PST) (envelope-from rizzo@xorpc.icir.org) Received: from xorpc.icir.org (localhost [127.0.0.1]) by xorpc.icir.org (8.12.3/8.12.3) with ESMTP id h2KGTxAq016429; Thu, 20 Mar 2003 08:29:59 -0800 (PST) (envelope-from rizzo@xorpc.icir.org) Received: (from rizzo@localhost) by xorpc.icir.org (8.12.3/8.12.3/Submit) id h2KGTs7g016412; Thu, 20 Mar 2003 08:29:54 -0800 (PST) (envelope-from rizzo) Date: Thu, 20 Mar 2003 08:29:54 -0800 From: Luigi Rizzo To: Bruce Evans Cc: Peter Pentchev , net@FreeBSD.ORG, Tristan Goode Subject: Re: write(2) SIGPIPE on a closed socket? Message-ID: <20030320082954.B15241@xorpc.icir.org> References: <20030319093002.GT468@straylight.oblivion.bg> <20030319013748.A84035@xorpc.icir.org> <20030319094506.GB27330@straylight.oblivion.bg> <20030319215212.V8375@gamplex.bde.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <20030319215212.V8375@gamplex.bde.org>; from bde@zeta.org.au on Wed, Mar 19, 2003 at 10:27:57PM +1100 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 Wed, Mar 19, 2003 at 10:27:57PM +1100, Bruce Evans wrote: ... ... > Similarly in for sockets except in the SO_NOSIGPIPE case, unless I am > misreading uipc_syscalls.c:sendit(): > > % 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 ? cheers luigi To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message