[prev in list] [next in list] [prev in thread] [next in thread]
List: haproxy
Subject: Re: HAProxy and FreeBSD EADDRINUSE
From: Piotr Rybicki <meritus () innervision ! pl>
Date: 2008-12-09 9:52:48
Message-ID: 493E3FF0.10502 () innervision ! pl
[Download RAW message or body]
Hi all, some more informations
from FreeSBD src code (/usr/src/sys/netinet/tcp_usrreq.c)
FreeBSD 7.1-PRERELEASE
(...)
/*
* Common subroutine to open a TCP connection to remote host specified
* by struct sockaddr_in in mbuf *nam. Call in_pcbbind to assign a local
* port number if needed. Call in_pcbconnect_setup to do the routing and
* to choose a local host address (interface). If there is an existing
* incarnation of the same connection in TIME-WAIT state and if the remote
* host was sending CC options and if the connection duration was < MSL,
then
* truncate the previous TIME-WAIT state and proceed.
* Initialize connection parameters and enter SYN-SENT state.
*/
static int
tcp_connect(struct tcpcb *tp, struct sockaddr *nam, struct thread *td)
{
struct inpcb *inp = tp->t_inpcb, *oinp;
struct socket *so = inp->inp_socket;
struct in_addr laddr;
u_short lport;
int error;
INP_INFO_WLOCK_ASSERT(&tcbinfo);
INP_WLOCK_ASSERT(inp);
if (inp->inp_lport == 0) {
error = in_pcbbind(inp, (struct sockaddr *)0, td->td_ucred);
if (error)
return error;
}
/*
* Cannot simply call in_pcbconnect, because there might be an
* earlier incarnation of this same connection still in
* TIME_WAIT state, creating an ADDRINUSE error.
*/
laddr = inp->inp_laddr;
lport = inp->inp_lport;
error = in_pcbconnect_setup(inp, nam, &laddr.s_addr, &lport,
&inp->inp_faddr.s_addr, &inp->inp_fport, &oinp, td->td_ucred);
if (error && oinp == NULL)
return error;
if (oinp)
return EADDRINUSE;
inp->inp_laddr = laddr;
in_pcbrehash(inp);
(...)
According to:
http://www.madore.org/~david/computers/connect-intr.html
And:
http://kerneltrap.org/mailarchive/freebsd-net/2007/11/27/451121
It seems that it's common problem in FreeBSD (at minimum).
Mabe there should be some sort of connect-retry functionality
implemented in this area (f.e try 2-3 times)?
Best regards:
Piotr Rybicki
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic