You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by GitBox <gi...@apache.org> on 2021/11/19 17:16:48 UTC
[GitHub] [qpid-dispatch] kgiusti commented on a change in pull request #1425: DISPATCH-2103 Log actual HTTP listener port number when 0 is configured
kgiusti commented on a change in pull request #1425:
URL: https://github.com/apache/qpid-dispatch/pull/1425#discussion_r753373851
##########
File path: src/http-libwebsockets.c
##########
@@ -374,25 +380,38 @@ static void listener_start(qd_lws_listener_t *hl, qd_http_server_t *hs) {
info.options |=
LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT |
-#if LWS_LIBRARY_VERSION_MAJOR > 3 || (LWS_LIBRARY_VERSION_MAJOR == 3 && LWS_LIBRARY_VERSION_MINOR >= 2)
+#ifdef QD_HAVE_MODERN_LIBWEBSOCKETS
(config->ssl_required ? 0 : LWS_SERVER_OPTION_ALLOW_NON_SSL_ON_SSL_PORT | LWS_SERVER_OPTION_ALLOW_HTTP_ON_HTTPS_LISTENER) |
#else
(config->ssl_required ? 0 : LWS_SERVER_OPTION_ALLOW_NON_SSL_ON_SSL_PORT) |
#endif
((config->requireAuthentication && info.ssl_ca_filepath) ? LWS_SERVER_OPTION_REQUIRE_VALID_OPENSSL_CLIENT_CERT : 0);
}
info.vhost_name = hl->listener->config.host_port;
+#ifdef QD_HAVE_MODERN_LIBWEBSOCKETS
+ info.finalize = finalize_http;
+ info.finalize_arg = hl;
+#endif
hl->vhost = lws_create_vhost(hs->context, &info);
- if (hl->vhost) {
- /* Store hl pointer in vhost */
- void *vp = lws_protocol_vh_priv_zalloc(hl->vhost, &protocols[0], sizeof(hl));
- memcpy(vp, &hl, sizeof(hl));
- qd_log(hs->log, QD_LOG_NOTICE, "Listening for HTTP on %s", config->host_port);
- return;
- } else {
+ if (!hl->vhost) {
qd_log(hs->log, QD_LOG_NOTICE, "Error listening for HTTP on %s", config->host_port);
goto error;
}
+
+ /* Store hl pointer in vhost */
+ void *vp = lws_protocol_vh_priv_zalloc(hl->vhost, &protocols[0], sizeof(hl));
+ memcpy(vp, &hl, sizeof(hl));
+
+ if (port == 0) {
+ // If a 0 (zero) is specified for a port, get the actual listening port from the listener.
+ const int resolved_port = lws_get_vhost_port(hl->vhost);
Review comment:
Any chance this can fail? Docs say lws_get_vhost_port() can return -1 on error. If we don't expect it to return -1 add an assert(resolved_port != -1) in case we break the code at some point.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
For additional commands, e-mail: dev-help@qpid.apache.org