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

protocol init: allow use of client apis during per-vhost protocol init

This commit is contained in:
Andy Green 2017-10-21 09:06:13 +08:00
parent 28d820ba0a
commit af8f2d3616
2 changed files with 13 additions and 1 deletions

View file

@ -197,6 +197,11 @@ lws_protocol_init(struct lws_context *context)
struct lws wsi;
int n;
if (context->doing_protocol_init)
return 0;
context->doing_protocol_init = 1;
memset(&wsi, 0, sizeof(wsi));
wsi.context = context;
@ -261,8 +266,12 @@ lws_protocol_init(struct lws_context *context)
*/
if (vh->protocols[n].callback(&wsi,
LWS_CALLBACK_PROTOCOL_INIT, NULL,
(void *)pvo, 0))
(void *)pvo, 0)) {
lwsl_err("%s: vhost %s failed init\n", __func__,
vh->protocols[n].name);
context->doing_protocol_init = 0;
return 1;
}
}
vh->created_vhost_protocols = 1;
@ -270,6 +279,8 @@ next:
vh = vh->vhost_next;
}
context->doing_protocol_init = 0;
if (!context->protocol_init_done)
lws_finalize_startup(context);

View file

@ -1116,6 +1116,7 @@ struct lws_context {
unsigned int requested_kill:1;
unsigned int protocol_init_done:1;
unsigned int ssl_gate_accepts:1;
unsigned int doing_protocol_init;
/*
* set to the Thread ID that's doing the service loop just before entry
* to poll indicates service thread likely idling in poll()