From 096380fbdcecc737541a582bc631e8a2ef7eab98 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Tue, 24 Sep 2019 10:21:51 +0100 Subject: [PATCH] Add workaround for libwebsockets 3.2.0. --- ChangeLog.txt | 6 ++++++ src/loop.c | 16 ++++++++++++++++ src/mosquitto_broker_internal.h | 3 --- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index e8e5a92b..bcc1902c 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,9 @@ +1.6.7 - 201909xx +================ + +Broker: +- Add workaround for working with libwebsockets 3.2.0. + Client library: - Don't use `/` in autogenerated client ids, to avoid confusing with topics. diff --git a/src/loop.c b/src/loop.c index f0b1e18e..c63e9968 100644 --- a/src/loop.c +++ b/src/loop.c @@ -101,6 +101,14 @@ static void temp__expire_websockets_clients(struct mosquitto_db *db) } #endif +#if defined(WITH_WEBSOCKETS) && LWS_LIBRARY_VERSION_NUMBER == 3002000 +void lws__sul_callback(struct lws_sorted_usec_list *l) +{ +} + +static struct lws_sorted_usec_list sul; +#endif + int mosquitto_main_loop(struct mosquitto_db *db, mosq_sock_t *listensock, int listensock_count) { #ifdef WITH_SYS_TREE @@ -133,6 +141,11 @@ int mosquitto_main_loop(struct mosquitto_db *db, mosq_sock_t *listensock, int li time_t expiration_check_time = 0; char *id; + +#if defined(WITH_WEBSOCKETS) && LWS_LIBRARY_VERSION_NUMBER == 3002000 + memset(&sul, 0, sizeof(struct lws_sorted_usec_list)); +#endif + #ifndef WIN32 sigemptyset(&sigblock); sigaddset(&sigblock, SIGINT); @@ -603,6 +616,9 @@ int mosquitto_main_loop(struct mosquitto_db *db, mosq_sock_t *listensock, int li if(db->config->listeners[i].ws_context){ #if LWS_LIBRARY_VERSION_NUMBER > 3002000 libwebsocket_service(db->config->listeners[i].ws_context, -1); +#elif LWS_LIBRARY_VERSION_NUMBER == 3002000 + lws_sul_schedule(db->config->listeners[i].ws_context, 0, &sul, lws__sul_callback, 10); + libwebsocket_service(db->config->listeners[i].ws_context, 0); #else libwebsocket_service(db->config->listeners[i].ws_context, 0); #endif diff --git a/src/mosquitto_broker_internal.h b/src/mosquitto_broker_internal.h index 322c6a8a..a0ab5a07 100644 --- a/src/mosquitto_broker_internal.h +++ b/src/mosquitto_broker_internal.h @@ -37,9 +37,6 @@ Contributors: # define libwebsocket_protocols lws_protocols # define libwebsocket_callback_reasons lws_callback_reasons # define libwebsocket lws -# if LWS_LIBRARY_VERSION_NUMBER == 3002000 -# error "libwebsockets 3.2.0 is not compatible with Mosquitto. <3.1.0, or >=3.2.1 will work fine" -# endif # else # define lws_pollfd pollfd # define lws_service_fd(A, B) libwebsocket_service_fd((A), (B))