Bugs item #546756, was opened at 2002-04-21 13:29
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=108032&aid=546756&group_id=8032

Category: hslibs/net
Group: 5.02
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
>Assigned to: Simon Marlow (simonmar)
>Summary: Finalisation in "withSocketsDo"

Initial Comment:
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!

----------------------------------------------------------------------

>Comment By: Simon Marlow (simonmar)
Date: 2002-07-02 11:39

Message:
Logged In: YES 
user_id=48280

Fix applied; thanks!

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=108032&aid=546756&group_id=8032
_______________________________________________
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to