diff options
author | Venky Shankar <vshankar@redhat.com> | 2016-01-27 17:04:18 +0530 |
---|---|---|
committer | Venky Shankar <vshankar@redhat.com> | 2016-01-28 05:22:29 -0800 |
commit | 786a8b395b09126a1151865c57ec2753a26facbb (patch) | |
tree | 900655718512bb0593e0cd7f41c367e9cc80f3b6 | |
parent | eb5e71c26d780fd5e440893fcc78fa91c36fe0c1 (diff) |
features / bitrot: Prevent spurious pthread_cond_wait() wakeup
pthread_cond_wait() is prone to spurious wakeups and it's utmost
necessarry to check a boolean predicate for thread continuation.
See man(3) pthread_cond_wait() for details.
The following is done in bitrot scrubber:
if (list_empty (&fsscrub->scrublist))
pthread_cond_wait (&fsscrub->cond, &fsscrub->mutex);
followed by:
list_first_entry (&fsscrub->scrublist, ...)
A spurious wakeup from pthread_cond_wait() with the absence of
list_empty() check causes list_first_entry() to return garbage.
Change-Id: I08786b9686b5503fcad6127e4c2a2cfac4bb7849
BUG: 1302201
Signed-off-by: Venky Shankar <vshankar@redhat.com>
Reviewed-on: http://review.gluster.org/13302
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Tested-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Smoke: Gluster Build System <jenkins@build.gluster.com>
CentOS-regression: Gluster Build System <jenkins@build.gluster.com>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
-rw-r--r-- | xlators/features/bit-rot/src/bitd/bit-rot-scrub.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c b/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c index 0a7212cd828..d95008ca9a2 100644 --- a/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c +++ b/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c @@ -1039,7 +1039,7 @@ _br_scrubber_find_scrubbable_entry (struct br_scrubber *fsscrub, br_child_t *firstchild = NULL; while (1) { - if (list_empty (&fsscrub->scrublist)) + while (list_empty (&fsscrub->scrublist)) pthread_cond_wait (&fsscrub->cond, &fsscrub->mutex); firstchild = NULL; |