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

adopt: improve wsi tags for listen

async-dns has to keep a listener on udp:53, but its tag doesn't really give
a clue what it is

[1534033|wsisrv|0|adopted]

this patch improves it and moves the decision about putting the server wsi
in SERVER or MUX group to the caller instead of guessing from the desc
name.

[1549684|wsisrv|0|system|asyncdns]
This commit is contained in:
Andy Green 2021-10-29 15:03:33 +01:00
parent 310e576cdc
commit 0993543ac8
4 changed files with 11 additions and 10 deletions

View file

@ -45,7 +45,8 @@ lws_get_idlest_tsi(struct lws_context *context)
}
struct lws *
lws_create_new_server_wsi(struct lws_vhost *vhost, int fixed_tsi, const char *desc)
lws_create_new_server_wsi(struct lws_vhost *vhost, int fixed_tsi, int group,
const char *desc)
{
struct lws *new_wsi;
int n = fixed_tsi;
@ -69,11 +70,8 @@ lws_create_new_server_wsi(struct lws_vhost *vhost, int fixed_tsi, const char *de
lws_wsi_fault_timedclose(new_wsi);
__lws_lc_tag(vhost->context, &vhost->context->lcg[
#if defined(LWS_ROLE_H2) || defined(LWS_ROLE_MQTT)
strcmp(desc, "adopted") ? LWSLCG_WSI_MUX :
#endif
LWSLCG_WSI_SERVER], &new_wsi->lc, desc);
__lws_lc_tag(vhost->context, &vhost->context->lcg[group],
&new_wsi->lc, "%s|%s", vhost->name, desc);
new_wsi->wsistate |= LWSIFR_SERVER;
new_wsi->tsi = (char)n;
@ -138,7 +136,7 @@ __lws_adopt_descriptor_vhost1(struct lws_vhost *vh, lws_adoption_type type,
n = -1;
if (parent)
n = parent->tsi;
new_wsi = lws_create_new_server_wsi(vh, n, "adopted");
new_wsi = lws_create_new_server_wsi(vh, n, LWSLCG_WSI_SERVER, fi_wsi_name);
if (!new_wsi)
return NULL;

View file

@ -1214,7 +1214,8 @@ lws_client_reset(struct lws **wsi, int ssl, const char *address, int port,
const char *path, const char *host, char weak);
struct lws * LWS_WARN_UNUSED_RESULT
lws_create_new_server_wsi(struct lws_vhost *vhost, int fixed_tsi, const char *desc);
lws_create_new_server_wsi(struct lws_vhost *vhost, int fixed_tsi,
int group, const char *desc);
char * LWS_WARN_UNUSED_RESULT
lws_generate_client_handshake(struct lws *wsi, char *pkt);

View file

@ -260,7 +260,7 @@ __lws_wsi_server_new(struct lws_vhost *vh, struct lws *parent_wsi,
} while (b < 3 && n < sizeof(tmp1) - 2);
tmp1[n] = '\0';
lws_snprintf(tmp, sizeof(tmp), "h2_sid%u_(%s)", sid, tmp1);
wsi = lws_create_new_server_wsi(vh, parent_wsi->tsi, tmp);
wsi = lws_create_new_server_wsi(vh, parent_wsi->tsi, LWSLCG_WSI_MUX, tmp);
if (!wsi) {
lwsl_notice("new server wsi failed (%s)\n", lws_vh_tag(vh));
return NULL;

View file

@ -1241,7 +1241,9 @@ cmd_completion:
lws_set_timeout(wsi, 0, 0);
w = lws_create_new_server_wsi(wsi->a.vhost,
wsi->tsi, "mqtt_sid1");
wsi->tsi,
LWSLCG_WSI_MUX,
"mqtt_sid1");
if (!w) {
lwsl_notice("%s: sid 1 migrate failed\n",
__func__);