2 * libwebsockets - small server side websockets and web server implementation
4 * Copyright (C) 2010-2018 Andy Green <andy@warmcat.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation:
9 * version 2.1 of the License.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
23 #include "core/private.h"
27 lws_plat_pipe_create(struct lws *wsi)
29 struct lws_context_per_thread *pt = &wsi->context->pt[(int)wsi->tsi];
31 #if defined(LWS_HAVE_PIPE2)
32 return pipe2(pt->dummy_pipe_fds, O_NONBLOCK);
34 return pipe(pt->dummy_pipe_fds);
39 lws_plat_pipe_signal(struct lws *wsi)
41 struct lws_context_per_thread *pt = &wsi->context->pt[(int)wsi->tsi];
45 n = write(pt->dummy_pipe_fds[1], &buf, 1);
51 lws_plat_pipe_close(struct lws *wsi)
53 struct lws_context_per_thread *pt = &wsi->context->pt[(int)wsi->tsi];
55 if (pt->dummy_pipe_fds[0] && pt->dummy_pipe_fds[0] != -1)
56 close(pt->dummy_pipe_fds[0]);
57 if (pt->dummy_pipe_fds[1] && pt->dummy_pipe_fds[1] != -1)
58 close(pt->dummy_pipe_fds[1]);
60 pt->dummy_pipe_fds[0] = pt->dummy_pipe_fds[1] = -1;