Commit graph

1512 commits

Author SHA1 Message Date
Joey Hess
5d63c2a4bb check files with lsof in batches before adding
I've tested both cases where this is necessary, and it works great!
A file with multiple writers is not added until the last one closes.
2012-06-15 22:36:42 -04:00
Joey Hess
7ee300a47f race avoidance
When there are duplicate add events for the same file, only add it once.
2012-06-15 20:55:03 -04:00
Joey Hess
59abd787c9 can't wait for LinkChanges specifically
There is indeed a race waiting for LinkChanges:

1. file annexed, link made
2. link deleted
3. inotify event for link creation runs, but as link is gone, handler is not run
2012-06-15 19:17:21 -04:00
Joey Hess
679ef4c858 continued work on deferred addding 2012-06-15 19:00:06 -04:00
Joey Hess
c27c751b34 preliminary deferring of file adds to commit time
Defer adding files to the annex until commit time, when during a batch
operation, a bundle of files will be available. This will allow for
checking a them all with a single lsof call.

The tricky part is that adding the file causes a symlink change inotify.
So I made it wait for an appropriate number of symlink changes to be
received before continuing with the commit. This avoids any delay
in the commit process. It is possible that some unrelated symlink change is
made; if that happens it'll commit it and delay committing the newly added
symlink for 1 second. This seems ok. I do rely on the expected symlink
change event always being received, but only when the add succeeds.

Another way to do it might be to directly stage the symlink, and then
ignore the redundant symlink change event. That would involve some
redundant work, and perhaps an empty commit, but if this code turns
out to have some bug, that'd be the best way to avoid it.

FWIW, this change seems to, as a bonus, have produced better grouping
of batch changes into single commits. Before, a large batch change would
result in a series of commits, with the first containing only one file,
and each of the rest bundling a number of files. Now, the added wait for
the symlink changes to arrive gives time for additional add changes to
be processed, all within the same commit.
2012-06-15 19:00:06 -04:00
Joey Hess
8c7dfc93b5 catch IO exceptions in runThreadState
A few places catch IO errors after calling runThreadState,
but since the MVar was not restored, it'd later deadlock trying to read
from it.

I'd like to catch all exceptions here, but I could not get the types
to unify.
2012-06-15 19:00:06 -04:00
Joey Hess
8919c2e4da check for unstaged old symlinks in the sanity checker 2012-06-13 19:25:47 -04:00
Joey Hess
4b9b9b4947 add sanity checker thread
Currently wakes up once a day, and does nothing. :)
2012-06-13 17:54:23 -04:00
Joey Hess
7575c5bb56 tweak 2012-06-13 14:19:21 -04:00
Joey Hess
59a7b3a51a finish daemon status thread 2012-06-13 14:02:40 -04:00
Joey Hess
ff2414427b implement daemon status serialization to a file
Also afterLastDaemonRun, with 10 minute slop to handle majority of clock
skew issues.
2012-06-13 13:35:15 -04:00
Joey Hess
ccc5005245 reorganize 2012-06-13 12:46:39 -04:00