Sending the signal while not being sure that is is
expected could be a race condition. Taking the mutex
avoids it.
In the same time, switch to broadcasting.
Change-Id: I3f43d0d860cccc61ec140ceef223f572f806872c
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
uint64_t x;
struct evloop *evloop = userdata;
read(evloop->efd, &x, sizeof x);
- pthread_cond_signal(&evloop->cond);
+ pthread_mutex_lock(&mutex);
+ pthread_cond_broadcast(&evloop->cond);
+ pthread_mutex_unlock(&mutex);
return 1;
}
el = &evloop[0];
if (!el->sdev) {
/* creates the eventfd for waking up polls */
- el->efd = eventfd(0, EFD_CLOEXEC|EFD_SEMAPHORE);
+ el->efd = eventfd(0, EFD_CLOEXEC);
if (el->efd < 0) {
ERROR("can't make eventfd for events");
goto error1;