From rfg@monkeys.com  Sat Jan  6 23:22:45 2001
Return-Path: <rfg@monkeys.com>
Received: from mail.monkeys.com (236.dsl9226.rcsis.com [63.92.26.236])
	by hub.freebsd.org (Postfix) with ESMTP id AE7EA37B840
	for <FreeBSD-gnats-submit@freebsd.org>; Sat,  6 Jan 2001 23:11:55 -0800 (PST)
Received: (from rfg@localhost)
	by mail.monkeys.com (8.11.1/8.11.1) id f077BsU57011;
	Sat, 6 Jan 2001 23:11:54 -0800 (PST)
Message-Id: <200101070711.f077BsU57011@mail.monkeys.com>
Date: Sat, 6 Jan 2001 23:11:54 -0800 (PST)
From: "Ronald F. Guilmette" <rfg@monkeys.com>
Reply-To: rfg@monkeys.com
To: FreeBSD-gnats-submit@freebsd.org
Subject: connect(2) can yield EWOULDBLOCK/EAGAIN
X-Send-Pr-Version: 3.2

>Number:         24125
>Category:       docs
>Synopsis:       connect(2) can yield EWOULDBLOCK/EAGAIN
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    wes
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          doc-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Jan 06 23:30:01 PST 2001
>Closed-Date:    Sat Sep 23 23:04:29 GMT 2006
>Last-Modified:  Sat Sep 23 23:04:29 GMT 2006
>Originator:     Ronald F. Guilmette
>Release:        FreeBSD 4.2-RELEASE i386
>Organization:
Infinite Monkeys & Co.
>Environment:

>Description:

	It appears that the connect(2) function can yield a -1 (error)
	result and can set errno to EAGAIN/EWOULDBLOCK in some cases
	when trying to connect sockets that have previously been marked
	as non-blocking.

	Note however that the man page for connect(2) documents no such
	possibility.

	Given that the text associated with EAGAIN is "Resource temporarily
	unavailable" it is clear that some resource is being used up, but
	I have no idea which one or even how to find out which one.  I *am*
	using quite a lot of sockets in the relevant program, but still,
	it is both annoying and troublesome to be getting an undocumented
	errno result from connect(2) and not even have it be clear which
	resource limitation is causing this.

>How-To-Repeat:

	Sorry, but I do not have any nice simple program which can demon-
	strate this problem at the moment... only a rather large application
	program.  But if you need a small example program which triggers
	the problem (i.e. the undocumented EAGAIN errno result), let me
	know and I will try to cook one up.

>Fix:

	For the resource limitation:  None known.

	For the documentation problem:  Fix the ERRORS section of the
	connect(2) man page so that it includes EAGAIN and so that it
	specifies what resource limitations might cause this result.

>Release-Note:
>Audit-Trail:

From: "Ronald F. Guilmette" <rfg@monkeys.com>
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: docs/24125: connect(2) can yield EWOULDBLOCK/EAGAIN
Date: Sat, 06 Jan 2001 23:38:28 -0800

 A brief follow-up on my own PR.
 
 I dug around in the networking parts of the kernel and found that 
 what was probably happening to cause EAGAIN errors to be issued
 in response to connect(2) call was a absence of available (auto
 assigned) port numbers for outgoing connections.
 
 /sbin/sysctl -a says (under default conditions):
 
 net.inet.ip.portrange.first: 1024
 net.inet.ip.portrange.last: 5000
 
 This leaves less than 4000 available auto-assigned port number for
 outgoing connections.  It appears that if those all get used up
 then connect(2) will start to yield -1 with errno set to EAGAIN.
 
 This should, of course, be documented in the ERRORS section of the
 connect(2) man page.
 
 Increasing the currently set value of net.inet.ip.portrange.last
 (via sysctl) seems to make the problem go away.
 
 
Responsible-Changed-From-To: freebsd-doc->wes@freebsd.org 
Responsible-Changed-By: wes 
Responsible-Changed-When: Thu Jan 25 08:58:54 PST 2001 
Responsible-Changed-Why:  
I'll shepherd this one, I've recently commited a fix to the code. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=24125 
Responsible-Changed-From-To: wes@freebsd.org->wes 
Responsible-Changed-By: peter 
Responsible-Changed-When: Mon Feb 19 11:09:54 PST 2001 
Responsible-Changed-Why:  
s/wes@freebsd.org/wes/ 

http://www.freebsd.org/cgi/query-pr.cgi?pr=24125 

From: Graham Percival <gpermus@gmail.com>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: docs/24125: connect(2) can yield EWOULDBLOCK/EAGAIN
Date: Thu, 8 Jun 2006 00:45:21 -0700

 Could this bug be closed?  It looks like wes@ fixed it 5 years ago.
 
 Cheers,
 - Graham Percival
 
State-Changed-From-To: open->feedback 
State-Changed-By: wes 
State-Changed-When: Wed Aug 16 02:56:57 UTC 2006 
State-Changed-Why:  
Committed fix to man page, should be closed after verification. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=24125 
State-Changed-From-To: feedback->closed 
State-Changed-By: wes 
State-Changed-When: Sat Sep 23 23:03:45 UTC 2006 
State-Changed-Why:  
Feedback timeout, close this (finally). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=24125 
>Unformatted:

Ronald promised to review the man page changes after returning from
holiday.  Hopefully this note will remind him.  ;^)
