id,summary,reporter,owner,description,type,status,priority,milestone,component,version,resolution,keywords,cc
44,Network.Socket.connect blocks the whole RTS on Windows with -threaded,joeyadams,,"On Windows with -threaded, when Network.Socket.connect is called, it blocks the whole RTS until the connection attempt succeeds or fails.

This is because under the hood, it is calling c_connect, an unsafe foreign import:

{{{
foreign import CALLCONV unsafe ""connect""
  c_connect :: CInt -> Ptr SockAddr -> CInt{-CSockLen???-} -> IO CInt
}}}

Unsafe foreign calls block the whole runtime system.  Safe foreign calls block only the current thread (but cannot be interrupted by exceptions).

I tested it on Windows with network-2.3.0.8, and Network.Socket.connect does in fact block the whole program.  When I changed unsafe to safe and recompiled, it did not block the whole program.

It seems clear that c_connect should be a safe foreign import, at least on Windows with -threaded.  Are there any other foreign calls marked safe that could potentially block on Windows?",defect,new,major,,network,2.3,,FFI,
