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

active_conns: simplify h1 exclusion rule

This commit is contained in:
Andy Green 2021-03-25 13:28:02 +00:00
parent 5cdc9c114d
commit f72acc9e07

View file

@ -1608,10 +1608,15 @@ lws_vhost_active_conns(struct lws *wsi, struct lws **nwsi, const char *adsin)
const char *my_alpn = lws_wsi_client_stash_item(wsi, CIS_ALPN, const char *my_alpn = lws_wsi_client_stash_item(wsi, CIS_ALPN,
_WSI_TOKEN_CLIENT_ALPN); _WSI_TOKEN_CLIENT_ALPN);
#endif #endif
char newconn_cannot_use_h1 = 0;
#if defined(LWS_WITH_TLS) #if defined(LWS_WITH_TLS)
char newconn_cannot_use_h1 = 0;
if ((wsi->tls.use_ssl & LCCSCF_USE_SSL) && if ((wsi->tls.use_ssl & LCCSCF_USE_SSL) &&
(my_alpn && !strstr(my_alpn, "http/1.1"))) my_alpn && !strstr(my_alpn, "http/1.1"))
/*
* new guy wants to use tls, he specifies the alpn and he does
* not list h1 as a choice ==> he can't bind to existing h1
*/
newconn_cannot_use_h1 = 1; newconn_cannot_use_h1 = 1;
#endif #endif
@ -1657,15 +1662,18 @@ lws_vhost_active_conns(struct lws *wsi, struct lws **nwsi, const char *adsin)
*/ */
(w->role_ops == wsi->role_ops || (w->role_ops == wsi->role_ops ||
(lwsi_role_http(w) && lwsi_role_http(wsi))) && (lwsi_role_http(w) && lwsi_role_http(wsi))) &&
w->cli_hostname_copy && /* ... same role, or at least both some kind of http */
!(newconn_cannot_use_h1 && w->role_ops != &role_ops_h1) && w->cli_hostname_copy && !strcmp(adsin, w->cli_hostname_copy) &&
!strcmp(adsin, w->cli_hostname_copy) && /* same endpoint hostname */
#if defined(LWS_WITH_TLS) #if defined(LWS_WITH_TLS)
(!(wsi->tls.use_ssl & LCCSCF_USE_SSL) || !my_alpn || (my_alpn && strstr(my_alpn, "http/1.1"))) && !(newconn_cannot_use_h1 && w->role_ops == &role_ops_h1) &&
/* if we can't use h1, old guy must not be h1 */
(wsi->tls.use_ssl & LCCSCF_USE_SSL) == (wsi->tls.use_ssl & LCCSCF_USE_SSL) ==
(w->tls.use_ssl & LCCSCF_USE_SSL) && (w->tls.use_ssl & LCCSCF_USE_SSL) &&
/* must both agree on tls use or not */
#endif #endif
wsi->c_port == w->c_port) { wsi->c_port == w->c_port) {
/* same endpoint port */
/* /*
* There's already an active connection. * There's already an active connection.