From 8c47549a75399fe0f375fbf1ad1de9f6cf2e1f44 Mon Sep 17 00:00:00 2001 From: joe Date: Tue, 18 Jul 2017 04:23:29 -0400 Subject: Oops. I wasn't giving sendQuery the needed transaction id. --- src/Network/QueryResponse.hs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Network/QueryResponse.hs b/src/Network/QueryResponse.hs index 6fa301c7..dc25faf8 100644 --- a/src/Network/QueryResponse.hs +++ b/src/Network/QueryResponse.hs @@ -59,11 +59,11 @@ forkListener client = do -- dispatch the response. sendQuery :: forall err a b tbl x meth tid addr. - Client err meth tid addr x -- ^ A query/response implementation. - -> MethodSerializer addr x meth a b -- ^ Information for marshalling the query. - -> a -- ^ The outbound query. - -> addr -- ^ Destination address of query. - -> IO (Maybe b) -- ^ The response, or 'Nothing' if it timed out. + Client err meth tid addr x -- ^ A query/response implementation. + -> MethodSerializer tid addr x meth a b -- ^ Information for marshalling the query. + -> a -- ^ The outbound query. + -> addr -- ^ Destination address of query. + -> IO (Maybe b) -- ^ The response, or 'Nothing' if it timed out. sendQuery (Client net d err pending whoami _) meth q addr = do mvar <- newEmptyMVar tid <- atomically $ do @@ -72,7 +72,7 @@ sendQuery (Client net d err pending whoami _) meth q addr = do writeTVar pending tbl' return tid self <- whoami (Just addr) - sendMessage net addr (wrapQuery meth self addr q) + sendMessage net addr (wrapQuery meth tid self addr q) mres <- timeout (methodTimeout meth) $ takeMVar mvar case mres of Just x -> return $ Just $ unwrapResponse meth x @@ -139,7 +139,7 @@ dispatchQuery (MethodHandler unwrapQ wrapR f) tid self x addr = -- | These four parameters are required to implement an ougoing query. A -- peer-to-peer algorithm will define a 'MethodSerializer' for every 'MethodHandler' that -- might be returned by 'lookupHandler'. -data MethodSerializer addr x meth a b = MethodSerializer +data MethodSerializer tid addr x meth a b = MethodSerializer { -- | Seconds to wait for a response. methodTimeout :: Int -- | A method identifier used for error reporting. This needn't be the @@ -149,7 +149,7 @@ data MethodSerializer addr x meth a b = MethodSerializer -- The /addr/ arguments are, respectively, our own origin address and the -- destination of the request. The /ctx/ argument is useful for attaching -- auxillary notations on all outgoing packets. - , wrapQuery :: addr -> addr -> a -> x + , wrapQuery :: tid -> addr -> addr -> a -> x -- | Parse an inbound packet /x/ into a response /b/ for this query. , unwrapResponse :: x -> b } @@ -211,12 +211,12 @@ onInbound f tr = tr data TransactionMethods d tid x = TransactionMethods { -- | Before a query is sent, this function stores an 'MVar' to which the - -- response will be written too. The returned _tid_ is a transaction id + -- response will be written too. The returned /tid/ is a transaction id -- that can be used to forget the 'MVar' if the remote peer is not -- responding. dispatchRegister :: MVar x -> d -> (tid, d) - -- | This method is invoked when an incomming packet _x_ indicates it is - -- a response to the transaction with id _tid_. The returned IO action + -- | This method is invoked when an incomming packet /x/ indicates it is + -- a response to the transaction with id /tid/. The returned IO action -- is will write the packet to the correct 'MVar' thus completing the -- dispatch. , dispatchResponse :: tid -> x -> d -> (d, IO ()) @@ -228,9 +228,9 @@ data TransactionMethods d tid x = TransactionMethods -- | The standard lookup table methods for use as input to 'transactionMethods' -- in lieu of directly implementing 'TransactionMethods'. data TableMethods t tid = TableMethods - { -- | Insert a new _tid_ entry into the transaction table. + { -- | Insert a new /tid/ entry into the transaction table. tblInsert :: forall a. tid -> a -> t a -> t a - -- | Delete transaction _tid_ from the transaction table. + -- | Delete transaction /tid/ from the transaction table. , tblDelete :: forall a. tid -> t a -> t a -- | Lookup the value associated with transaction /tid/. , tblLookup :: forall a. tid -> t a -> Maybe a -- cgit v1.2.3