diff options
author | Joe Crayne <joe@jerkface.net> | 2019-12-28 20:08:39 -0500 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2020-01-01 23:28:00 -0500 |
commit | 9e57739768cf456a8d3e85c43321d5997cf19ed5 (patch) | |
tree | 918e41ab2f5a37bbf141c22a5bf0be4a15e02957 | |
parent | 36b07bb1396244b8b4ed8ad5b0c81351195d8428 (diff) |
Now searchCancel works so remove killThread hack.
-rw-r--r-- | dht/examples/dhtd.hs | 10 |
1 files 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 | |||
1060 | schs <- readTVar dhtSearches | 1060 | schs <- readTVar dhtSearches |
1061 | case Map.lookup (method,nid) schs of | 1061 | case Map.lookup (method,nid) schs of |
1062 | Nothing -> return $ hPutClient h "No match." | 1062 | Nothing -> return $ hPutClient h "No match." |
1063 | Just DHTSearch{searchThread} -> do | 1063 | Just DHTSearch{searchState} -> do |
1064 | modifyTVar' dhtSearches (Map.delete (method,nid)) | 1064 | modifyTVar' dhtSearches (Map.delete (method,nid)) |
1065 | searchCancel searchState | ||
1065 | return $ do | 1066 | return $ do |
1066 | killThread searchThread | 1067 | -- killThread searchThread |
1067 | hPutClient h "Removed search." | 1068 | hPutClient h "Removed search." |
1068 | removeAll = join $ atomically $ do | 1069 | removeAll = join $ atomically $ do |
1069 | schs <- readTVar dhtSearches | 1070 | schs <- readTVar dhtSearches |
@@ -1071,8 +1072,9 @@ clientSession s@Session{..} sock cnum h = do | |||
1071 | writeTVar dhtSearches remainder | 1072 | writeTVar dhtSearches remainder |
1072 | return $ do | 1073 | return $ do |
1073 | ns <- forM (Map.toList scrapped) $ | 1074 | ns <- forM (Map.toList scrapped) $ |
1074 | \((m,nid),DHTSearch{searchThread}) -> do | 1075 | \((m,nid),DHTSearch{searchState}) -> do |
1075 | killThread searchThread | 1076 | atomically $ searchCancel searchState |
1077 | -- killThread searchThread | ||
1076 | return $ show nid | 1078 | return $ show nid |
1077 | hPutClient h $ unlines $ map (mappend "Removed " . mappend method . mappend " ") ns | 1079 | hPutClient h $ unlines $ map (mappend "Removed " . mappend method . mappend " ") ns |
1078 | case nidstr of | 1080 | case nidstr of |