diff --git a/minimal-examples/http-server/minimal-http-server-multivhost/README.md b/minimal-examples/http-server/minimal-http-server-multivhost/README.md index 421722084..26c99a18b 100644 --- a/minimal-examples/http-server/minimal-http-server-multivhost/README.md +++ b/minimal-examples/http-server/minimal-http-server-multivhost/README.md @@ -30,6 +30,11 @@ for the connection, and you will be served content from ./mount-origin-localhost ## usage +Commandline option|Meaning +---|--- +-d |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 diff --git a/minimal-examples/http-server/minimal-http-server-multivhost/minimal-http-server.c b/minimal-examples/http-server/minimal-http-server-multivhost/minimal-http-server.c index 57e07541b..966616fde 100644 --- a/minimal-examples/http-server/minimal-http-server-multivhost/minimal-http-server.c +++ b/minimal-examples/http-server/minimal-http-server-multivhost/minimal-http-server.c @@ -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);