From 9e57739768cf456a8d3e85c43321d5997cf19ed5 Mon Sep 17 00:00:00 2001 From: Joe Crayne Date: Sat, 28 Dec 2019 20:08:39 -0500 Subject: Now searchCancel works so remove killThread hack. --- dht/examples/dhtd.hs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/dht/examples/dhtd.hs b/dht/examples/dhtd.hs index ce04b020..26f3f149 100644 --- a/dht/examples/dhtd.hs +++ b/dht/examples/dhtd.hs @@ -1060,10 +1060,11 @@ clientSession s@Session{..} sock cnum h = do schs <- readTVar dhtSearches case Map.lookup (method,nid) schs of Nothing -> return $ hPutClient h "No match." - Just DHTSearch{searchThread} -> do + Just DHTSearch{searchState} -> do modifyTVar' dhtSearches (Map.delete (method,nid)) + searchCancel searchState return $ do - killThread searchThread + -- killThread searchThread hPutClient h "Removed search." removeAll = join $ atomically $ do schs <- readTVar dhtSearches @@ -1071,8 +1072,9 @@ clientSession s@Session{..} sock cnum h = do writeTVar dhtSearches remainder return $ do ns <- forM (Map.toList scrapped) $ - \((m,nid),DHTSearch{searchThread}) -> do - killThread searchThread + \((m,nid),DHTSearch{searchState}) -> do + atomically $ searchCancel searchState + -- killThread searchThread return $ show nid hPutClient h $ unlines $ map (mappend "Removed " . mappend method . mappend " ") ns case nidstr of -- cgit v1.2.3