diff --git a/CMakeLists.txt b/CMakeLists.txt index 4dee8266..deaeca4d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,6 +33,7 @@ option(WITH_BUILTIN_GETIFADDRS "Use BSD getifaddrs implementation from libwebsoc option(WITHOUT_TESTAPPS "Don't build the libwebsocket-test-apps" OFF) option(WITHOUT_CLIENT "Don't build the client part of the library" OFF) option(WITHOUT_SERVER "Don't build the server part of the library" OFF) +option(WITHOUT_SERVER_EXTPOLL "Don't build a server version that uses external poll" OFF) option(WITH_LIBCRYPTO "Use libcrypto MD5 and SHA1 implementations" ON) option(WITHOUT_PING "Don't build the ping test application" OFF) option(WITHOUT_DEBUG "Don't compile debug related code" OFF) @@ -237,7 +238,7 @@ source_group("Sources" FILES ${SOURCES}) # # Create the lib. # -add_library(websocket STATIC +add_library(websockets STATIC ${HDR_PRIVATE} ${HDR_PUBLIC} ${SOURCES}) @@ -287,7 +288,7 @@ endif() message("ZLib include dirs: ${ZLIB_INCLUDE_DIRS}") message("ZLib libraries: ${ZLIB_LIBRARIES}") include_directories(${ZLIB_INCLUDE_DIRS}) -target_link_libraries(websocket ${ZLIB_LIBRARIES}) +target_link_libraries(websockets ${ZLIB_LIBRARIES}) # # OpenSSL @@ -310,18 +311,18 @@ if (WITH_SSL) message("OpenSSL include dir: ${OPENSSL_INCLUDE_DIR}") message("OpenSSL libraries: ${OPENSSL_LIBRARIES}") include_directories(${OPENSSL_INCLUDE_DIR}) - target_link_libraries(websocket ${OPENSSL_LIBRARIES}) + target_link_libraries(websockets ${OPENSSL_LIBRARIES}) endif(WITH_SSL) # # Platform specific libs. # if (WIN32) - target_link_libraries(websocket ws2_32.lib) + target_link_libraries(websockets ws2_32.lib) endif() if (UNIX) - target_link_libraries(websocket m) + target_link_libraries(websockets m) endif() # @@ -352,7 +353,7 @@ if (NOT WITHOUT_TESTAPPS) source_group("Headers" FILES ${TEST_HDR}) source_group("Sources" FILES ${TEST_SRCS}) add_executable(${TEST_NAME} ${TEST_SRCS} ${TEST_HDR}) - target_link_libraries(${TEST_NAME} websocket) + target_link_libraries(${TEST_NAME} websockets) set_property( TARGET ${TEST_NAME} @@ -382,6 +383,22 @@ if (NOT WITHOUT_TESTAPPS) "${WIN32_HELPERS_PATH}/netdb.h;${WIN32_HELPERS_PATH}/strings.h;${WIN32_HELPERS_PATH}/unistd.h;${WIN32_HELPERS_PATH}/websock-w32.h") endif(NOT WITHOUT_SERVER) + # + # test-server-extpoll + # + if (NOT WITHOUT_SERVER_EXTPOLL) + create_test_app(test-server-extpoll + "test-server/test-server.c" + "" + "${WIN32_HELPERS_PATH}/netdb.h;${WIN32_HELPERS_PATH}/strings.h;${WIN32_HELPERS_PATH}/unistd.h;${WIN32_HELPERS_PATH}/websock-w32.h") + + # Set defines for this executable only. + set_property( + TARGET test-server-extpoll + PROPERTY COMPILE_DEFINITIONS EXTERNAL_POLL INSTALL_DATADIR="${SSL_CERT_DIR}" + ) + endif(NOT WITHOUT_SERVER_EXTPOLL) + # # test-fraggle # diff --git a/lib/daemonize.c b/lib/daemonize.c index c56ad7fc..ab537a0e 100644 --- a/lib/daemonize.c +++ b/lib/daemonize.c @@ -24,6 +24,11 @@ int pid_daemon; static char *lock_path; +int get_daemonize_pid() +{ + return pid_daemon; +} + static void child_handler(int signum) { diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c index 17fd7efc..d7471666 100644 --- a/lib/libwebsockets.c +++ b/lib/libwebsockets.c @@ -1513,7 +1513,8 @@ libwebsocket_create_context(int port, const char *interf, #endif #ifndef LWS_NO_DAEMONIZE - extern int pid_daemon; + extern int get_daemonize_pid(); + int pid_daemon = get_daemonize_pid(); #endif lwsl_notice("Initial logging level %d\n", log_level); @@ -1561,6 +1562,7 @@ libwebsocket_create_context(int port, const char *interf, if (wsdll) poll = (PFNWSAPOLL)GetProcAddress(wsdll, "WSAPoll"); + /* Finally fall back to emulated poll if all else fails */ if (!poll) poll = emulated_poll; } diff --git a/lib/private-libwebsockets.h b/lib/private-libwebsockets.h index 769f2a7e..5d618ae6 100644 --- a/lib/private-libwebsockets.h +++ b/lib/private-libwebsockets.h @@ -47,6 +47,14 @@ #include +#ifndef inline + #ifdef __inline + #define inline __inline + #elif defined(__inline__) + #define inline __inline__ + #endif +#endif + #ifdef WIN32 #define LWS_NO_DAEMONIZE @@ -390,8 +398,8 @@ struct libwebsocket { }; #ifndef LWS_LATENCY -#define lws_latency(context, wsi, action, ret, completion) -#define lws_latency_pre(context, wsi) +static void lws_latency(struct libwebsocket_context *context, struct libwebsocket *wsi, const char *action, int ret, int completion) { while (0); } +static void lws_latency_pre(struct libwebsocket_context *context, struct libwebsocket *wsi) { while (0); } #else #define lws_latency_pre(_context, _wsi) lws_latency(_context, _wsi, NULL, 0, 0) extern void