[ 
https://issues.apache.org/jira/browse/DISPATCH-2103?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17446845#comment-17446845
 ] 

ASF GitHub Bot commented on DISPATCH-2103:
------------------------------------------

jiridanek commented on a change in pull request #1425:
URL: https://github.com/apache/qpid-dispatch/pull/1425#discussion_r753696907



##########
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:
       The vhost is started successfully at this point, so there had to be an 
actual port number assigned to it at some point. I'm adding the assert.




-- 
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-unsubscr...@qpid.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Log the actual HTTP websocket listener port when 0 was specified in config
> --------------------------------------------------------------------------
>
>                 Key: DISPATCH-2103
>                 URL: https://issues.apache.org/jira/browse/DISPATCH-2103
>             Project: Qpid Dispatch
>          Issue Type: New Feature
>    Affects Versions: 1.15.0
>            Reporter: Jiri Daněk
>            Assignee: Jiri Daněk
>            Priority: Major
>             Fix For: 1.19.0
>
>
> {code}
>     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 {
>         qd_log(hs->log, QD_LOG_NOTICE, "Error listening for HTTP on %s", 
> config->host_port);
>         goto error;
>     }
>     return;
> {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@qpid.apache.org
For additional commands, e-mail: dev-h...@qpid.apache.org

Reply via email to