Skip to content
Browse files

Use throwIO instead of throw to raise SSL exceptions.

Apart from being the right way to raise an error in IO, it prevents
a nasty "PAP object entered!" runtime crash I encountered using GHC HEAD.
  • Loading branch information...
1 parent fd3cbb8 commit 959fe8bdfe8fb399e199d22475c3e31265d8a0d2 @mvv mvv committed
Showing with 7 additions and 7 deletions.
  1. +7 −7 OpenSSL/Session.hsc
14 OpenSSL/Session.hsc
@@ -332,13 +332,13 @@ foreign import ccall "SSL_connect" _ssl_connect :: Ptr SSL_ -> IO CInt
foreign import ccall unsafe "SSL_get_error" _ssl_get_error :: Ptr SSL_ -> CInt -> IO CInt
throwSSLException :: CInt -> IO a
-throwSSLException (#const SSL_ERROR_ZERO_RETURN ) = throw ConnectionCleanlyClosed
-throwSSLException (#const SSL_ERROR_WANT_CONNECT ) = throw WantConnect
-throwSSLException (#const SSL_ERROR_WANT_ACCEPT ) = throw WantAccept
-throwSSLException (#const SSL_ERROR_WANT_X509_LOOKUP) = throw WantX509Lookup
-throwSSLException (#const SSL_ERROR_SYSCALL ) = throw SSLIOError
-throwSSLException (#const SSL_ERROR_SSL ) = throw ProtocolError
-throwSSLException x = throw (UnknownError (fromIntegral x))
+throwSSLException (#const SSL_ERROR_ZERO_RETURN ) = throwIO ConnectionCleanlyClosed
+throwSSLException (#const SSL_ERROR_WANT_CONNECT ) = throwIO WantConnect
+throwSSLException (#const SSL_ERROR_WANT_ACCEPT ) = throwIO WantAccept
+throwSSLException (#const SSL_ERROR_WANT_X509_LOOKUP) = throwIO WantX509Lookup
+throwSSLException (#const SSL_ERROR_SYSCALL ) = throwIO SSLIOError
+throwSSLException (#const SSL_ERROR_SSL ) = throwIO ProtocolError
+throwSSLException x = throwIO (UnknownError (fromIntegral x))
-- | This is the type of an SSL IO operation. EOF and termination are handled
-- by exceptions while everything else is one of these. Note that reading

0 comments on commit 959fe8b

Please sign in to comment.
Something went wrong with that request. Please try again.