From owner-freebsd-hackers@FreeBSD.ORG Fri Jan 2 21:41:11 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C133216A4CE; Fri, 2 Jan 2004 21:41:11 -0800 (PST) Received: from dglawrence.com (12-224-163-157.client.attbi.com [12.224.163.157]) by mx1.FreeBSD.org (Postfix) with ESMTP id 777BA43D48; Fri, 2 Jan 2004 21:41:10 -0800 (PST) (envelope-from dg@nexus.dglawrence.com) Received: from nexus.dglawrence.com (localhost [127.0.0.1]) by dglawrence.com (8.12.10/8.12.6) with ESMTP id i035fFkk009669; Fri, 2 Jan 2004 21:41:15 -0800 (PST) (envelope-from dg@nexus.dglawrence.com) Received: (from dg@localhost) by nexus.dglawrence.com (8.12.10/8.12.3/Submit) id i035fFbN009668; Fri, 2 Jan 2004 21:41:15 -0800 (PST) Date: Fri, 2 Jan 2004 21:41:15 -0800 From: "David G. Lawrence" To: Alfred Perlstein Message-ID: <20040103054115.GV56722@nexus.dglawrence.com> References: <20040103005338.GU9623@elvis.mu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040103005338.GU9623@elvis.mu.org> X-Mailman-Approved-At: Sat, 03 Jan 2004 04:57:57 -0800 cc: hackers@freebsd.org Subject: Re: [PATCH] sendfile erroniously returns ENOTCONN. X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 Jan 2004 05:41:11 -0000 > sendfile(2) returns ENOTCONN when the remote side has disconnected instead > of EPIPE. Can this fix be applied? Is there a reason for it being the > way it is? I know EPIPE can cause SIGPIPE which can cause problems, but > the error here is incorrect, and considering that the manpage mentions > EPIPE as a possible error... is this perhaps due to a change in the > socket flags API? I know the problem is on 4.x and 5.x. > > Index: uipc_syscalls.c > =================================================================== > RCS file: /home/ncvs/src/sys/kern/uipc_syscalls.c,v > retrieving revision 1.162 > diff -u -r1.162 uipc_syscalls.c > --- uipc_syscalls.c 28 Dec 2003 08:57:08 -0000 1.162 > +++ uipc_syscalls.c 2 Jan 2004 21:56:10 -0000 > @@ -1697,10 +1697,6 @@ > error = EINVAL; > goto done; > } > - if ((so->so_state & SS_ISCONNECTED) == 0) { > - error = ENOTCONN; > - goto done; > - } > if (uap->offset < 0) { > error = EINVAL; > goto done; sendfile(8) tries to maintain compatibility with sosend as much as is reasonable. ENOTCONN is the appropriate error to return if the socket isn't connected. sosend checks SS_CANTSENDMORE prior to the check for SS_ISCONNECTED, however, and returns EPIPE in that case. Perhaps sendfile should be changed to do the same (just a though - I'm not proposing that this be done). Removing the check entirely seems clearly wrong, however. -DG David G. Lawrence President Download Technologies, Inc. - http://www.downloadtech.com - (866) 399 8500 TeraSolutions, Inc. - http://www.terasolutions.com - (888) 346 7175 The FreeBSD Project - http://www.freebsd.org Pave the road of life with opportunities.