Skip to content
This repository has been archived by the owner on Jan 18, 2020. It is now read-only.

Commit

Permalink
GHC 6.12.3 friendliness: don't use Control.Monad.void
Browse files Browse the repository at this point in the history
  • Loading branch information
peteg authored and depressed-pho committed Sep 7, 2011
1 parent 69069b1 commit fd3fe9e
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions OpenSSL/Session.hsc
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ import Control.Concurrent (threadWaitWrite, threadWaitRead)
import Control.Concurrent.QSem import Control.Concurrent.QSem
import Control.Exception import Control.Exception
import Control.Applicative ((<$>), (<$)) import Control.Applicative ((<$>), (<$))
import Control.Monad (void, unless) import Control.Monad (unless)
import Data.Typeable import Data.Typeable
import Data.Foldable (Foldable, mapM_, forM_) import Data.Foldable (Foldable, mapM_, forM_)
import Data.Traversable (Traversable, mapM, forM) import Data.Traversable (Traversable, mapM, forM)
Expand Down Expand Up @@ -224,7 +224,7 @@ foreign import ccall unsafe "SSL_CTX_set_verify"
contextSetVerificationMode :: SSLContext -> VerificationMode -> IO () contextSetVerificationMode :: SSLContext -> VerificationMode -> IO ()
contextSetVerificationMode context VerifyNone = contextSetVerificationMode context VerifyNone =
withContext context $ \ctx -> withContext context $ \ctx ->
void $ _ssl_set_verify_mode ctx (#const SSL_VERIFY_NONE) nullFunPtr _ssl_set_verify_mode ctx (#const SSL_VERIFY_NONE) nullFunPtr >> return ()


contextSetVerificationMode context (VerifyPeer reqp oncep cbp) = do contextSetVerificationMode context (VerifyPeer reqp oncep cbp) = do
let mode = (#const SSL_VERIFY_PEER) .|. let mode = (#const SSL_VERIFY_PEER) .|.
Expand All @@ -237,7 +237,8 @@ contextSetVerificationMode context (VerifyPeer reqp oncep cbp) = do
oldCb <- readIORef cbRef oldCb <- readIORef cbRef
writeIORef cbRef newCb writeIORef cbRef newCb
forM_ oldCb freeHaskellFunPtr forM_ oldCb freeHaskellFunPtr
void $ _ssl_set_verify_mode ctx mode $ fromMaybe nullFunPtr newCb _ssl_set_verify_mode ctx mode $ fromMaybe nullFunPtr newCb
return ()


foreign import ccall unsafe "SSL_CTX_load_verify_locations" foreign import ccall unsafe "SSL_CTX_load_verify_locations"
_ssl_load_verify_locations :: Ptr SSLContext_ -> Ptr CChar -> Ptr CChar -> IO CInt _ssl_load_verify_locations :: Ptr SSLContext_ -> Ptr CChar -> Ptr CChar -> IO CInt
Expand Down Expand Up @@ -287,8 +288,8 @@ data SSL_
-- waiting for the RTS to wake the Haskell thread. -- waiting for the RTS to wake the Haskell thread.
data SSL = SSL { sslSem :: QSem data SSL = SSL { sslSem :: QSem
, sslPtr :: ForeignPtr SSL_ , sslPtr :: ForeignPtr SSL_
, sslFd :: Fd , sslFd :: Fd -- ^ Get the underlying socket Fd
, sslSocket :: Maybe Socket , sslSocket :: Maybe Socket -- ^ Get the socket underlying an SSL connection
} }


foreign import ccall unsafe "SSL_new" _ssl_new :: Ptr SSLContext_ -> IO (Ptr SSL_) foreign import ccall unsafe "SSL_new" _ssl_new :: Ptr SSLContext_ -> IO (Ptr SSL_)
Expand Down Expand Up @@ -453,7 +454,7 @@ foreign import ccall "SSL_write" _ssl_write :: Ptr SSL_ -> Ptr Word8 -> CInt ->
-- | Write a given ByteString to the SSL connection. Either all the data is -- | Write a given ByteString to the SSL connection. Either all the data is
-- written or an exception is raised because of an error -- written or an exception is raised because of an error
write :: SSL -> B.ByteString -> IO () write :: SSL -> B.ByteString -> IO ()
write ssl bs = void $ sslBlock (`tryWrite` bs) ssl write ssl bs = sslBlock (`tryWrite` bs) ssl >> return ()


-- | Try to write a given ByteString to the SSL connection without blocking. -- | Try to write a given ByteString to the SSL connection without blocking.
tryWrite :: SSL -> B.ByteString -> IO (SSLResult ()) tryWrite :: SSL -> B.ByteString -> IO (SSLResult ())
Expand Down Expand Up @@ -540,12 +541,6 @@ getVerifyResult ssl =
r <- _ssl_get_verify_result ssl r <- _ssl_get_verify_result ssl
return $ r == (#const X509_V_OK) return $ r == (#const X509_V_OK)


-- | Get the socket underlying an SSL connection
sslSocket :: SSL -> Maybe Socket

-- | Get the underlying socket Fd
sslFd :: SSL -> Fd

-- | The root exception type for all SSL exceptions. -- | The root exception type for all SSL exceptions.
data SomeSSLException data SomeSSLException
= forall e. Exception e => SomeSSLException e = forall e. Exception e => SomeSSLException e
Expand Down

0 comments on commit fd3fe9e

Please sign in to comment.