From owner-freebsd-bugs@FreeBSD.ORG Tue Mar 22 17:50:39 2005 Return-Path: Delivered-To: freebsd-bugs@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B2ABA16A4CE for ; Tue, 22 Mar 2005 17:50:39 +0000 (GMT) Received: from smtp4.na.baesystems.com (smtp4.na.baesystems.com [63.164.202.13]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3811C43D5D for ; Tue, 22 Mar 2005 17:50:39 +0000 (GMT) (envelope-from James.Juran@baesystems.com) Received: from BLUMS0022.bluelnk.net (blums0022.na.baesystems.com [10.40.96.145])j2MHobYj020789 for ; Tue, 22 Mar 2005 12:50:37 -0500 (EST) Received: from vahqex3.digitalnet.com ([159.94.37.43])j2MHoauF004638 for ; Tue, 22 Mar 2005 12:50:36 -0500 (EST) Received: from juran.digitalnet.com ([159.94.6.27]) by vahqex3.digitalnet.com with Microsoft SMTPSVC(5.0.2195.6713); Tue, 22 Mar 2005 12:50:23 -0500 Received: from [127.0.0.1] (localhost [127.0.0.1]) by juran.digitalnet.com (8.12.11/8.12.11) with ESMTP id j2MHoNLU003686 for ; Tue, 22 Mar 2005 12:50:23 -0500 From: James Juran To: freebsd-bugs@FreeBSD.org In-Reply-To: <200503221700.j2MH06Ln058240@freefall.freebsd.org> References: <200503221700.j2MH06Ln058240@freefall.freebsd.org> Content-Type: text/plain Organization: BAE Systems Information Technology, LLC Message-Id: <1111513822.3629.2.camel@juran.digitalnet.com> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Date: Tue, 22 Mar 2005 12:50:23 -0500 Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 22 Mar 2005 17:50:23.0374 (UTC) FILETIME=[9F4BAAE0:01C52F07] Subject: Re: kern/79138: close while sending on connected UNIX-domain socket can return ENOTCONN, should return EPIPE or 0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Mar 2005 17:50:39 -0000 Sorry about the line wrapping on the description. Here's a properly wrapped version of the description field: The test program shown below, when run on a uniproc system compiled with PREEMPTION and FULL_PREEMPTION, shows that calling send() for more than 2048 bytes on a UNIX-domain connection-oriented socket can return ENOTCONN, even when the socket is connected. This happens when the other side of the connection does a partial recv() and then closes the connection with data still in the send buffer. The send() should return either EPIPE, if the close happens before the send completes, or 0 if the send completes before the close takes effect. What happens is that sosend() breaks the send into 2048-byte chunks and calls uipc_send() for each one. uipc_send() wakes up a process waiting in recv(). In the GENERIC kernel on uniproc, this wakeup doesn't actually take effect until sosend() tries to get the SOCKBUF_LOCK at the bottom of the main loop. It then checks SBS_CANTSENDMORE on the next loop iteration, and returns EPIPE as it should. However, with option FULL_PREEMPTION, the process doing the recv() gets run right away, and performs its close before the second call to uipc_send(). uipc_send() then fails the check for SS_ISCONNECTED and returns ENOTCONN. Even though this failure requires FULL_PREEMPTION to reproduce on uniproc, I would think that on SMP there would be a chance of failure even on a standard kernel.