Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,868
    • Issues 4,868
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 456
    • Merge requests 456
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #65
Closed
Open
Created Apr 21, 2002 by nobody@trac-nobody

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 ResolvedFixed
Component hslibs/net
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking