Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 19 Jan 2001 16:38:20 -0800
From:      Dima Dorfman <dima@unixfreak.org>
To:        Garrett Wollman <wollman@khavrinen.lcs.mit.edu>
Cc:        Wes Peters <wes@softweyr.com>, freebsd-net@FreeBSD.ORG
Subject:   Re: manual page review: connect(2) EAGAIN error 
Message-ID:  <20010120003825.5FD213E02@bazooka.unixfreak.org>
In-Reply-To: Message from Garrett Wollman <wollman@khavrinen.lcs.mit.edu>  of "Fri, 19 Jan 2001 12:36:27 EST." <200101191736.MAA10929@khavrinen.lcs.mit.edu> 

next in thread | previous in thread | raw e-mail | index | archive | help
> <<On Fri, 19 Jan 2001 09:32:14 -0700, Wes Peters <wes@softweyr.com> said:
> 
> > If the code implements what?  Returning EAGAIN when no ephemeral ports are
> > available?  That is all the above really says, and then provides a hint
> > as to how to fix it.  The description is a little simplistic, as it misses
> > the lowfirst-lowlast and highfirst-highlast ranges.
> 
> If no ports are available, the correct (Standard) error is
> [EADDRNOTAVAIL], regardless of whether the socket is in blocking or
> non-blocking mode.

The code does indeed seem to implement this.  The patch below is a
possible remedy.  I only tested some very simple cases, but it does
seem to work.  Also, judging from the comments above the changed lines
(not in the diff), it looks like this is the right place.

As far as I can tell, function changed, in_pcbbind, is called on
blocking and non-blocking sockets alike.  My tests also show that
EAGAIN was being returned on blocking sockets when all ports were in
use (just wanted to clear that up; the patch seems to just use
non-blocking sockets as an example, anyway).

					Dima Dorfman
					dima@unixfreak.org


Index: in_pcb.c
===================================================================
RCS file: /st/src/FreeBSD/src/sys/netinet/in_pcb.c,v
retrieving revision 1.71
diff -u -r1.71 in_pcb.c
--- in_pcb.c	2000/12/27 03:02:29	1.71
+++ in_pcb.c	2001/01/20 00:31:27
@@ -313,7 +313,7 @@
 					 * occurred above.
 					 */
 					inp->inp_laddr.s_addr = INADDR_ANY;
-					return (EAGAIN);
+					return (EADDRNOTAVAIL);
 				}
 				--*lastport;
 				if (*lastport > first || *lastport < last)
@@ -334,7 +334,7 @@
 					 * occurred above.
 					 */
 					inp->inp_laddr.s_addr = INADDR_ANY;
-					return (EAGAIN);
+					return (EADDRNOTAVAIL);
 				}
 				++*lastport;
 				if (*lastport < first || *lastport > last)


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?20010120003825.5FD213E02>