Skip to content

Commit

Permalink
accesslib: mark_context_dirty() - fix race condition
Browse files Browse the repository at this point in the history
We had a 1s race condition where a user could get their rights loaded
at the exact time an admin is changing roles/caps and see the "old"
data. Or even see a half-updated view of the access controls.

Yuck.

So we fix the race condition backdating the dirtyness. Cheap, but
effective. And then we backdate it some more to cover for minor clock
flutter on clusters (you still need ntp however!).
  • Loading branch information
martinlanghoff committed Sep 19, 2007
1 parent 16cb1ef commit 8e9fa6b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/accesslib.php
Expand Up @@ -4978,7 +4978,10 @@ function mark_context_dirty($path) {

// only if it is a non-empty string
if (is_string($path) && $path !== '') {
set_config($path, time(), 'accesslib/dirtycontexts');
// The timestamp is 2s in the past to cover for
// - race conditions within the 1s granularity
// - very small clock offsets in clusters (use ntpd!)
set_config($path, time()-2, 'accesslib/dirtycontexts');
}
}

Expand Down

0 comments on commit 8e9fa6b

Please sign in to comment.