summaryrefslogtreecommitdiff
path: root/poll/unix/wakeup.c
diff options
context:
space:
mode:
Diffstat (limited to 'poll/unix/wakeup.c')
-rw-r--r--poll/unix/wakeup.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/poll/unix/wakeup.c b/poll/unix/wakeup.c
index 6c3dcd6fb..b7e9efd45 100644
--- a/poll/unix/wakeup.c
+++ b/poll/unix/wakeup.c
@@ -18,6 +18,7 @@
#include "apr_poll.h"
#include "apr_time.h"
#include "apr_portable.h"
+#include "apr_atomic.h"
#include "apr_arch_file_io.h"
#include "apr_arch_networkio.h"
#include "apr_arch_poll_private.h"
@@ -33,7 +34,7 @@ apr_status_t apr_poll_create_wakeup_pipe(apr_pool_t *pool, apr_pollfd_t *pfd,
apr_status_t rv;
if ((rv = apr_file_socket_pipe_create(&wakeup_pipe[0], &wakeup_pipe[1],
- pool)) != APR_SUCCESS)
+ pool)) != APR_SUCCESS)
return rv;
pfd->reqevents = APR_POLLIN;
@@ -80,9 +81,9 @@ apr_status_t apr_poll_create_wakeup_pipe(apr_pool_t *pool, apr_pollfd_t *pfd,
{
apr_status_t rv;
+ /* Read end of the pipe is non-blocking */
if ((rv = apr_file_pipe_create_ex(&wakeup_pipe[0], &wakeup_pipe[1],
- APR_WRITE_BLOCK,
- pool)) != APR_SUCCESS)
+ APR_WRITE_BLOCK, pool)))
return rv;
pfd->p = pool;
@@ -135,18 +136,11 @@ apr_status_t apr_poll_close_wakeup_pipe(apr_file_t **wakeup_pipe)
/* Read and discard whatever is in the wakeup pipe.
*/
-void apr_poll_drain_wakeup_pipe(apr_file_t **wakeup_pipe)
+void apr_poll_drain_wakeup_pipe(volatile apr_uint32_t *wakeup_set, apr_file_t **wakeup_pipe)
{
- char rb[512];
- apr_size_t nr = sizeof(rb);
-
- while (apr_file_read(wakeup_pipe[0], rb, &nr) == APR_SUCCESS) {
- /* Although we write just one byte to the other end of the pipe
- * during wakeup, multiple threads could call the wakeup.
- * So simply drain out from the input side of the pipe all
- * the data.
- */
- if (nr != sizeof(rb))
- break;
- }
+ char ch;
+
+ (void)apr_file_getc(&ch, wakeup_pipe[0]);
+ apr_atomic_set32(wakeup_set, 0);
}
+