diff --git a/CMakeLists.txt b/CMakeLists.txt index cf0f3a26b..8465289ca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -130,6 +130,7 @@ option(LWS_WITH_ZLIB "Include zlib support (required for extensions)" OFF) option(LWS_WITH_BUNDLED_ZLIB "Use bundled zlib version (Windows only)" ${LWS_WITH_BUNDLED_ZLIB_DEFAULT}) option(LWS_WITH_MINIZ "Use miniz instead of zlib" OFF) option(LWS_WITH_DEPRECATED_LWS_DLL "Migrate to lws_dll2 instead ASAP" OFF) +option(LWS_WITH_SEQUENCER "lws_seq_t support" ON) # # to use miniz, enable both LWS_WITH_ZLIB and LWS_WITH_MINIZ # @@ -217,6 +218,7 @@ if (NOT LWS_WITH_NETWORK) set(LWS_WITH_HTTP_STREAM_COMPRESSION 0) set(LWS_WITH_HTTP_BROTLI 0) set(LWS_WITH_POLL 0) + set(LWS_WITH_SEQUENCER 0) endif() if (LWS_WITH_STRUCT_SQLITE3) @@ -957,7 +959,6 @@ if (LWS_WITH_NETWORK) lib/core-net/network.c lib/core-net/vhost.c lib/core-net/pollfd.c - lib/core-net/sequencer.c lib/core-net/service.c lib/core-net/sorted-usec-list.c lib/core-net/stats.c @@ -966,13 +967,22 @@ if (LWS_WITH_NETWORK) lib/core-net/adopt.c lib/roles/pipe/ops-pipe.c ) + + if (LWS_WITH_SEQUENCER) + list(APPEND SOURCES + lib/core-net/sequencer.c) + endif() + if (LWS_WITH_ABSTRACT) list(APPEND SOURCES lib/abstract/abstract.c - lib/abstract/test-sequencer.c ) + if (LWS_WITH_SEQUENCER) + list(APPEND SOURCES + lib/abstract/test-sequencer.c) + endif() endif() - + if (LWS_WITH_STATS) list(APPEND SOURCES lib/core-net/stats.c diff --git a/cmake/lws_config.h.in b/cmake/lws_config.h.in index 6dc50f0c5..236a8881e 100644 --- a/cmake/lws_config.h.in +++ b/cmake/lws_config.h.in @@ -126,6 +126,7 @@ #cmakedefine LWS_WITH_POLL #cmakedefine LWS_WITH_RANGES #cmakedefine LWS_WITH_SELFTESTS +#cmakedefine LWS_WITH_SEQUENCER #cmakedefine LWS_WITH_SERVER_STATUS #cmakedefine LWS_WITH_SMTP #cmakedefine LWS_WITH_SOCKS5 diff --git a/lib/core-net/service.c b/lib/core-net/service.c index 3d91a1a80..b433fda90 100644 --- a/lib/core-net/service.c +++ b/lib/core-net/service.c @@ -557,9 +557,10 @@ lws_service_periodic_checks(struct lws_context *context, if (context->time_up < 1464083026 && now > 1464083026) context->time_up = now; - +#if defined(LWS_WITH_SEQUENCER) __lws_seq_timeout_check(pt, usnow); lws_pt_do_pending_sequencer_events(pt); +#endif if (context->last_timeout_check_s == now) return 0; diff --git a/lib/core/context.c b/lib/core/context.c index 0ed77b5e1..e0438390e 100644 --- a/lib/core/context.c +++ b/lib/core/context.c @@ -551,8 +551,10 @@ lws_context_destroy3(struct lws_context *context) for (n = 0; n < context->count_threads; n++) { struct lws_context_per_thread *pt = &context->pt[n]; - + (void)pt; +#if defined(LWS_WITH_SEQUENCER) lws_seq_destroy_all_on_pt(pt); +#endif if (context->event_loop_ops->destroy_pt) context->event_loop_ops->destroy_pt(context, n); diff --git a/lib/event-libs/common.c b/lib/event-libs/common.c index f869536cf..56357be95 100644 --- a/lib/event-libs/common.c +++ b/lib/event-libs/common.c @@ -1,7 +1,7 @@ /* * libwebsockets - small server side websockets and web server implementation * - * Copyright (C) 2010-2018 Andy Green + * Copyright (C) 2010-2019 Andy Green * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -38,11 +38,13 @@ __lws_event_service_get_earliest_wake(struct lws_context_per_thread *pt, us = t; seen = 1; } +#if defined(LWS_WITH_SEQUENCER) t = __lws_seq_timeout_check(pt, usnow); if (t && (!seen || t < us)) { us = t; seen = 1; } +#endif return us; } diff --git a/lib/plat/unix/unix-service.c b/lib/plat/unix/unix-service.c index 268f7465a..1b9b54c5e 100644 --- a/lib/plat/unix/unix-service.c +++ b/lib/plat/unix/unix-service.c @@ -138,12 +138,14 @@ _lws_plat_service_tsi(struct lws_context *context, int timeout_ms, int tsi) lws_pt_unlock(pt); +#if defined(LWS_WITH_SEQUENCER) /* * if there are any pending sequencer events, handle the next one * for all sequencers with pending events. If nothing to do returns * immediately. */ lws_pt_do_pending_sequencer_events(pt); +#endif m = 0; #if defined(LWS_ROLE_WS) && !defined(LWS_WITHOUT_EXTENSIONS) diff --git a/minimal-examples/api-tests/api-test-lws_sequencer/CMakeLists.txt b/minimal-examples/api-tests/api-test-lws_sequencer/CMakeLists.txt index cfb9b98ee..1d24090f5 100644 --- a/minimal-examples/api-tests/api-test-lws_sequencer/CMakeLists.txt +++ b/minimal-examples/api-tests/api-test-lws_sequencer/CMakeLists.txt @@ -64,6 +64,7 @@ ENDMACRO() set(requirements 1) require_lws_config(LWS_ROLE_H1 1 requirements) require_lws_config(LWS_WITHOUT_CLIENT 0 requirements) +require_lws_config(LWS_WITH_SEQUENCER 1 requirements) if (requirements) add_executable(${SAMP} ${SRCS})