Open GoogleCodeExporter opened 8 years ago
I don't see the problem with just using Network.Socket.accept for most cases. I
guess it could be exposed in 'Network', but thats not a big deal. Does anyone
at
libraries@h.o consider this a bug in Network?
At any rate, this is certainly what causes my hackage-server process to
terminate
when DNS is unreachable. You see a couple arp requests (Who has
DDD.NNN.SSS.XXX tell
HHH.AAA.PPP.SSS) and once those time out the program terminates immediately -
no need
to wait a day and forget about operating without a working DNS.
Original comment by Thomas.D...@gmail.com
on 24 Sep 2008 at 2:26
To summarize the problem for casual readers:
- a connection is made to the web server
- the name lookup on the remote address fails
- getNameInfo(3) returns EAI_FAIL
- Network.Socket.getNameInfo throws an IO exception
- Network.accept does not catch the exception
- HAppS does not catch the exception
- the program exits
Note that the exception can only be produced when Network.accept is given a
socket
with family AF_INET6. On IPv4 sockets, name-lookup failure results in a normal
return with hostname = inet_ntoa addr.
I agree that the most reasonable solution is to use Network.Socket.accept.
(Just
catching the exception from Network.accept would require dropping any connection
whose remote address can't be mapped to a name.)
Ideally, I think HAppS.Server.HTTP.Types.Request should be changed to allow
both the
IP address and a hostname::(Maybe String) to be recorded, but this would
require a
fair bit of meddling with the present code. A simple compromise would be for
name
lookup failure to result in the substitution of IP-address-as-String for the
missing
hostname, as already happens in the case of IPv4.
It would also be quite nice to have the option of *not* looking up hostnames at
all.
Original comment by butt...@gmail.com
on 11 Nov 2008 at 9:34
I will share a "probable" workaround for this problem. It isn't a fix, in a
sense
that the underlying issue with Network isn't resolved. Rather, the workaround
is to
turn off ipv6 support in the network package, which I believe is one of the
haskell
core libraries. This is a "proable" fix because I can't reproduce the bug at
will.
However, reading the source code and judging by the error message, it seems very
likely that it resolves the problem. If happstutorial.com stops crashing every
couple
of days in the error logs, then I will know for sure. Also I will do some work
to see
if I can reproduce the bug at will now :)
To reinstall network myself ipv6 support:
download tarred source from
http://hackage.haskell.org/cgi-bin/hackage-scripts/package/network-2.2.0.1
make the following change
network-2.2.0.1>darcs diff
diff -rN old-network-2.2.0.1/Network.hs new-network-2.2.0.1/Network.hs
22c22
< #define IPV6_SOCKET_SUPPORT 1
---
> # /* define IPV6_SOCKET_SUPPORT 1 */
reinstall via cabal install. (I have cabal 1.6, the latest, not sure if that's
necessary but I think it might be.)
This workaround was the idea of Matt Elder. Matt not only came up with the
idea, but
was extremely generous with time diagnosing the problem and handholding.
Thanks, Matt.
Original comment by thomasha...@gmail.com
on 8 Jan 2009 at 1:49
Followup with suggested patch to Network library at
http://www.haskell.org/pipermail/libraries/2009-January/011103.html
Original comment by thomasha...@gmail.com
on 8 Jan 2009 at 4:23
To reproduce this bug (on ubunu hardy), you can just comment out the lines of
/etc/resolv.conf to disable dns, and then attempt to load happstutorial.com in a
browser. The "disable ipv6" fix does seem to me to work.
Original comment by thomasha...@gmail.com
on 11 Jan 2009 at 1:00
Original issue reported on code.google.com by
thomasha...@gmail.com
on 5 Jul 2008 at 8:45