-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot connect remotely with TLS on Windows (GHC bug...) #5
Comments
I've narrowed it down to the |
read :: SSL -> Int -> IO B.ByteString
read ssl nBytes = sslBlock (`tryRead` nBytes) ssl Which goes back to -- | Block until the operation is finished.
sslBlock :: (SSL -> IO (SSLResult a)) -> SSL -> IO a
sslBlock action ssl
= do result <- action ssl
case result of
SSLDone r -> return r
WantRead -> threadWaitRead (sslFd ssl) >> sslBlock action ssl
WantWrite -> threadWaitWrite (sslFd ssl) >> sslBlock action ssl Think |
According to this ticket it has been a bug for 8 years. |
Here is the implementation in base 4.7.0.0: http://hackage.haskell.org/package/base-4.7.0.0/docs/src/Control-Concurrent.html#threadWaitRead says you need to compile with -threaded for it to work. Are you compiling with -threaded? In theory it should be raising an error if you are not.. |
Yea, looks like I have -threaded on http://lpaste.net/106752 |
One of two things could be happening.
#ifdef mingw32_HOST_OS
foreign import ccall unsafe "rtsSupportsBoundThreads" threaded :: Bool
withThread :: IO a -> IO a
withThread io = do
m <- newEmptyMVar
-- if the exception is asynchronous with throwTo mask_ will block is indefinitely
_ <- mask_ $ forkIO $ try io >>= putMVar m -- io here isn't happening, or an exception is being raised
x <- takeMVar m -- this blocks indefinitely
case x of
Right a -> return a
Left e -> throwIO (e :: IOException)
waitFd :: Fd -> CInt -> IO ()
waitFd fd write = do -- this code must be the culprit, fdReady might never return
throwErrnoIfMinus1_ "fdReady" $
fdReady (fromIntegral fd) write iNFINITE 0
iNFINITE :: CInt
iNFINITE = 0xFFFFFFFF -- urgh -- "dmjio: this is actual code in base I didn't write urgh"
foreign import ccall safe "fdReady"
fdReady :: CInt -> CInt -> CInt -> CInt -> IO CInt
#endif
|
So, it must be the ssl file descriptor never enters the ready state. |
I went into HsOpenSSL and started adding print statements. Strange part is that both client and server seem to be communicating initially, just that a query / update will not return to client entirely. This means the issue probably isn't
|
The blocking occurs on the linux server... so it absolutely couldn't be |
@stepcut,
I have a client who is attempting to connect to an acid TLS server. A query is submitted by the client, but never makes it back from the server. Here is the client's debug output. The server hangs with
Partial
Input, never returningDone
.Here is the servers output:
I've added debug statements to the code.
The text was updated successfully, but these errors were encountered: