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

minimal-http-server-multivhost: add --die-after-vhost option

This commit is contained in:
Andy Green 2018-06-20 16:22:58 +08:00
parent ac3bd36c60
commit 410db9a28e
2 changed files with 17 additions and 0 deletions

View file

@ -30,6 +30,11 @@ for the connection, and you will be served content from ./mount-origin-localhost
## usage
Commandline option|Meaning
---|---
-d <loglevel>|Debug verbosity in decimal, eg, -d15
--die-after-vhost | For testing failure handling
```
$ ./lws-minimal-http-server-multivhost
[2018/03/16 09:37:20:0866] USER: LWS minimal http server-multivhost | visit http://localhost:7681 / 7682

View file

@ -80,6 +80,11 @@ void sigint_handler(int sig)
interrupted = 1;
}
void vh_destruction_notification(struct lws_vhost *vh, void *arg)
{
lwsl_user("%s: called, arg: %p\n", __func__, arg);
}
int main(int argc, const char **argv)
{
struct lws_context_creation_info info;
@ -150,12 +155,19 @@ int main(int argc, const char **argv)
info.mounts = &mount_localhost3;
info.error_document_404 = "/404.html";
info.vhost_name = "localhost3";
info.finalize = vh_destruction_notification;
info.finalize_arg = NULL;
if (!lws_create_vhost(context, &info)) {
lwsl_err("Failed to create third vhost\n");
goto bail;
}
if (lws_cmdline_option(argc, argv, "--die-after-vhost")) {
lwsl_warn("bailing after creating vhosts\n");
goto bail;
}
while (n >= 0 && !interrupted)
n = lws_service(context, 1000);