Date: Thu, 20 Mar 2003 08:29:54 -0800 From: Luigi Rizzo <rizzo@icir.org> To: Bruce Evans <bde@zeta.org.au> Cc: Peter Pentchev <roam@ringlet.net>, net@FreeBSD.ORG, Tristan Goode <tgoode@iprimus.com.au> Subject: Re: write(2) SIGPIPE on a closed socket? Message-ID: <20030320082954.B15241@xorpc.icir.org> In-Reply-To: <20030319215212.V8375@gamplex.bde.org>; from bde@zeta.org.au on Wed, Mar 19, 2003 at 10:27:57PM %2B1100 References: <20030319093002.GT468@straylight.oblivion.bg> <20030319013748.A84035@xorpc.icir.org> <20030319094506.GB27330@straylight.oblivion.bg> <20030319215212.V8375@gamplex.bde.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Mar 19, 2003 at 10:27:57PM +1100, Bruce Evans wrote: ... <re. SIGPIPE handling> ... > 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030320082954.B15241>