summaryrefslogtreecommitdiff
path: root/dht/examples
diff options
context:
space:
mode:
Diffstat (limited to 'dht/examples')
-rw-r--r--dht/examples/dhtd.hs15
1 files changed, 13 insertions, 2 deletions
diff --git a/dht/examples/dhtd.hs b/dht/examples/dhtd.hs
index 6bbb3388..287301d4 100644
--- a/dht/examples/dhtd.hs
+++ b/dht/examples/dhtd.hs
@@ -1773,8 +1773,10 @@ main = do
1773 (waitForSignal, checkQuit) <- do 1773 (waitForSignal, checkQuit) <- do
1774 signalQuit <- atomically $ newTVar False 1774 signalQuit <- atomically $ newTVar False
1775 let quitCommand = atomically $ writeTVar signalQuit True 1775 let quitCommand = atomically $ writeTVar signalQuit True
1776 installHandler sigTERM (CatchOnce (atomically $ writeTVar signalQuit True)) Nothing 1776 installHandler sigTERM (CatchOnce (do dput XMisc "sigTERM!"
1777 installHandler sigINT (CatchOnce (atomically $ writeTVar signalQuit True)) Nothing 1777 atomically $ writeTVar signalQuit True)) Nothing
1778 installHandler sigINT (CatchOnce (do dput XMisc "sigINT!"
1779 atomically $ writeTVar signalQuit True)) Nothing
1778 let defaultToxData = do 1780 let defaultToxData = do
1779 rster <- Tox.newContactInfo 1781 rster <- Tox.newContactInfo
1780 crypto <- newCrypto 1782 crypto <- newCrypto
@@ -1848,6 +1850,13 @@ main = do
1848 quitBt 1850 quitBt
1849 quitTox 1851 quitTox
1850 1852
1853 -- dput XMisc "Raising sigINT"
1854 -- raiseSignal sigINT
1855 -- dput XMisc "Raising sigTERM"
1856 -- raiseSignal sigTERM -- This shouldn't cause a termination because the signal handler is still installed.
1857 -- -- However, it will interrupt any dangling calls to recvFrom so that those threads
1858 -- -- can clean up.
1859
1851 swarmsdb <- atomically $ readTVar (Mainline.contactInfo swarms) 1860 swarmsdb <- atomically $ readTVar (Mainline.contactInfo swarms)
1852 forM_ (Map.toList dhts) $ \(netname,dht) -> do 1861 forM_ (Map.toList dhts) $ \(netname,dht) -> do
1853 saveNodes netname dht 1862 saveNodes netname dht
@@ -1855,5 +1864,7 @@ main = do
1855 L.writeFile "bt-peers.dat" $ S.encodeLazy swarmsdb 1864 L.writeFile "bt-peers.dat" $ S.encodeLazy swarmsdb
1856 dput XMisc $ "Saved bt-peers.dat" 1865 dput XMisc $ "Saved bt-peers.dat"
1857 1866
1867 -- threadDelay 1000000
1868
1858 s <- threadReport False 1869 s <- threadReport False
1859 putStrLn s 1870 putStrLn s