[erlang-questions] HTTP requests and the meaning of eaddrinuse

Johnny Billquist bqt@REDACTED
Sat Jan 31 13:16:31 CET 2009


Per Hedeland wrote:
> Per Hedeland <per@REDACTED> wrote:
>> Checking for this uniqueness may be expensive, which could explain that
>> you get this problem "unnecessarily" - the stack may optimistically use
>> a local port that isn't actually free, on the assumption that you don't
>> normally make all your connections to the same remote address/port, so
>> it "should" work out. Except it doesn't when you are doing benchmarks
>> and other things that do tons of connections to the same address/port.
>>
>> There are ways to tweak things in those cases though
> 
> Forgot one that I actually used recently on FreeBSD - it randomizes the
> selection of local port to make spoofing harder, and every now and then
> a test case that did a bunch of localhost connections would get the
> EADDRINUSE. Turning off the randomization (sysctl
> net.inet.ip.portrange.randomized 1 -> 0) made it cycle nicely through
> the available range => problem solved. A quick check on a Linux 2.6.20
> system doesn't show any such randomization nor reveal a way to turn it
> on or off, but it may well be there somewhere...

Whoa? It don't actually check that the random port is actually free 
before giving it to you??? That would be a serious design flaw. It means 
that any socket creation can potentially give EADDRINUSE even though it 
could actually have given you a free port number.

Ick!

	Johnny

-- 
Johnny Billquist                  || "I'm on a bus
                                   ||  on a psychedelic trip
email: bqt@REDACTED             ||  Reading murder books
pdp is alive!                     ||  tryin' to stay hip" - B. Idol



More information about the erlang-questions mailing list