From 7fc095725f27e269d6059a9cfc42e63922decf5d Mon Sep 17 00:00:00 2001 From: Victor Denisov Date: Thu, 2 Jun 2016 07:46:24 -0700 Subject: [PATCH] Make psend's argument message strict (#55) If the message argument can't be evaluated successfully strict modifier will keep those errors outside of psend invocation. Psend will catch only actual IO exceptions. --- Database/MongoDB/Internal/Protocol.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Database/MongoDB/Internal/Protocol.hs b/Database/MongoDB/Internal/Protocol.hs index bf647ed..324513d 100644 --- a/Database/MongoDB/Internal/Protocol.hs +++ b/Database/MongoDB/Internal/Protocol.hs @@ -7,6 +7,7 @@ {-# LANGUAGE RecordWildCards, StandaloneDeriving, OverloadedStrings #-} {-# LANGUAGE CPP, FlexibleContexts, TupleSections, TypeSynonymInstances #-} {-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, UndecidableInstances #-} +{-# LANGUAGE BangPatterns #-} {-# LANGUAGE NamedFieldPuns, ScopedTypeVariables #-} @@ -143,7 +144,7 @@ listen Pipeline{..} = do psend :: Pipeline -> Message -> IO () -- ^ Send message to destination; the destination must not response (otherwise future 'call's will get these responses instead of their own). -- Throw IOError and close pipeline if send fails -psend p@Pipeline{..} message = withMVar vStream (flip writeMessage message) `onException` close p +psend p@Pipeline{..} !message = withMVar vStream (flip writeMessage message) `onException` close p pcall :: Pipeline -> Message -> IO (IO Response) -- ^ Send message to destination and return /promise/ of response from one message only. The destination must reply to the message (otherwise promises will have the wrong responses in them).