git-annex/Assistant
Joey Hess 345ee4f37c Switch to MonadCatchIO-transformers for better handling of state while catching exceptions.
As seen in this bug report, the lifted exception handling using the StateT
monad throws away state changes when an action throws an exception.
http://git-annex.branchable.com/bugs/git_annex_fork_bombs_on_gpg_file/
  .. Which can result in cached values being redundantly calculated, or other
     possibly worse bugs when the annex state gets out of sync with reality.

This switches from a StateT AnnexState to a ReaderT (MVar AnnexState).
All changes to the state go via the MVar. So when an Annex action is
running inside an exception handler, and it makes some changes, they
immediately go into affect in the MVar. If it then throws an exception
(or even crashes its thread!), the state changes are still in effect.

The MonadCatchIO-transformers change is actually only incidental.
I could have kept on using lifted-base for the exception handling.
However, I'd have needed to write a new instance of MonadBaseControl
for the new monad.. and I didn't write the old instance.. I begged Bas
and he kindly sent it to me. Happily, MonadCatchIO-transformers is
able to derive a MonadCatchIO instance for my monad.

This is a deep level change. It passes the test suite! What could it break?

Well.. The most likely breakage would be to code that runs an Annex action
in an exception handler, and *wants* state changes to be thrown away.
Perhaps the state changes leaves the state inconsistent, or wrong. Since
there are relatively few places in git-annex that catch exceptions in the
Annex monad, and the AnnexState is generally just used to cache calculated
data, this is unlikely to be a problem.

Oh yeah, this change also makes Assistant.Types.ThreadedMonad a bit
redundant. It's now entirely possible to run concurrent Annex actions in
different threads, all sharing access to the same state! The ThreadedMonad
just adds some extra work on top of that, with its own MVar, and avoids
such actions possibly stepping on one-another's toes. I have not gotten
rid of it, but might try that later. Being able to run concurrent Annex
actions would simplify parts of the Assistant code.
2013-05-19 14:16:36 -04:00
..
Alert refactor alert button creation code 2013-04-04 01:48:26 -04:00
Install fix osx build 2013-04-22 11:24:48 -04:00
Pairing proof of concept remote reordering UI (needs to be changed to use drag and drop) 2013-03-13 17:59:33 -04:00
Threads test suite passes in direct mode 2013-05-17 15:59:37 -04:00
Types add uuid to all xmpp messages 2013-04-30 13:22:55 -04:00
WebApp fix build 2013-05-12 19:13:38 -04:00
XMPP clean up from windows porting 2013-05-11 18:23:41 -04:00
Alert.hs show one alert when bulk adding files 2013-04-24 13:04:46 -04:00
BranchChange.hs split BranchChange and lifted 2012-10-29 19:20:54 -04:00
Changes.hs use DList for the transfer queue 2013-04-25 01:33:44 -04:00
Commits.hs remove last use of TSet 2013-04-24 17:16:04 -04:00
Common.hs refactor alert button creation code 2013-04-04 01:48:26 -04:00
DaemonStatus.hs rename module 2013-05-12 19:19:28 -04:00
DeleteRemote.hs assistant: When built with git before 1.8.0, use git remote rm to delete a remote. Newer git uses git remote remove. 2013-04-22 16:53:09 -04:00
Drop.hs fix dropping files from untrusted repositories 2013-03-31 18:39:49 -04:00
Install.hs rename module 2013-05-12 19:19:28 -04:00
MakeRemote.hs webapp: Now automatically fills in any creds used by an existing remote when creating a new remote of the same type. Done for Internet Archive, S3, Glacier, and Box.com remotes. 2013-04-27 15:16:06 -04:00
Monad.hs Switch to MonadCatchIO-transformers for better handling of state while catching exceptions. 2013-05-19 14:16:36 -04:00
NamedThread.hs refactor alert button creation code 2013-04-04 01:48:26 -04:00
NetMessager.hs assistant: XMPP git pull and push requests are cached and sent when presence of a new client is detected. 2013-03-06 21:38:01 -04:00
Pairing.hs Makefile now builds using cabal, taking advantage of cabal's automatic detection of appropriate build flags. 2013-02-27 02:39:22 -04:00
Pushes.hs whitespace fixes 2012-12-13 00:45:27 -04:00
ScanRemotes.hs where indentation 2012-10-31 02:34:03 -04:00
Ssh.hs rename module 2013-05-12 19:19:28 -04:00
Sync.hs add uuid to all xmpp messages 2013-04-30 13:22:55 -04:00
TransferQueue.hs use DList for the transfer queue 2013-04-25 01:33:44 -04:00
TransferrerPool.hs 2 minor fixes to transferkeys, otherwise it was perfect 1st time! 2013-03-20 13:24:35 -04:00
TransferSlots.hs maintain pools of running transferkeys processes (untested) 2013-03-19 18:46:29 -04:00
WebApp.hs webapp: Fix a race that sometimes caused alerts or other notifications to be missed if they occurred while a page was loading. 2013-03-27 14:56:20 -04:00
XMPP.hs add uuid to all xmpp messages 2013-04-30 13:22:55 -04:00