Finalisation in "withSocketsDo"
I'm using GHC 5.02.2, but I believe this comment still
applies. While debugging my socket-using program on a
Win98 machine my DNS (or some related part of
networking assembly) appears to die after having my
custom application throw an exception. I think the
following change will fix this:
Replace in Network.Socket module:
withSocketsDo act = do
x <- initWinSock
if ( x /= 0 ) then
ioError (userError "Failed to initialise WinSock")
else do
v <- act
shutdownWinSock
return v
...with...
withSocketsDo act = do
x <- initWinSock
if ( x /= 0 ) then
ioError (userError "Failed to initialise WinSock")
else
act `finally` shutdownWinSock
I cannot guarantee that this is the solution to my
problem, but when I catch all exceptions within the
body of the argument IO action the DNS problem does
not arise.
Also I doubt the exception utility function "finally"
is within scope, this is simply the clearest way to
write my fix :)
Keep up the good work!
Trac metadata
Trac field |
Value |
Version |
5.02 |
Type |
Bug |
TypeOfFailure |
OtherFailure |
Priority |
normal |
Resolution |
ResolvedDuplicate |
Component |
hslibs/net |
Test case |
|
Differential revisions |
|
BlockedBy |
|
Related |
|
Blocking |
|
CC |
|
Operating system |
|
Architecture |
|