{"schema":"libjg2-1",
"vpath":"/git/",
"avatar":"/git/avatar/",
"alang":"",
"gen_ut":1747030878,
"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":"4270eb8eb5b16b59bced01ea8fa85948",
"commit": {"type":"commit",
"time": 1642330096,
"time_ofs": 0,
"oid_tree": { "oid": "16eeed28f6fbb8adaa3497c1cdc96f270913c4a2", "alias": []},
"oid":{ "oid": "b3ec5a0a4e3db7b2ebf91c281a3c27b021c3377b", "alias": []},
"msg": "client: support socket reuseaddr",
"sig_commit": { "git_time": { "time": 1642330096, "offset": 0 }, "name": "Andy Green", "email": "andy@warmcat.com", "md5": "c50933ca2aa61e0fe2c43d46bb6b59cb" },
"sig_author": { "git_time": { "time": 1642156113, "offset": 0 }, "name": "Sylvian Saunier", "email": "sylvian.saunier@gmail.com", "md5": "b876988a13302fccb7b919d1ee8e5f37" }},
"body": "client: support socket reuseaddr\n\n"
,
"diff": "diff --git a/include/libwebsockets/lws-client.h b/include/libwebsockets/lws-client.h\nindex 8563371..232b883 100644\n--- a/include/libwebsockets/lws-client.h\n+++ b/include/libwebsockets/lws-client.h\n@@ -50,6 +50,12 @@ enum lws_client_connect_ssl_connection_flags {\n \tLCCSCF_HTTP_NO_FOLLOW_REDIRECT\t\t\u003d (1 \u003c\u003c 12),\n \tLCCSCF_HTTP_NO_CACHE_CONTROL\t\t\u003d (1 \u003c\u003c 13),\n \n+\tLCCSCF_ALLOW_REUSE_ADDR\t\t\t\t\u003d (1 \u003c\u003c 14),\n+\t/**\u003c allow reuse local addresses in a bind call\n+\t * When the listening socket is bound to INADDR_ANY with a specific port \n+\t * then it is not possible to bind to this port for any local address\n+\t */\n+\n \tLCCSCF_PIPELINE\t\t\t\t\u003d (1 \u003c\u003c 16),\n \t\t/**\u003c Serialize / pipeline multiple client connections\n \t\t * on a single connection where possible.\ndiff --git a/lib/plat/freertos/freertos-sockets.c b/lib/plat/freertos/freertos-sockets.c\nindex c6bfec3..56d8006 100644\n--- a/lib/plat/freertos/freertos-sockets.c\n+++ b/lib/plat/freertos/freertos-sockets.c\n@@ -175,6 +175,20 @@ lws_plat_set_socket_options_ip(lws_sockfd_type fd, uint8_t pri, int lws_flags)\n \t}\n #endif\n \n+\tif (lws_flags \u0026 LCCSCF_ALLOW_REUSE_ADDR) {\n+\t\toptval \u003d 1;\n+\t\tif (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR,\n+\t\t\t\t\t(const void *)\u0026optval, optlen) \u003c 0) { \n+#if !defined(LWS_WITH_NO_LOGS)\n+\t\t\ten \u003d errno;\n+\t\t\tlwsl_warn(\u0022%s: unable to reuse local addresses: errno %d\u005cn\u0022,\n+\t\t\t\t__func__, en);\n+#endif\n+\t\t\tret \u003d 1;\n+\t\t} else\n+\t\t\tlwsl_notice(\u0022%s: set reuse addresses\u005cn\u0022, __func__);\n+\t}\n+\n \tfor (n \u003d 0; n \u003c 4; n++) {\n \t\tif (!(lws_flags \u0026 ip_opt_lws_flags[n]))\n \t\t\tcontinue;\ndiff --git a/lib/plat/unix/unix-sockets.c b/lib/plat/unix/unix-sockets.c\nindex 07df994..394e858 100644\n--- a/lib/plat/unix/unix-sockets.c\n+++ b/lib/plat/unix/unix-sockets.c\n@@ -255,6 +255,21 @@ lws_plat_set_socket_options_ip(lws_sockfd_type fd, uint8_t pri, int lws_flags)\n \t}\n #endif\n \n+\tif (lws_flags \u0026 LCCSCF_ALLOW_REUSE_ADDR) {\n+\t\toptval \u003d 1;\n+\t\tif (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR,\n+\t\t\t\t\t(const void *)\u0026optval, optlen) \u003c 0) { \n+#if !defined(LWS_WITH_NO_LOGS)\n+\t\t\ten \u003d errno;\n+\t\t\tlwsl_warn(\u0022%s: unable to reuse local addresses: errno %d\u005cn\u0022,\n+\t\t\t\t__func__, en);\n+#endif\n+\t\t\tret \u003d 1;\n+\t\t} else\n+\t\t\tlwsl_notice(\u0022%s: set reuse addresses\u005cn\u0022, __func__);\n+\t}\n+\n+\n \tfor (n \u003d 0; n \u003c 4; n++) {\n \t\tif (!(lws_flags \u0026 ip_opt_lws_flags[n]))\n \t\t\tcontinue;\ndiff --git a/lib/plat/windows/windows-sockets.c b/lib/plat/windows/windows-sockets.c\nindex 7570a03..6bbc066 100644\n--- a/lib/plat/windows/windows-sockets.c\n+++ b/lib/plat/windows/windows-sockets.c\n@@ -146,16 +146,56 @@ lws_plat_set_socket_options(struct lws_vhost *vhost, lws_sockfd_type fd,\n \n int\n lws_plat_set_socket_options_ip(lws_sockfd_type fd, uint8_t pri, int lws_flags)\n-{\n+{\t\n+\tint optval \u003d 1, ret \u003d 0;\n+\tsocklen_t optlen \u003d sizeof(optval);\n+#if !defined(LWS_WITH_NO_LOGS)\n+\tint en;\n+#endif\n+\n \t/*\n \t * Seems to require \u0022differeniated services\u0022 but no docs\n \t *\n \t * https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ip-socket-options\n \t * https://docs.microsoft.com/en-us/previous-versions/windows/desktop/qos/differentiated-services\n \t */\n-\tlwsl_warn(\u0022%s: not implemented on windows platform\u005cn\u0022, __func__);\n+\tlwsl_warn(\u0022%s: priority and ip sockets options not implemented on windows platform\u005cn\u0022, __func__);\n+\t\n \n-\treturn 0;\n+\t/*\n+\t* only accept that we are the only listener on the port\n+\t* https://msdn.microsoft.com/zh-tw/library/\n+\t* windows/desktop/ms740621(v\u003dvs.85).aspx\n+\t*\n+\t* for lws, to match Linux, we default to exclusive listen\n+\t*/\n+\tif (lws_flags \u0026 LCCSCF_ALLOW_REUSE_ADDR) {\n+\t\tif (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR,\n+\t\t\t\t\t(const void *)\u0026optval, optlen) \u003c 0) { \n+#if !defined(LWS_WITH_NO_LOGS)\n+\t\t\ten \u003d errno;\n+\t\t\tlwsl_warn(\u0022%s: unable to reuse local addresses: errno %d\u005cn\u0022,\n+\t\t\t\t__func__, en);\n+#endif\n+\t\t\tret \u003d 1;\n+\t\t} else\n+\t\t\tlwsl_notice(\u0022%s: set reuse addresses\u005cn\u0022, __func__);\n+\n+\t} else {\n+\t\tif (setsockopt(fd, SOL_SOCKET, SO_EXCLUSIVEADDRUSE,\n+\t\t\t\t (const void *)\u0026optval, optlen) \u003c 0) {\n+#if !defined(LWS_WITH_NO_LOGS)\n+\t\t\ten \u003d errno;\n+\t\t\tlwsl_warn(\u0022%s: unable to use exclusive addresses: errno %d\u005cn\u0022,\n+\t\t\t\t__func__, en);\n+#endif\n+\t\t\tret \u003d 1;\n+\t\t} else\n+\t\t\tlwsl_notice(\u0022%s: set use exclusive addresses\u005cn\u0022, __func__);\n+\t}\n+\t\n+\n+\treturn ret;\n }\n \n int\n","s":{"c":1746901450,"u": 5879}}
],"g": 974,"chitpc": 0,"ehitpc": 0,"indexed":0
,
"ab": 0, "si": 0, "db":0, "di":0, "sat":0, "lfc": "7d0a"}