|
|
|
|
@ -1453,7 +1453,7 @@ struct UASYNC* uasync_create(void) {
|
|
|
|
|
InitializeCriticalSection(&ua->posted_lock); |
|
|
|
|
|
|
|
|
|
#else |
|
|
|
|
// POSIX: use eventfd for reliable cross-thread wakeup
|
|
|
|
|
#ifdef __linux__ |
|
|
|
|
ua->wakeup_pipe[0] = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC); |
|
|
|
|
if (ua->wakeup_pipe[0] < 0) { |
|
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_UASYNC, "eventfd() failed: %s", strerror(errno)); |
|
|
|
|
@ -1461,6 +1461,19 @@ struct UASYNC* uasync_create(void) {
|
|
|
|
|
return NULL; |
|
|
|
|
} |
|
|
|
|
ua->wakeup_pipe[1] = ua->wakeup_pipe[0]; |
|
|
|
|
#else |
|
|
|
|
if (pipe(ua->wakeup_pipe) < 0) { |
|
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_UASYNC, "pipe() failed: %s", strerror(errno)); |
|
|
|
|
u_free(ua); |
|
|
|
|
return NULL; |
|
|
|
|
} |
|
|
|
|
if (fcntl(ua->wakeup_pipe[0], F_SETFL, O_NONBLOCK) < 0) { |
|
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_UASYNC, "fcntl(wakeup_pipe[0], O_NONBLOCK) failed: %s", strerror(errno)); |
|
|
|
|
} |
|
|
|
|
if (fcntl(ua->wakeup_pipe[1], F_SETFL, O_NONBLOCK) < 0) { |
|
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_UASYNC, "fcntl(wakeup_pipe[1], O_NONBLOCK) failed: %s", strerror(errno)); |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
ua->wakeup_initialized = 1; |
|
|
|
|
|
|
|
|
|
#if HAS_EPOLL |
|
|
|
|
|