diff options
author | Joey Hess <joey@kitenet.net> | 2013-05-19 14:16:36 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-05-19 14:16:36 -0400 |
commit | 8d5ba728e69cc028f4daf77e5af19947d0c515ef (patch) | |
tree | 2fa4bf9830b0895dd85fb547746ddb1597579fba /debian/control | |
parent | f33acb1b95f1afd896b5ee00f99c178ac2ef770f (diff) |
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.
Diffstat (limited to 'debian/control')
-rw-r--r-- | debian/control | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/debian/control b/debian/control index 4fdee49f9..2a914fc0b 100644 --- a/debian/control +++ b/debian/control @@ -16,7 +16,7 @@ Build-Depends: libghc-dav-dev (>= 0.3) [amd64 i386 kfreebsd-amd64 kfreebsd-i386 sparc], libghc-quickcheck2-dev, libghc-monad-control-dev (>= 0.3), - libghc-lifted-base-dev, + libghc-monadcatchio-transformers-dev, libghc-unix-compat-dev, libghc-dlist-dev, libghc-uuid-dev, @@ -38,7 +38,6 @@ Build-Depends: libghc-wai-logger-dev [i386 amd64 kfreebsd-i386 kfreebsd-amd64], libghc-case-insensitive-dev, libghc-http-types-dev, - libghc-transformers-dev, libghc-blaze-builder-dev, libghc-crypto-api-dev, libghc-network-multicast-dev, |