mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
smp: give PROTOCOL_INIT a privake fakewsi
At init-time, PROTOCOL_INIT needs to be sent to each vhost-protocol combination to give them a chance to instantiate themselves. PROTOCOL_INIT can be deferred a bit, and since its subject is per vhost, which has no tsi affinity, in SMP case, its current use of context->pt[0] fakewsi can clash with other stuff happening simultaneously, eg, CANCEL_SERVICE broadcast, which happens on each pt. Solve this by changing PROTOCOL_INIT to use an on-stack fakewsi that cannot clash with any other service loop use of them. Take care about using a full fake wsi or an lws_a fakewsi if PLAT_FREERTOS.
This commit is contained in:
parent
e76ee9cb91
commit
7b315e394f
1 changed files with 13 additions and 8 deletions
|
@ -368,17 +368,25 @@ int
|
|||
lws_protocol_init_vhost(struct lws_vhost *vh, int *any)
|
||||
{
|
||||
const struct lws_protocol_vhost_options *pvo, *pvo1;
|
||||
lws_fakewsi_def_plwsa(&vh->context->pt[0]);
|
||||
int n;
|
||||
#if defined(LWS_PLAT_FREERTOS)
|
||||
struct lws_a _lwsa, *lwsa = &_lwsa;
|
||||
|
||||
lws_fakewsi_prep_plwsa_ctx(vh->context);
|
||||
memset(&_lwsa, 0, sizeof(_lwsa));
|
||||
#else
|
||||
struct lws _lws;
|
||||
struct lws_a *lwsa = &_lws.a;
|
||||
|
||||
plwsa->vhost = vh;
|
||||
memset(&_lws, 0, sizeof(_lws));
|
||||
#endif
|
||||
|
||||
lwsa->context = vh->context;
|
||||
lwsa->vhost = vh;
|
||||
|
||||
/* initialize supported protocols on this vhost */
|
||||
|
||||
for (n = 0; n < vh->count_protocols; n++) {
|
||||
plwsa->protocol = &vh->protocols[n];
|
||||
lwsa->protocol = &vh->protocols[n];
|
||||
if (!vh->protocols[n].name)
|
||||
continue;
|
||||
pvo = lws_vhost_protocol_options(vh, vh->protocols[n].name);
|
||||
|
@ -424,9 +432,6 @@ lws_protocol_init_vhost(struct lws_vhost *vh, int *any)
|
|||
*any |= !!vh->tls.ssl_ctx;
|
||||
#endif
|
||||
|
||||
plwsa->vhost = vh;
|
||||
plwsa->protocol = &vh->protocols[n];
|
||||
|
||||
pvo = lws_vhost_protocol_options(vh, vh->protocols[n].name);
|
||||
|
||||
/*
|
||||
|
@ -440,7 +445,7 @@ lws_protocol_init_vhost(struct lws_vhost *vh, int *any)
|
|||
if (pvo || !vh->pvo) {
|
||||
lwsl_info("%s: init %s.%s\n", __func__, vh->name,
|
||||
vh->protocols[n].name);
|
||||
if (vh->protocols[n].callback((struct lws *)plwsa,
|
||||
if (vh->protocols[n].callback((struct lws *)lwsa,
|
||||
LWS_CALLBACK_PROTOCOL_INIT, NULL,
|
||||
(void *)(pvo ? pvo->options : NULL), 0)) {
|
||||
if (vh->protocol_vh_privs && vh->protocol_vh_privs[n]) {
|
||||
|
|
Loading…
Add table
Reference in a new issue