From 9c7ce251e40212c3f3a4bf75589beba4d86767b2 Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Fri, 5 Oct 2012 15:03:20 -0400 Subject: Admit base-4.6 in Build-Depends --- git-annex.cabal | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'git-annex.cabal') diff --git a/git-annex.cabal b/git-annex.cabal index 048cad3d3..518c63d8d 100644 --- a/git-annex.cabal +++ b/git-annex.cabal @@ -48,7 +48,7 @@ Executable git-annex Build-Depends: MissingH, hslogger, directory, filepath, unix, containers, utf8-string, network, mtl, bytestring, old-locale, time, pcre-light, extensible-exceptions, dataenc, SHA, process, json, HTTP, - base == 4.5.*, monad-control, transformers-base, lifted-base, + base >= 4.5 && < 4.7, monad-control, transformers-base, lifted-base, IfElse, text, QuickCheck >= 2.1, bloomfilter, edit-distance, process -- Need to list these because they're generated from .hsc files. Other-Modules: Utility.Touch Utility.Mounts @@ -95,7 +95,7 @@ Test-Suite test Build-Depends: testpack, HUnit, MissingH, hslogger, directory, filepath, unix, containers, utf8-string, network, mtl, bytestring, old-locale, time, pcre-light, extensible-exceptions, dataenc, SHA, process, json, HTTP, - base == 4.5.*, monad-control, transformers-base, lifted-base, + base >= 4.5 && < 4.7, monad-control, transformers-base, lifted-base, IfElse, text, QuickCheck >= 2.1, bloomfilter, edit-distance, process Other-Modules: Utility.Touch Include-Dirs: Utility -- cgit v1.2.3 From d8087d187dfa7b8b9d19085d05533ed203131bdc Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Fri, 5 Oct 2012 17:02:51 -0400 Subject: TransferSlots: Use SafeSemaphore's MSemN instead of QSemN from base As described in the documentation, QSemN is unsafe for a variety of reasons. --- Assistant/TransferSlots.hs | 13 +++++++------ git-annex.cabal | 5 +++-- 2 files changed, 10 insertions(+), 8 deletions(-) (limited to 'git-annex.cabal') diff --git a/Assistant/TransferSlots.hs b/Assistant/TransferSlots.hs index 9e9156ad9..c41b1d28c 100644 --- a/Assistant/TransferSlots.hs +++ b/Assistant/TransferSlots.hs @@ -16,9 +16,10 @@ import Logs.Transfer import qualified Control.Exception as E import Control.Concurrent +import qualified Control.Concurrent.MSemN as MSemN import Data.Typeable -type TransferSlots = QSemN +type TransferSlots = MSemN.MSemN Int {- A special exception that can be thrown to pause or resume a transfer, while - keeping its slot in use. -} @@ -39,21 +40,21 @@ numSlots :: Int numSlots = 1 newTransferSlots :: IO TransferSlots -newTransferSlots = newQSemN numSlots +newTransferSlots = MSemN.new numSlots {- Waits until a transfer slot becomes available, then runs a - TransferGenerator, and then runs the transfer action in its own thread. -} inTransferSlot :: TransferSlotRunner inTransferSlot dstatus s gen = do - waitQSemN s 1 + MSemN.wait s 1 runTransferThread dstatus s =<< gen {- Runs a TransferGenerator, and its transfer action, - without waiting for a slot to become available. -} inImmediateTransferSlot :: TransferSlotRunner inImmediateTransferSlot dstatus s gen = do - signalQSemN s (-1) + MSemN.signal s (-1) runTransferThread dstatus s =<< gen {- Runs a transfer action, in an already allocated transfer slot. @@ -67,7 +68,7 @@ inImmediateTransferSlot dstatus s gen = do - then rerunning the action. -} runTransferThread :: DaemonStatusHandle -> TransferSlots -> Maybe (Transfer, TransferInfo, IO ()) -> IO () -runTransferThread _ s Nothing = signalQSemN s 1 +runTransferThread _ s Nothing = MSemN.signal s 1 runTransferThread dstatus s (Just (t, info, a)) = do tid <- forkIO go updateTransferInfo dstatus t $ info { transferTid = Just tid } @@ -86,4 +87,4 @@ runTransferThread dstatus s (Just (t, info, a)) = do Just ResumeTransfer -> go _ -> done _ -> done - done = signalQSemN s 1 + done = MSemN.signal s 1 diff --git a/git-annex.cabal b/git-annex.cabal index 518c63d8d..d760d4adb 100644 --- a/git-annex.cabal +++ b/git-annex.cabal @@ -1,5 +1,5 @@ Name: git-annex -Version: 3.20121001 +Version: 3.20121002 Cabal-Version: >= 1.8 License: GPL Maintainer: Joey Hess @@ -49,7 +49,8 @@ Executable git-annex unix, containers, utf8-string, network, mtl, bytestring, old-locale, time, pcre-light, extensible-exceptions, dataenc, SHA, process, json, HTTP, base >= 4.5 && < 4.7, monad-control, transformers-base, lifted-base, - IfElse, text, QuickCheck >= 2.1, bloomfilter, edit-distance, process + IfElse, text, QuickCheck >= 2.1, bloomfilter, edit-distance, process, + SafeSemaphore -- Need to list these because they're generated from .hsc files. Other-Modules: Utility.Touch Utility.Mounts Include-Dirs: Utility -- cgit v1.2.3