diff --git a/lib/plat/unix/unix-pipe.c b/lib/plat/unix/unix-pipe.c index b4470975a..ad04acbbc 100644 --- a/lib/plat/unix/unix-pipe.c +++ b/lib/plat/unix/unix-pipe.c @@ -31,18 +31,34 @@ int lws_plat_pipe_create(struct lws *wsi) { struct lws_context_per_thread *pt = &wsi->a.context->pt[(int)wsi->tsi]; + int n; #if defined(LWS_HAVE_EVENTFD) pt->dummy_pipe_fds[0] = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK); pt->dummy_pipe_fds[1] = -1; - return pt->dummy_pipe_fds[0] < 0 ? -1 : 0; + n = pt->dummy_pipe_fds[0] < 0 ? -1 : 0; + goto set; #elif defined(LWS_HAVE_PIPE2) - return pipe2(pt->dummy_pipe_fds, O_NONBLOCK); + n = pipe2(pt->dummy_pipe_fds, O_NONBLOCK); #else - return pipe(pt->dummy_pipe_fds); + n = pipe(pt->dummy_pipe_fds); #endif + +#if defined(LWS_HAVE_EVENTFD) +set: +#endif + if (n >= 0) { + if (fcntl(pt->dummy_pipe_fds[0], F_SETFL, O_NONBLOCK) < 0) + n = -1; + else if (pt->dummy_pipe_fds[1] >= 0) { + if (fcntl(pt->dummy_pipe_fds[1], F_SETFL, O_NONBLOCK) < 0) + n = -1; + } + } + + return n; } int diff --git a/lib/roles/netlink/ops-netlink.c b/lib/roles/netlink/ops-netlink.c index 9aa1028ee..6df2ceee8 100644 --- a/lib/roles/netlink/ops-netlink.c +++ b/lib/roles/netlink/ops-netlink.c @@ -510,6 +510,8 @@ rops_pt_init_destroy_netlink(struct lws_context *context, goto bail1; } + lws_plat_set_nonblocking(wsi->desc.sockfd); + __lws_lc_tag(context, &context->lcg[LWSLCG_VHOST], &wsi->lc, "netlink"); diff --git a/minimal-examples/http-server/minimal-http-server-eventlib-foreign/libevent.c b/minimal-examples/http-server/minimal-http-server-eventlib-foreign/libevent.c index b68b04307..a6c851085 100644 --- a/minimal-examples/http-server/minimal-http-server-eventlib-foreign/libevent.c +++ b/minimal-examples/http-server/minimal-http-server-eventlib-foreign/libevent.c @@ -43,9 +43,9 @@ foreign_event_loop_init_and_run_libevent(void) tv.tv_sec = 1; tv.tv_usec = 0; + event_enable_debug_mode(); loop_event = event_base_new(); - sighandler_event = evsignal_new((struct event_base *)loop_event, SIGINT, signal_cb_event, (void*)SIGINT);