aboutsummaryrefslogtreecommitdiff
path: root/lib/roles
diff options
context:
space:
mode:
authorAndy Green <andy@warmcat.com>2021-06-21 08:50:13 +0100
committerAndy Green <andy@warmcat.com>2021-06-22 15:55:47 +0100
commit6163c967273fad05bf544e455bc185562eb6facc (patch)
treeb99a8c4a0061949aac58d4d2da490e5c9b94d6d7 /lib/roles
parent8c122cd8bd5123e7def1e2602f1031fa93fc2c16 (diff)
downloadlibwebsockets-6163c967273fad05bf544e455bc185562eb6facc.tar.gz
vhost: allow multiple listen sockets
Some platforms need two sockets with AF_INET and AF_INET6 to listen to both protocols. This patch changes the single listen socket each vhost could previously handle to become an lws_dll2 and adapts the related code to handle them as a linked-list rather than as a singleton. The next patch adapts the listen / server code to create multiple listen wsi for vhosts listening on multiple ip protocols.
Diffstat (limited to 'lib/roles')
-rw-r--r--lib/roles/http/server/server.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/lib/roles/http/server/server.c b/lib/roles/http/server/server.c
index 265187ee..9ddb108c 100644
--- a/lib/roles/http/server/server.c
+++ b/lib/roles/http/server/server.c
@@ -80,18 +80,15 @@ _lws_vhost_init_server(const struct lws_context_creation_info *info,
vhost->listen_port == CONTEXT_PORT_NO_LISTEN_SERVER)
return 0;
+
+
vh = vhost->context->vhost_list;
while (vh) {
- if (vh->listen_port == vhost->listen_port) {
- if (((!vhost->iface && !vh->iface) ||
- (vhost->iface && vh->iface &&
- !strcmp(vhost->iface, vh->iface))) &&
- vh->lserv_wsi
- ) {
- lwsl_notice(" using listen skt from vhost %s\n",
- vh->name);
- return 0;
- }
+ if (vh->listen_wsi.count &&
+ lws_vhost_compare_listen(vhost, vh)) {
+ lwsl_notice(" using listen skt from vhost %s\n",
+ vh->name);
+ return 0;
}
vh = vh->vhost_next;
}
@@ -346,7 +343,7 @@ done_list:
goto bail;
}
- vhost->lserv_wsi = wsi;
+ lws_dll2_add_tail(&wsi->listen_list, &vhost->listen_wsi);
lws_pt_unlock(pt);
#if defined(WIN32) && defined(TCP_FASTOPEN)
@@ -375,7 +372,7 @@ done_list:
n = listen(wsi->desc.sockfd, LWS_SOMAXCONN);
if (n < 0) {
lwsl_err("listen failed with error %d\n", LWS_ERRNO);
- vhost->lserv_wsi = NULL;
+ lws_dll2_remove(&wsi->listen_list);
__remove_wsi_socket_from_fds(wsi);
goto bail;
}