From: Guus Sliepen Date: Wed, 22 Jul 2020 18:30:14 +0000 (+0200) Subject: Add reset_sync_flag(). X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=338f9b00960c55a865a9f07a87b7fd3c12b13bc8;p=meshlink Add reset_sync_flag(). This is for the test suite to reset a flag without broadcasting that it changed state. --- diff --git a/test/utils.c b/test/utils.c index c526ff0d..21b33f5e 100644 --- a/test/utils.c +++ b/test/utils.c @@ -25,6 +25,12 @@ void set_sync_flag(struct sync_flag *s, bool value) { assert(pthread_mutex_unlock(&s->mutex) == 0); } +void reset_sync_flag(struct sync_flag *s) { + assert(pthread_mutex_lock(&s->mutex) == 0); + s->flag = false; + assert(pthread_mutex_unlock(&s->mutex) == 0); +} + bool check_sync_flag(struct sync_flag *s) { bool flag; assert(pthread_mutex_lock(&s->mutex) == 0); diff --git a/test/utils.h b/test/utils.h index 883b9154..2a56ed83 100644 --- a/test/utils.h +++ b/test/utils.h @@ -15,6 +15,7 @@ struct sync_flag { extern void init_sync_flag(struct sync_flag *s); extern void set_sync_flag(struct sync_flag *s, bool value); +extern void reset_sync_flag(struct sync_flag *s); extern bool check_sync_flag(struct sync_flag *s); extern bool wait_sync_flag(struct sync_flag *s, int seconds);