{"schema":"libjg2-1",
"vpath":"/git/",
"avatar":"/git/avatar/",
"alang":"",
"gen_ut":1750807545,
"reponame":"libwebsockets",
"desc":"libwebsockets lightweight C networking library",
"owner": { "name": "Andy Green", "email": "andy@warmcat.com", "md5": "c50933ca2aa61e0fe2c43d46bb6b59cb" },"url":"https://libwebsockets.org/repo/libwebsockets",
"f":3,
"items": [
{"schema":"libjg2-1",
"cid":"b4279bc5562897976ead84b9bb4df65d",
"commit": {"type":"commit",
"time": 1565610276,
"time_ofs": 60,
"oid_tree": { "oid": "05cba96deed90fc48c8bef7f5521d20aaa8e22e6", "alias": []},
"oid":{ "oid": "d3021980194991d175388115a65a4265bd155f36", "alias": []},
"msg": "external poll: add default-off cmake option",
"sig_commit": { "git_time": { "time": 1565610276, "offset": 60 }, "name": "Andy Green", "email": "andy@warmcat.com", "md5": "c50933ca2aa61e0fe2c43d46bb6b59cb" },
"sig_author": { "git_time": { "time": 1565425987, "offset": 60 }, "name": "Andy Green", "email": "andy@warmcat.com", "md5": "c50933ca2aa61e0fe2c43d46bb6b59cb" }},
"body": "external poll: add default-off cmake option\n\nExternal poll support generates a lot of messages on a busy system\nfor no value unless you're one of the few people using it. It's\nnot recommended for new users and is there for backwards compatibility.\n\nMake it not built by default and selectable by cmake option."
,
"diff": "diff --git a/CMakeLists.txt b/CMakeLists.txt\nindex b7391d0..f215560 100644\n--- a/CMakeLists.txt\n+++ b/CMakeLists.txt\n@@ -131,6 +131,7 @@ option(LWS_WITH_BUNDLED_ZLIB \u0022Use bundled zlib version (Windows only)\u0022 ${LWS_WIT\n option(LWS_WITH_MINIZ \u0022Use miniz instead of zlib\u0022 OFF)\n option(LWS_WITH_DEPRECATED_LWS_DLL \u0022Migrate to lws_dll2 instead ASAP\u0022 OFF)\n option(LWS_WITH_SEQUENCER \u0022lws_seq_t support\u0022 ON)\n+option(LWS_WITH_EXTERNAL_POLL \u0022Support external POLL integration using callback messages (not recommended)\u0022 OFF)\n #\n # to use miniz, enable both LWS_WITH_ZLIB and LWS_WITH_MINIZ\n #\ndiff --git a/cmake/lws_config.h.in b/cmake/lws_config.h.in\nindex 021024b..9690a48 100644\n--- a/cmake/lws_config.h.in\n+++ b/cmake/lws_config.h.in\n@@ -100,6 +100,7 @@\n #cmakedefine LWS_WITH_DEPRECATED_LWS_DLL\n #cmakedefine LWS_WITH_DIR\n #cmakedefine LWS_WITH_ESP32\n+#cmakedefine LWS_WITH_EXTERNAL_POLL\n #cmakedefine LWS_WITH_FTS\n #cmakedefine LWS_WITH_GENCRYPTO\n #cmakedefine LWS_WITH_GENERIC_SESSIONS\ndiff --git a/lib/core-net/connect.c b/lib/core-net/connect.c\nindex 8eacb81..604bebb 100644\n--- a/lib/core-net/connect.c\n+++ b/lib/core-net/connect.c\n@@ -57,11 +57,6 @@ lws_client_connect_via_info(const struct lws_client_connect_info *i)\n \t\tif (lws_protocol_init(i-\u003econtext))\n \t\t\treturn NULL;\n \n-#if LWS_MAX_SMP \u003e 1\n-\ttid \u003d wsi-\u003evhost-\u003eprotocols[0].callback(wsi, LWS_CALLBACK_GET_THREAD_ID,\n-\t\t\t\t\t\tNULL, NULL, 0);\n-#endif\n-\n \t/*\n \t * If we have .local_protocol_name, use it to select the local protocol\n \t * handler to bind to. Otherwise use .protocol if http[s].\n@@ -93,6 +88,11 @@ lws_client_connect_via_info(const struct lws_client_connect_info *i)\n \t\tgoto bail;\n \t}\n \n+#if LWS_MAX_SMP \u003e 1\n+\ttid \u003d wsi-\u003evhost-\u003eprotocols[0].callback(wsi, LWS_CALLBACK_GET_THREAD_ID,\n+\t\t\t\t\t\tNULL, NULL, 0);\n+#endif\n+\n \t/*\n \t * PHASE 2: if SMP, bind the client to whatever tsi the current thread\n \t * represents\ndiff --git a/lib/core-net/pollfd.c b/lib/core-net/pollfd.c\nindex d2267bd..725861c 100644\n--- a/lib/core-net/pollfd.c\n+++ b/lib/core-net/pollfd.c\n@@ -147,6 +147,8 @@ _lws_change_pollfd(struct lws *wsi, int _and, int _or, struct lws_pollargs *pa)\n \tif (wsi-\u003ehttp2_substream)\n \t\treturn 0;\n \n+#if defined(LWS_WITH_EXTERNAL_POLL)\n+\n \tif (wsi-\u003evhost \u0026\u0026\n \t wsi-\u003evhost-\u003eprotocols[0].callback(wsi,\n \t\t\t \t \t LWS_CALLBACK_CHANGE_MODE_POLL_FD,\n@@ -154,6 +156,7 @@ _lws_change_pollfd(struct lws *wsi, int _and, int _or, struct lws_pollargs *pa)\n \t\tret \u003d -1;\n \t\tgoto bail;\n \t}\n+#endif\n \n \tif (context-\u003eevent_loop_ops-\u003eio) {\n \t\tif (_and \u0026 LWS_POLLIN)\n@@ -254,7 +257,9 @@ __dump_fds(struct lws_context_per_thread *pt, const char *s)\n int\n __insert_wsi_socket_into_fds(struct lws_context *context, struct lws *wsi)\n {\n+#if defined(LWS_WITH_EXTERNAL_POLL)\n \tstruct lws_pollargs pa \u003d { wsi-\u003edesc.sockfd, LWS_POLLIN, 0 };\n+#endif\n \tstruct lws_context_per_thread *pt \u003d \u0026context-\u003ept[(int)wsi-\u003etsi];\n \tint ret \u003d 0;\n \n@@ -283,10 +288,13 @@ __insert_wsi_socket_into_fds(struct lws_context *context, struct lws *wsi)\n \tassert(wsi-\u003eevent_pipe || wsi-\u003evhost);\n \tassert(lws_socket_is_valid(wsi-\u003edesc.sockfd));\n \n+#if defined(LWS_WITH_EXTERNAL_POLL)\n+\n \tif (wsi-\u003evhost \u0026\u0026\n \t wsi-\u003evhost-\u003eprotocols[0].callback(wsi, LWS_CALLBACK_LOCK_POLL,\n \t\t\t\t\t wsi-\u003euser_space, (void *) \u0026pa, 1))\n \t\treturn -1;\n+#endif\n \n \tif (insert_wsi(context, wsi))\n \t\treturn -1;\n@@ -295,25 +303,32 @@ __insert_wsi_socket_into_fds(struct lws_context *context, struct lws *wsi)\n \n \tpt-\u003efds[wsi-\u003eposition_in_fds_table].fd \u003d wsi-\u003edesc.sockfd;\n \tpt-\u003efds[wsi-\u003eposition_in_fds_table].events \u003d LWS_POLLIN;\n+#if defined(LWS_WITH_EXTERNAL_POLL)\n \tpa.events \u003d pt-\u003efds[pt-\u003efds_count].events;\n+#endif\n \n \tlws_plat_insert_socket_into_fds(context, wsi);\n \n+#if defined(LWS_WITH_EXTERNAL_POLL)\n+\n \t/* external POLL support via protocol 0 */\n \tif (wsi-\u003evhost \u0026\u0026\n \t wsi-\u003evhost-\u003eprotocols[0].callback(wsi, LWS_CALLBACK_ADD_POLL_FD,\n \t\t\t\t\t wsi-\u003euser_space, (void *) \u0026pa, 0))\n \t\tret \u003d -1;\n+#endif\n #ifndef LWS_NO_SERVER\n \t/* if no more room, defeat accepts on this thread */\n \tif ((unsigned int)pt-\u003efds_count \u003d\u003d context-\u003efd_limit_per_thread - 1)\n \t\tlws_accept_modulation(context, pt, 0);\n #endif\n \n+#if defined(LWS_WITH_EXTERNAL_POLL)\n \tif (wsi-\u003evhost \u0026\u0026\n \t wsi-\u003evhost-\u003eprotocols[0].callback(wsi, LWS_CALLBACK_UNLOCK_POLL,\n \t\t\t\t\t wsi-\u003euser_space, (void *)\u0026pa, 1))\n \t\tret \u003d -1;\n+#endif\n \n //\t__dump_fds(pt, \u0022post insert\u0022);\n \n@@ -324,7 +339,9 @@ int\n __remove_wsi_socket_from_fds(struct lws *wsi)\n {\n \tstruct lws_context *context \u003d wsi-\u003econtext;\n+#if defined(LWS_WITH_EXTERNAL_POLL)\n \tstruct lws_pollargs pa \u003d { wsi-\u003edesc.sockfd, 0, 0 };\n+#endif\n \tstruct lws_context_per_thread *pt \u003d \u0026context-\u003ept[(int)wsi-\u003etsi];\n \tstruct lws *end_wsi;\n \tint v, m, ret \u003d 0;\n@@ -340,11 +357,12 @@ __remove_wsi_socket_from_fds(struct lws *wsi)\n \t\treturn 1;\n \t}\n #endif\n-\n+#if defined(LWS_WITH_EXTERNAL_POLL)\n \tif (wsi-\u003evhost \u0026\u0026 wsi-\u003evhost-\u003eprotocols \u0026\u0026\n \t wsi-\u003evhost-\u003eprotocols[0].callback(wsi, LWS_CALLBACK_LOCK_POLL,\n \t\t\t\t\t wsi-\u003euser_space, (void *)\u0026pa, 1))\n \t\treturn -1;\n+#endif\n \n \tlws_same_vh_protocol_remove(wsi);\n \n@@ -401,11 +419,13 @@ __remove_wsi_socket_from_fds(struct lws *wsi)\n \t\twsi-\u003eposition_in_fds_table \u003d LWS_NO_FDS_POS;\n \t}\n \n+#if defined(LWS_WITH_EXTERNAL_POLL)\n \t/* remove also from external POLL support via protocol 0 */\n \tif (lws_socket_is_valid(wsi-\u003edesc.sockfd) \u0026\u0026 wsi-\u003evhost \u0026\u0026\n \t wsi-\u003evhost-\u003eprotocols[0].callback(wsi, LWS_CALLBACK_DEL_POLL_FD,\n \t\t\t\t\t wsi-\u003euser_space, (void *) \u0026pa, 0))\n \t\tret \u003d -1;\n+#endif\n \n #ifndef LWS_NO_SERVER\n \tif (!context-\u003ebeing_destroyed \u0026\u0026\n@@ -414,10 +434,12 @@ __remove_wsi_socket_from_fds(struct lws *wsi)\n \t\tlws_accept_modulation(context, pt, 1);\n #endif\n \n+#if defined(LWS_WITH_EXTERNAL_POLL)\n \tif (wsi-\u003evhost \u0026\u0026\n \t wsi-\u003evhost-\u003eprotocols[0].callback(wsi, LWS_CALLBACK_UNLOCK_POLL,\n \t\t\t\t\t wsi-\u003euser_space, (void *) \u0026pa, 1))\n \t\tret \u003d -1;\n+#endif\n \n //\t__dump_fds(pt, \u0022post remove\u0022);\n \n@@ -439,16 +461,21 @@ __lws_change_pollfd(struct lws *wsi, int _and, int _or)\n \tif (!context)\n \t\treturn 1;\n \n+#if defined(LWS_WITH_EXTERNAL_POLL)\n \tif (wsi-\u003evhost \u0026\u0026\n \t wsi-\u003evhost-\u003eprotocols[0].callback(wsi, LWS_CALLBACK_LOCK_POLL,\n \t\t\t\t\t wsi-\u003euser_space, (void *) \u0026pa, 0))\n \t\treturn -1;\n+#endif\n \n \tret \u003d _lws_change_pollfd(wsi, _and, _or, \u0026pa);\n+\n+#if defined(LWS_WITH_EXTERNAL_POLL)\n \tif (wsi-\u003evhost \u0026\u0026\n \t wsi-\u003evhost-\u003eprotocols[0].callback(wsi, LWS_CALLBACK_UNLOCK_POLL,\n \t\t\t\t\t wsi-\u003euser_space, (void *) \u0026pa, 0))\n \t\tret \u003d -1;\n+#endif\n \n \treturn ret;\n }\ndiff --git a/test-apps/test-server.c b/test-apps/test-server.c\nindex 3e3a006..bc70cb0 100644\n--- a/test-apps/test-server.c\n+++ b/test-apps/test-server.c\n@@ -35,7 +35,7 @@ int close_testing;\n int max_poll_elements;\n int debug_level \u003d LLL_USER | 7;\n \n-#ifdef EXTERNAL_POLL\n+#if defined(LWS_WITH_EXTERNAL_POLL)\n struct lws_pollfd *pollfds;\n int *fd_lookup;\n int count_pollfds;\n@@ -479,7 +479,7 @@ int main(int argc, char **argv)\n \tlwsl_notice(\u0022(C) Copyright 2010-2018 Andy Green \u003candy@warmcat.com\u003e\u005cn\u0022);\n \n \tprintf(\u0022Using resource path \u005c\u0022%s\u005c\u0022\u005cn\u0022, resource_path);\n-#ifdef EXTERNAL_POLL\n+#if defined(LWS_WITH_EXTERNAL_POLL)\n #if !defined(WIN32) \u0026\u0026 !defined(_WIN32) \u0026\u0026 !defined(__ANDROID__)\n \tmax_poll_elements \u003d getdtablesize();\n #else\n@@ -593,7 +593,7 @@ int main(int argc, char **argv)\n \t\t * as soon as it can take more packets (usually immediately)\n \t\t */\n \n-#ifdef EXTERNAL_POLL\n+#if defined(LWS_WITH_EXTERNAL_POLL)\n \t\t/*\n \t\t * this represents an existing server's single poll action\n \t\t * which also includes libwebsocket sockets\n@@ -642,7 +642,7 @@ int main(int argc, char **argv)\n \n \t}\n \n-#ifdef EXTERNAL_POLL\n+#if defined(LWS_WITH_EXTERNAL_POLL)\n done:\n #endif\n \n","s":{"c":1750807545,"u": 4478}}
],"g": 6811,"chitpc": 0,"ehitpc": 0,"indexed":0
,
"ab": 0, "si": 0, "db":0, "di":0, "sat":0, "lfc": "0000"}