diff options
author | Joe Crayne <joe@jerkface.net> | 2020-01-03 21:27:50 -0500 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2020-01-07 13:24:59 -0500 |
commit | c7fb8cfe16f821e4e148d1855a18cb81255743bc (patch) | |
tree | c035afc9ff870ea3bfc5b1dc7c4254ad0c0bf4b3 /server | |
parent | 5ea2de4e858cc89282561922bae257b6f9041d2e (diff) |
Async search.
Diffstat (limited to 'server')
-rw-r--r-- | server/src/Network/QueryResponse.hs | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/server/src/Network/QueryResponse.hs b/server/src/Network/QueryResponse.hs index 4f14ea3c..94eb4796 100644 --- a/server/src/Network/QueryResponse.hs +++ b/server/src/Network/QueryResponse.hs | |||
@@ -332,9 +332,6 @@ data TransactionMethods d qid addr x = TransactionMethods | |||
332 | -- will write the packet to the correct 'MVar' thus completing the | 332 | -- will write the packet to the correct 'MVar' thus completing the |
333 | -- dispatch. | 333 | -- dispatch. |
334 | , dispatchResponse :: qid -> Result x -> d -> STM (d, IO ()) | 334 | , dispatchResponse :: qid -> Result x -> d -> STM (d, IO ()) |
335 | -- | When a timeout interval elapses, this method is called to remove the | ||
336 | -- transaction from the table. | ||
337 | , dispatchCancel :: qid -> d -> STM d | ||
338 | } | 335 | } |
339 | 336 | ||
340 | -- | A set of methods necessary for dispatching incoming packets. | 337 | -- | A set of methods necessary for dispatching incoming packets. |
@@ -429,7 +426,9 @@ asyncQuery c@(Client net d err pending whoami _) meth q addr0 withResponse = do | |||
429 | tm_key <- registerTimeout tm expiry $ do | 426 | tm_key <- registerTimeout tm expiry $ do |
430 | atomically $ do | 427 | atomically $ do |
431 | tbl <- readTVar pending | 428 | tbl <- readTVar pending |
432 | v <- dispatchCancel (tableMethods d) qid tbl | 429 | -- Below, we discard the returned IO action since we will call |
430 | -- withResponse directly later. | ||
431 | (v,_) <- dispatchResponse (tableMethods d) qid TimedOut tbl | ||
433 | writeTVar pending v | 432 | writeTVar pending v |
434 | m <- takeMVar keyvar | 433 | m <- takeMVar keyvar |
435 | forM_ m $ \_ -> withResponse qid TimedOut | 434 | forM_ m $ \_ -> withResponse qid TimedOut |
@@ -505,8 +504,7 @@ transactionMethods' :: | |||
505 | -> (g -> (qid,g)) -- ^ Generate a new unique /tid/ value and update the generator state /g/. | 504 | -> (g -> (qid,g)) -- ^ Generate a new unique /tid/ value and update the generator state /g/. |
506 | -> TransactionMethods (g,t a) qid addr x | 505 | -> TransactionMethods (g,t a) qid addr x |
507 | transactionMethods' store load (TableMethods insert delete lookup) generate = TransactionMethods | 506 | transactionMethods' store load (TableMethods insert delete lookup) generate = TransactionMethods |
508 | { dispatchCancel = \tid (g,t) -> return (g, delete tid t) | 507 | { dispatchRegister = \nowPlusExpiry v a (g,t) -> do |
509 | , dispatchRegister = \nowPlusExpiry v a (g,t) -> do | ||
510 | let (tid,g') = generate g | 508 | let (tid,g') = generate g |
511 | let t' = insert tid (store v) nowPlusExpiry t -- (now + microsecondsDiff expiry) t | 509 | let t' = insert tid (store v) nowPlusExpiry t -- (now + microsecondsDiff expiry) t |
512 | return ( tid, (g',t') ) | 510 | return ( tid, (g',t') ) |