From owner-freebsd-hackers@FreeBSD.ORG Thu Apr 24 23:13:01 2003 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 EAD1C37B401 for ; Thu, 24 Apr 2003 23:13:00 -0700 (PDT) Received: from mail.isg.siue.edu (mail.isg.siue.edu [146.163.5.4]) by mx1.FreeBSD.org (Postfix) with ESMTP id B1F4B43FA3 for ; Thu, 24 Apr 2003 23:12:59 -0700 (PDT) (envelope-from wgrim@cougar.isg.siue.edu) Received: from WEBSHIELD1.isg.siue.edu (webshield1.isg.siue.edu [146.163.5.149]) by mail.isg.siue.edu (8.9.3p2/8.9.3) with SMTP id BAA13503 for ; Fri, 25 Apr 2003 01:12:54 -0500 (CDT) Received: From mail.isg.siue.edu ([146.163.5.4]) by WEBSHIELD1.isg.siue.edu (WebShield SMTP v4.5 MR1a); id 1051251174106; Fri, 25 Apr 2003 01:12:54 -0500 Received: from cougar (cougar [146.163.5.29]) by mail.isg.siue.edu (8.9.3p2/8.9.3) with ESMTP id BAA13472 for ; Fri, 25 Apr 2003 01:12:48 -0500 (CDT) Date: Fri, 25 Apr 2003 01:12:48 -0500 (CDT) From: William Michael Grim To: freebsd-hackers@freebsd.org In-Reply-To: <20030425031450.G8323-100000@foem.leiden.webweaving.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Subject: Re: recv() returning 0 and EINTR on a still connection. 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: Fri, 25 Apr 2003 06:13:01 -0000 Hey there. I think your problem is that n==0 does NOT mean the connection was closed (at least not with TCP; I haven't really looked into other session protocols). If n==0, it only means you have stopped receiving data because there is no more to be received; you can only trust errno if n==-1 or whatever the man page specifies for your OS (FreeBSD is -1 in this case). I hope this helps you unless I somehow misread anything you said. William Michael Grim Student, Southern Illinois University at Edwardsville Unix System Administrator, SIUE, Computer Science dept. Phone: (217) 341-6552 Email: wgrim@siue.edu On Fri, 25 Apr 2003, Dirk-Willem van Gulik wrote: > > After an upgrade from 2.2.8 to 5.0 the following fragement of > code in userland seems to trip under high loads: > > server-code > n = recv(... > if (n<0) { > if (errno = EAGAIN) > .. > if (errno = EINTR) > .. > } > if (n == 0) > bing > > with a n == 0 and errno == EINTR. (i.e. NOT n=-1). > > Even though the connection does not seem closed from the client end. > > Is it possible for n==0 -not- to mean that the connection is closed ? > > Or in other words that recv() behaves not like read(2) in this respect. > > (In all fairness; the man page for recv(2) does only detail n=-1 for the > EAGAIN. And does not mention any semantics for n==0, unlike read(2) which > says: > > RETURN VALUES > If successful, the number of bytes actually read is returned. Upon read- > ing end-of-file, zero is returned. Otherwise, a -1 is returned and the > global variable errno is set to indicate the error. > > Is recv() fundamentally different ? And is n==0 errno=EINTR a possible > valid return with the meaning; interupted and no bytes read ? > > Thanks > > Dw > > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org" >