From 17648be234e3d7a4205af91a85e0f21f0d3e3391 Mon Sep 17 00:00:00 2001 From: River Tarnell Date: Sat, 28 Dec 2013 17:41:09 +0000 Subject: [PATCH] unix: fix non-OSX builds uv__stream_osx_interrupt_select was only defined on OS X, but is used elsewhere on all platforms. The intention was to implement it as a no-op on other platforms, but the entire definition was inside "#ifdef __APPLE__", so this didn't actually work. Fix: move it above the #ifdef. --- src/unix/stream.c | 50 +++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/unix/stream.c b/src/unix/stream.c index f4e9bf75..9f5d40cf 100644 --- a/src/unix/stream.c +++ b/src/unix/stream.c @@ -138,6 +138,31 @@ void uv__stream_init(uv_loop_t* loop, } +static void uv__stream_osx_interrupt_select(uv_stream_t* stream) { +#if defined(__APPLE__) + /* Notify select() thread about state change */ + uv__stream_select_t* s; + int r; + + s = stream->select; + if (s == NULL) + return; + + /* Interrupt select() loop + * NOTE: fake_fd and int_fd are socketpair(), thus writing to one will + * emit read event on other side + */ + do + r = write(s->fake_fd, "x", 1); + while (r == -1 && errno == EINTR); + + assert(r == 1); +#else /* !defined(__APPLE__) */ + /* No-op on any other platform */ +#endif /* !defined(__APPLE__) */ +} + + #if defined(__APPLE__) static void uv__stream_osx_select(void* arg) { uv_stream_t* stream; @@ -229,31 +254,6 @@ static void uv__stream_osx_select(void* arg) { } -static void uv__stream_osx_interrupt_select(uv_stream_t* stream) { -#if defined(__APPLE__) - /* Notify select() thread about state change */ - uv__stream_select_t* s; - int r; - - s = stream->select; - if (s == NULL) - return; - - /* Interrupt select() loop - * NOTE: fake_fd and int_fd are socketpair(), thus writing to one will - * emit read event on other side - */ - do - r = write(s->fake_fd, "x", 1); - while (r == -1 && errno == EINTR); - - assert(r == 1); -#else /* !defined(__APPLE__) */ - /* No-op on any other platform */ -#endif /* !defined(__APPLE__) */ -} - - static void uv__stream_osx_select_cb(uv_async_t* handle, int status) { uv__stream_select_t* s; uv_stream_t* stream;