Date: Fri, 21 Mar 2003 04:14:03 +1100 (EST) From: Bruce Evans <bde@zeta.org.au> To: Luigi Rizzo <rizzo@icir.org> 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: <20030321040924.G13725@gamplex.bde.org> In-Reply-To: <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> <20030320082954.B15241@xorpc.icir.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 20 Mar 2003, Luigi Rizzo wrote: > On Wed, Mar 19, 2003 at 10:27:57PM +1100, Bruce Evans wrote: > ... > <re. SIGPIPE handling> > > % 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030321040924.G13725>