accept does reverse DNS lookup
If "accept" gets a connection where the connecting machine
cannot be found via a reverse DNS lookup, it throws an
exception. I noticed this when I tried connecting to a
server made with GHC from inside a network that has real
IP numbers but no reverse DNS entries, and have had
reports of the same problems from inside similar networks.
If I disable the server's DNS lookups, connections fail
from everywhere. This is the exception:
exception during accept: does not exist
Action: getHostByAddr
Reason: no such host entry
I'm fairly sure this isn't an OS quirk, since the
machine I'm
testing on runs lots of other services that don't have this
problem, it seems to be a problem for GHC servers.
As you can see from this snippet:
aResult <- try (accept s)
case aResult of
Right (h,_,port) -> do
pid <- forkIO (do
c1 <- takeMVar cc
if c1 == 0 then takeMVar l else return ()
putMVar cc (c1 + 1)
handler state h
c2 <- takeMVar cc
if c2 == 1 then putMVar l () else return ()
putMVar cc (c2-1))
return ()
Left e -> do
--DEBUG
putStrLn ("exception during accept: " ++ show e)
return ()
I never actually demand the connecting host name, so
I would hope the lookup wouldn't happen
I'm testing on a RH 7.1 x86, with the GHC 5.02.
Sample code attached
Trac metadata
Trac field |
Value |
Version |
5.02 |
Type |
Bug |
TypeOfFailure |
OtherFailure |
Priority |
normal |
Resolution |
ResolvedFixed |
Component |
hslibs/net |
Test case |
|
Differential revisions |
|
BlockedBy |
|
Related |
|
Blocking |
|
CC |
|
Operating system |
|
Architecture |
|