1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

pipe2 where possible

This commit is contained in:
Andy Green 2018-04-12 21:37:59 +08:00
parent aa816e98a9
commit 65f87efca9
4 changed files with 14 additions and 1 deletions

View file

@ -567,6 +567,7 @@ include(CheckIncludeFile)
include(CheckIncludeFiles)
include(CheckLibraryExists)
include(CheckTypeSize)
include(CheckCSourceCompiles)
if (LWS_WITHOUT_BUILTIN_SHA1)
set(LWS_SHA1_USE_OPENSSL_NAME 1)
@ -1359,6 +1360,11 @@ else()
CHECK_FUNCTION_EXISTS(TLS_client_method LWS_HAVE_TLS_CLIENT_METHOD)
CHECK_FUNCTION_EXISTS(TLSv1_2_client_method LWS_HAVE_TLSV1_2_CLIENT_METHOD)
endif()
# ideally we want to use pipe2()
CHECK_C_SOURCE_COMPILES("#define _GNU_SOURCE\n#include <unistd.h>\nint main(void) {int fd[2];\n return pipe2(fd, 0);\n}\n" LWS_HAVE_PIPE2)
set(CMAKE_REQUIRED_LIBRARIES ${temp})
# Generate the lws_config.h that includes all the public compilation settings.
configure_file(

View file

@ -164,6 +164,8 @@
#cmakedefine LWS_HAVE_MALLOC_H
#cmakedefine LWS_HAVE_PIPE2
/* OpenSSL various APIs */
#cmakedefine LWS_HAVE_TLS_CLIENT_METHOD

View file

@ -19,6 +19,7 @@
* MA 02110-1301 USA
*/
#define _GNU_SOURCE
#include "private-libwebsockets.h"
#include <pwd.h>
@ -40,7 +41,11 @@ lws_plat_pipe_create(struct lws *wsi)
{
struct lws_context_per_thread *pt = &wsi->context->pt[(int)wsi->tsi];
#if defined(LWS_HAVE_PIPE2)
return pipe2(pt->dummy_pipe_fds, O_NONBLOCK);
#else
return pipe(pt->dummy_pipe_fds);
#endif
}
int

View file

@ -26,7 +26,7 @@ rops_handle_POLLIN_pipe(struct lws_context_per_thread *pt, struct lws *wsi,
struct lws_pollfd *pollfd)
{
#if !defined(WIN32) && !defined(_WIN32)
char s[10];
char s[100];
int n;
/*