Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 11 Feb 1999 11:22:30 -0600 (CST)
From:      Licia <licia@o-o.org>
To:        David Greenman <dg@root.com>
Cc:        freebsd-bugs@FreeBSD.ORG
Subject:   Re: kern/10028: TCP problem binding port - address already in use 
Message-ID:  <Pine.BSF.4.05.9902111117190.14586-100000@o-o.org>
In-Reply-To: <199902111710.JAA85414@freefall.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 11 Feb 1999, David Greenman wrote:
> The following reply was made to PR kern/10028; it has been noted by GNATS.
> 
> From: David Greenman <dg@root.com>
> To: david@inty.net
> Cc: freebsd-gnats-submit@FreeBSD.ORG
> Subject: Re: kern/10028: TCP problem binding port - address already in use 
> Date: Thu, 11 Feb 1999 09:04:05 -0800
> 
>  >>Description:
>  >I am developing a server program which listens on a port (8080 in this case)
>  >Often when the program exits (usually on a signal), the kernel does not
>  >'unbind' the port (i.e. netstat -na shows the port still in LISTEN state). I
>  >can still make connections to the port, even though there is no process
>  >listening on it. Trying to run the server program again reports 'address
>  >already in use'. There is no way to clear this problem other than rebooting,
>  >which is unacceptable.
>  >
>  >The problem occurs with kernel versions 2.2.x and 3.0
>  
>     Hmmm. I've never seen this before. Are you absolutely sure that there isn't
>  another process with the socket open?
>  
>  -DG
>  
>  David Greenman
>  Co-founder/Principal Architect, The FreeBSD Project

I've seen a problem like this before.  It usually occurs when the server
forks child processes to handle accepted connections and doesn't properly
handle their termination.  It can usually be cleared up by proper use of
wait4(); in the parent process at regular intervals.  something along the
lines of :

while(wait4(-1, &status,WNOHANG|WUNTRACED,NULL)>0);

placed somewhere in the main loop of the parent and in the signal
handlers should work if you're not interested in saving or checking the status
of the child processes. Alternatively, he could simply wait a while longer
until things time out and it all resets itself. :)


[ licia@o-o.org ] [ http://www.o-o.org/~licia/ ] [ Alias : Ladywolf]
[ Telnet to o-o.org and log in as bbs ]    [ ssh -l bbs -C o-o.org ]
[        A happy user of FreeBSD : http://www.freebsd.org/         ]


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.05.9902111117190.14586-100000>