From 8d2bf9f844ac4ea66a1905f55c7f6fb066bf177a Mon Sep 17 00:00:00 2001 From: Ramakrishnan Muthukrishnan <ram@rkrishnan.org> Date: Fri, 11 Dec 2015 22:18:39 +0530 Subject: [PATCH] main: kill FS thread on exit (revisit) --- src/main/Main.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/Main.hs b/src/main/Main.hs index a7efef0..4efd36f 100644 --- a/src/main/Main.hs +++ b/src/main/Main.hs @@ -3,7 +3,7 @@ module Main where import Prelude hiding (log, length, readFile, getContents) -import Control.Concurrent (forkIO) +import Control.Concurrent (forkIO, killThread) import Control.Concurrent.MVar (readMVar) import Data.ByteString.Char8 (ByteString, getContents, readFile) import qualified FuncTorrent.FileSystem as FS (createMsgChannel, pieceMapFromFile, startThread) @@ -75,7 +75,7 @@ main = do log $ "Downloading file : " ++ filePath pieceMap <- FS.pieceMapFromFile filePath fileLen defaultPieceMap log $ "start filesystem manager thread" - withFile filePath ReadWriteMode (FS.startThread pieceMap fsMsgChannel) + fsTid <- withFile filePath ReadWriteMode (FS.startThread pieceMap fsMsgChannel) log $ "starting server" (serverSock, (PortNumber portnum)) <- Server.start log $ "server started on " ++ show portnum @@ -90,3 +90,4 @@ main = do let p1 = head ps handlePeerMsgs p1 peerId m pieceMap True fsMsgChannel logStop logR + killThread fsTid -- 2.45.2