fork off git-annex copy for transfers

This doesn't quite work, because canceling a transfer sends a signal
to git-annex, but not to rsync (etc).

Looked at making git-annex run in its own process group, which could then
be killed, and would kill child processes. But, rsync checks if it's
process group is the foreground process group and doesn't show progress if
not, and when git has run git-annex, if git-annex makes a new process
group, that is not the case. Also, if git has run git-annex, ctrl-c
wouldn't be propigated to it if it made a new process group.

So this seems like a blind alley, but recording it here just in case.
This commit is contained in:
Joey Hess 2012-08-10 14:14:08 -04:00
parent 2e1f3a86ae
commit d5e06e7b89
4 changed files with 44 additions and 63 deletions

View file

@ -11,7 +11,6 @@ import Control.Exception
import Control.Concurrent
import Common.Annex
import Assistant.ThreadedMonad
type TransferSlots = QSemN
@ -29,13 +28,12 @@ newTransferSlots = newQSemN numSlots
{- Waits until a transfer slot becomes available, and runs a transfer
- action in the slot, in its own thread. Note that this thread is
- subject to being killed when the transfer is canceled. -}
inTransferSlot :: TransferSlots -> ThreadState -> Annex a -> IO ThreadId
inTransferSlot s st a = do
inTransferSlot :: TransferSlots -> IO () -> IO ThreadId
inTransferSlot s a = do
waitQSemN s 1
forkIO $ bracket_ noop done run
forkIO $ bracket_ noop done a
where
done = transferComplete s
run = unsafeRunThreadState st a
{- Call when a transfer is complete. -}
transferComplete :: TransferSlots -> IO ()