1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-30 00:00:16 +01:00

async_dns: protocols init: make sure we add vhost once

This commit is contained in:
Andy Green 2022-04-12 14:55:06 +01:00
parent a04aaad7f0
commit 06229deb8c

View file

@ -818,9 +818,20 @@ lws_create_vhost(struct lws_context *context,
*/
#if defined(LWS_WITH_SYS_ASYNC_DNS)
if (!context->vhost_list) {
memcpy(&lwsp[m++], &lws_async_dns_protocol,
sizeof(struct lws_protocols));
vh->count_protocols++;
uint8_t seen = 0;
for (n = 0; n < m; n++)
if (!memcmp(&lwsp[n], &lws_async_dns_protocol, sizeof(struct lws_protocols))) {
/* Already defined */
seen = 1;
break;
}
if (!seen) {
memcpy(&lwsp[m++], &lws_async_dns_protocol,
sizeof(struct lws_protocols));
vh->count_protocols++;
}
}
#endif