Browse Source

BrokerClient: fix timeout detection

master
Denis Tereshkin 9 years ago
parent
commit
49c16b0acf
  1. 3
      src/ATrade/Broker/Client.hs

3
src/ATrade/Broker/Client.hs

@ -21,6 +21,7 @@ import Data.Int @@ -21,6 +21,7 @@ import Data.Int
import Data.IORef
import Data.Maybe
import Data.List.NonEmpty
import qualified Data.List as L
import qualified Data.Text as T
import qualified Data.ByteString.Lazy as BL
import Data.Text.Encoding
@ -51,7 +52,7 @@ brokerClientThread ctx ep cmd resp comp killMv = finally brokerClientThread' cle @@ -51,7 +52,7 @@ brokerClientThread ctx ep cmd resp comp killMv = finally brokerClientThread' cle
request <- takeMVar cmd
send sock [] (BL.toStrict $ encode request)
events <- poll 1000 [Sock sock [In] Nothing]
if (not . null) events
if (not . null) $ L.head events
then do
maybeResponse <- decode . BL.fromStrict <$> receive sock
case maybeResponse of

Loading…
Cancel
Save