Ticket #2 (new defect)

Opened 9 years ago

Last modified 9 years ago

Socket related IO cannot be be interrupted on Windows

Reported by: igloo Owned by:
Priority: major Milestone:
Component: network Version:
Keywords: Cc:


Originally reported here: http://hackage.haskell.org/trac/ghc/ticket/2943

While playing with socket communication, I noticed that socket IO cannot be interrupted or killed. The attached program simply hangs, irregardless whether is was complied using the -threaded flag or not.

import Network
import Control.Concurrent

main = withSocketsDo $ do
    tid <- forkIO $ do
        s <- listenOn (PortNumber 1234)
        accept s
        return ()
    threadDelay 2000000
    killThread tid

Change History

Changed 9 years ago by simonmar

  • owner set to simonmar
  • status changed from new to assigned

This is because accept makes a safe FFI call on Windows, whereas on Unix it uses threadWaitRead to wait for a connection (threadWaitRead is interruptible, but not available on Windows).

It looks to me like it ought to be interruptible without -threaded, I don't completely understand what's going on there.

Ideally we would have an IO manager thread on Windows and handle this in the same way as other blocking IO operations, but that's a big job.

Changed 9 years ago by simonmar

  • owner simonmar deleted
  • status changed from assigned to new

oops, didn't mean to assign ownership.

Note: See TracTickets for help on using tickets.