When compiled with -threaded, the following program crashes with the message: threadWait: invalid argument (Bad file descriptor). This happens with network-3.0.1.1 and with HEAD, but not with network-2.6.3.6.
import Network.Socket
main :: IO ()
main = do
sock <- socket AF_INET Stream defaultProtocol
setSocketOption sock ReuseAddr 1
bind sock $ SockAddrInet 6000 $ tupleToHostAddress (127, 0, 0, 1)
listen sock 1
_ <- accept sock
return ()
This seems to be caused by the fact that the accept function doesn't ensure that the internal IORef inside the socket remains referenced until the accept operation is complete. The solution would be to implement something like #352 and use it in every function that might block, like accept or recvBuf.
When compiled with
-threaded, the following program crashes with the message:threadWait: invalid argument (Bad file descriptor). This happens withnetwork-3.0.1.1and with HEAD, but not withnetwork-2.6.3.6.This seems to be caused by the fact that the
acceptfunction doesn't ensure that the internalIORefinside the socket remains referenced until theacceptoperation is complete. The solution would be to implement something like #352 and use it in every function that might block, likeacceptorrecvBuf.