Skip to content

Commit 68b2f1a

Browse files
committed
Fix grace period over bound checking
The array of the grace period will have the number update run + 1 of the index. So the bound of the grace period is the number of update runs, not update run + 1.
1 parent 23c2dbb commit 68b2f1a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

thread-rcu/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ static void *reader_func(void *argv)
7171
if (tmp->count != old_prev_count)
7272
atomic_fetch_add_explicit(&gp_idx, 1, memory_order_release);
7373
if (atomic_load_explicit(&gp_idx, memory_order_acquire) >
74-
N_UPDATE_RUN + 1) {
74+
N_UPDATE_RUN) {
7575
fprintf(stderr, "grace period index (%u) is over bound (%u).\n",
7676
atomic_load_explicit(&gp_idx, memory_order_acquire),
7777
N_UPDATE_RUN);

0 commit comments

Comments
 (0)