#include "utils.h"
-void set_sync_flag(struct sync_flag *s) {
+void set_sync_flag(struct sync_flag *s, bool value) {
pthread_mutex_lock(&s->mutex);
- s->flag = true;
+ s->flag = value;
pthread_cond_broadcast(&s->cond);
pthread_mutex_unlock(&s->mutex);
}
timeout.tv_sec += seconds;
while(!s->flag)
- if(!pthread_cond_timedwait(&s->cond, &s->mutex, &timeout) || errno != EINTR)
+ if(!pthread_cond_timedwait(&s->cond, &s->mutex, &timeout) || errno != EINTR) {
break;
+ }
return s->flag;
}
// Don't poll in the application thread, use a condition variable to signal when the peer is online.
static void pair_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) {
- set_sync_flag(mesh->priv);
+ (void)node;
+
+ set_sync_flag(mesh->priv, reachable);
}
void start_meshlink_pair(meshlink_handle_t *a, meshlink_handle_t *b) {
- struct sync_flag pair_status = {};
+ struct sync_flag pair_status = {.flag = false};
a->priv = &pair_status;
meshlink_set_node_status_cb(a, pair_status_cb);