qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tr...@apache.org
Subject qpid-dispatch git commit: Revert "DISPATCH-103: Refactor to use LWS context per listener."
Date Thu, 08 Dec 2016 01:18:47 GMT
Repository: qpid-dispatch
Updated Branches:
  refs/heads/master cc4c82502 -> b794973eb


Revert "DISPATCH-103: Refactor to use LWS context per listener."

This reverts commit cc4c82502025de74e8e703fb614d2195babf8a47.


Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/b794973e
Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/b794973e
Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/b794973e

Branch: refs/heads/master
Commit: b794973ebcf145a9a8a1f314ed66c019d19e98f4
Parents: cc4c825
Author: Ted Ross <tross@redhat.com>
Authored: Wed Dec 7 20:12:55 2016 -0500
Committer: Ted Ross <tross@redhat.com>
Committed: Wed Dec 7 20:12:55 2016 -0500

----------------------------------------------------------------------
 include/qpid/dispatch/driver.h |  12 ++-
 src/http-libwebsockets.c       | 168 +++++++++++++++++-------------------
 src/http.h                     |  16 ++--
 src/posix/driver.c             |  16 ++--
 src/server.c                   |  19 ++--
 src/server_private.h           |   1 +
 6 files changed, 117 insertions(+), 115 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/b794973e/include/qpid/dispatch/driver.h
----------------------------------------------------------------------
diff --git a/include/qpid/dispatch/driver.h b/include/qpid/dispatch/driver.h
index a0d4478..f08d54a 100644
--- a/include/qpid/dispatch/driver.h
+++ b/include/qpid/dispatch/driver.h
@@ -31,7 +31,8 @@
 #include <proton/transport.h>
 #include <proton/types.h>
 
-struct qd_http_listener_t;
+struct qd_http_t;
+struct qd_http_connector_t;
 
 /** @file
  * API for the Driver Layer.
@@ -149,10 +150,10 @@ qdpn_listener_t *qdpn_listener(qdpn_driver_t *driver,
                                const char *host,
                                const char *port,
                                const char *protocol_family,
-                               struct qd_http_listener_t *http,
+                               struct qd_http_t  *http,
                                void* context);
 
-struct qd_http_listener_t *qdpn_listener_http(qdpn_listener_t *l);
+struct qd_http_t *qdpn_listener_http(qdpn_listener_t *l);
 
 /** Access the head listener for a driver.
  *
@@ -407,7 +408,7 @@ bool qdpn_connector_activated(qdpn_connector_t *connector, qdpn_activate_criteri
  * @return a new listener on the given host:port, NULL if error
  */
 qdpn_listener_t *qdpn_listener_fd(qdpn_driver_t *driver, pn_socket_t fd,
-                                  struct qd_http_listener_t *http, void *context);
+                                  struct qd_http_t *http, void *context);
 
 pn_socket_t qdpn_listener_get_fd(qdpn_listener_t *listener);
 
@@ -424,6 +425,9 @@ qdpn_connector_t *qdpn_connector_fd(qdpn_driver_t *driver, pn_socket_t
fd, void
 /** Get the file descriptor for this connector */
 int qdpn_connector_get_fd(qdpn_connector_t *connector);
 
+/** Get the HTTP per-connector state for this connector, NULL if not enabled. */
+struct qd_http_connector_t *qdpn_connector_http(qdpn_connector_t* c);
+
 /** Set the wakeup time on the connector */
 void qdpn_connector_wakeup(qdpn_connector_t* c, pn_timestamp_t t);
 

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/b794973e/src/http-libwebsockets.c
----------------------------------------------------------------------
diff --git a/src/http-libwebsockets.c b/src/http-libwebsockets.c
index b3fb9f5..c456b07 100644
--- a/src/http-libwebsockets.c
+++ b/src/http-libwebsockets.c
@@ -20,6 +20,7 @@
 #include <qpid/dispatch/atomic.h>
 #include <qpid/dispatch/amqp.h>
 #include <qpid/dispatch/driver.h>
+#include <qpid/dispatch/log.h>
 #include <qpid/dispatch/threading.h>
 #include <qpid/dispatch/timer.h>
 
@@ -31,60 +32,49 @@
 #include "http.h"
 #include "config.h"
 
-typedef struct fd_data_t {
-    qdpn_connector_t *connector;
-    struct lws *wsi;
-} fd_data_t;
-
-struct qd_http_listener_t {
+/* Shared context for all HTTP connections.  */
+struct qd_http_t {
     sys_mutex_t *lock;
     qd_dispatch_t *dispatch;
+    qd_log_source_t *log;
     struct lws_context *context;
     qd_timer_t *timer;
-    fd_data_t *fd;             /* indexed by file descriptor */
-    size_t fd_len;
+    qdpn_connector_t **connectors; /* Indexed by file descriptor */
+    size_t connectors_len;
 };
 
-static inline fd_data_t *fd_data(qd_http_listener_t *hl, int fd) {
-    fd_data_t *d = (fd < hl->fd_len) ? &hl->fd[fd] : NULL;
-    return (d && d->connector && d->wsi) ? d : NULL;
-}
-
-static inline qdpn_connector_t *fd_connector(qd_http_listener_t *hl, int fd) {
-    fd_data_t *d = fd_data(hl, fd);
-    return d ? d->connector : NULL;
+static inline qdpn_connector_t *fd_connector(qd_http_t *h, int fd) {
+    return (fd < h->connectors_len) ? h->connectors[fd] : NULL;
 }
 
-static inline qd_http_listener_t *wsi_http_listener(struct lws *wsi) {
-    return (qd_http_listener_t*)lws_context_user(lws_get_context(wsi));
+static inline qd_http_t *wsi_http(struct lws *wsi) {
+    return (qd_http_t *)lws_context_user(lws_get_context(wsi));
 }
 
 static inline qdpn_connector_t *wsi_connector(struct lws *wsi) {
-    qd_http_listener_t *hl = wsi_http_listener(wsi);
-    return fd_connector(hl, lws_get_socket_fd(wsi));
+    return fd_connector(wsi_http(wsi), lws_get_socket_fd(wsi));
 }
 
-static inline fd_data_t *set_fd(qd_http_listener_t *hl, int fd, qdpn_connector_t *c, struct
lws *wsi) {
-    if (fd >= hl->fd_len) {
-        size_t len = hl->fd_len;
-        hl->fd_len = (fd+1)*2;
-        hl->fd = realloc(hl->fd, hl->fd_len*sizeof(*hl->fd));
-        if (!hl->fd) return NULL;
-        memset(hl->fd + len, 0, sizeof(*hl->fd)*(hl->fd_len - len));
+static inline int set_fd(qd_http_t *h, int fd, qdpn_connector_t *c) {
+    if (fd >= h->connectors_len) {
+        size_t len = h->connectors_len;
+        h->connectors_len = (fd+1)*2;
+        h->connectors = realloc(h->connectors, h->connectors_len*sizeof(qdpn_connector_t*));
+        if (!h->connectors) return -1;
+        memset(h->connectors + len, 0, h->connectors_len - len);
     }
-    fd_data_t *d = &hl->fd[fd];
-    d->connector = c;
-    d->wsi = wsi;
-    return d;
+    h->connectors[fd] = c;
+    return 0;
 }
 
 /* Mark the qd connector closed, but leave the FD for LWS to clean up */
 int mark_closed(struct lws *wsi) {
-    qd_http_listener_t *hl = wsi_http_listener(wsi);
-    fd_data_t *d = fd_data(hl, lws_get_socket_fd(wsi));
-    if (d) {
-        qdpn_connector_mark_closed(d->connector);
-        memset(d, 0, sizeof(*d));
+    qd_http_t *h = wsi_http(wsi);
+    int fd = lws_get_socket_fd(wsi);
+    qdpn_connector_t *c = fd_connector(h, fd);
+    if (c) {
+        qdpn_connector_mark_closed(c);
+        return set_fd(h, fd, NULL);
     }
     return 0;
 }
@@ -107,12 +97,12 @@ static int transport_push(pn_transport_t *t, pn_bytes_t buf) {
     return buf.size;
 }
 
-static inline int normal_close(struct lws *wsi, const char *msg) {
+static int normal_close(struct lws *wsi, qdpn_connector_t *c, const char *msg) {
     lws_close_reason(wsi, LWS_CLOSE_STATUS_NORMAL, (unsigned char*)msg, strlen(msg));
     return -1;
 }
 
-static inline int unexpected_close(struct lws *wsi, const char *msg) {
+static int unexpected_close(struct lws *wsi, qdpn_connector_t *c, const char *msg) {
     lws_close_reason(wsi, LWS_CLOSE_STATUS_UNEXPECTED_CONDITION, (unsigned char*)msg, strlen(msg));
     return -1;
 }
@@ -171,20 +161,23 @@ typedef struct buffer_t { void *start; size_t size; size_t cap; } buffer_t;
 static int callback_amqpws(struct lws *wsi, enum lws_callback_reasons reason,
                            void *user, void *in, size_t len)
 {
+    qd_http_t *h = wsi_http(wsi);
     qdpn_connector_t *c = wsi_connector(wsi);
     pn_transport_t *t = c ? qdpn_connector_transport(c) : NULL;
+    const char *name = c ? qdpn_connector_name(c) : "<unknown>";
 
     switch (reason) {
 
     case LWS_CALLBACK_ESTABLISHED: {
         memset(user, 0, sizeof(buffer_t));
+        qd_log(h->log, QD_LOG_TRACE, "HTTP from %s upgraded to AMQP/WebSocket", name);
         break;
     }
 
     case LWS_CALLBACK_SERVER_WRITEABLE: {
         ssize_t size;
         if (!t || (size = pn_transport_pending(t)) < 0) {
-            return normal_close(wsi, "write-closed");
+            return normal_close(wsi, c, "write-closed");
         }
         if (size > 0) {
             const void *start = pn_transport_head(t);
@@ -196,14 +189,14 @@ static int callback_amqpws(struct lws *wsi, enum lws_callback_reasons
reason,
                 wtmp->size = wtmp->cap = tmpsize;
             }
             if (wtmp->start == NULL) {
-                return unexpected_close(wsi, "out-of-memory");
+                return unexpected_close(wsi, c, "out-of-memory");
             }
             void *tmpstart = wtmp->start + LWS_PRE;
             memcpy(tmpstart, start, size);
             ssize_t wrote = lws_write(wsi, tmpstart, size, LWS_WRITE_BINARY);
             if (wrote < 0) {
                 pn_transport_close_head(t);
-                return normal_close(wsi, "write-error");
+                return normal_close(wsi, c, "write-error");
             } else {
                 pn_transport_pop(t, (size_t)wrote);
             }
@@ -213,10 +206,10 @@ static int callback_amqpws(struct lws *wsi, enum lws_callback_reasons
reason,
 
     case LWS_CALLBACK_RECEIVE: {
         if (!t || pn_transport_capacity(t) < 0) {
-            return normal_close(wsi, "read-closed");
+            return normal_close(wsi, c, "read-closed");
         }
         if (transport_push(t, pn_bytes(len, in))) {
-            return unexpected_close(wsi, "read-overflow");
+            return unexpected_close(wsi, c, "read-overflow");
         }
         break;
     }
@@ -257,64 +250,59 @@ static const struct lws_http_mount console_mount = {
     1,                  /* strlen("/"), ie length of the mountpoint */
 };
 
-static void check_timer(void *void_http_listener) {
-    qd_http_listener_t *hl = (qd_http_listener_t*)void_http_listener;
-    sys_mutex_lock(hl->lock);
+static void check_timer(void *void_http) {
+    qd_http_t *h = (qd_http_t*)void_http;
+    sys_mutex_lock(h->lock);
     /* Run LWS global timer and forced-service checks. */
-    lws_service_fd(hl->context, NULL);
-    while (!lws_service_adjust_timeout(hl->context, 1, 0)) {
+    lws_service_fd(h->context, NULL);
+    while (!lws_service_adjust_timeout(h->context, 1, 0)) {
         /* -1 timeout means just do forced service */
-        lws_plat_service_tsi(hl->context, -1, 0);
+        lws_plat_service_tsi(h->context, -1, 0);
     }
-    if (!hl->timer) {
-        hl->timer = qd_timer(hl->dispatch, check_timer, hl);
+    if (!h->timer) {
+        h->timer = qd_timer(h->dispatch, check_timer, h);
     }
-    qd_timer_cancel(hl->timer);
-    qd_timer_schedule(hl->timer, 1000); /* LWS wants per-second wakeups */
-    sys_mutex_unlock(hl->lock);
+    qd_timer_cancel(h->timer);
+    qd_timer_schedule(h->timer, 1000); /* LWS wants per-second wakeups */
+    sys_mutex_unlock(h->lock);
 }
 
 void qd_http_connector_process(qdpn_connector_t *c) {
-    qd_http_listener_t * hl = qdpn_listener_http(qdpn_connector_listener(c));
-    sys_mutex_lock(hl->lock);
+    qd_http_t * h = qdpn_listener_http(qdpn_connector_listener(c));
+    sys_mutex_lock(h->lock);
     int fd = qdpn_connector_get_fd(c);
-    fd_data_t *d = fd_data(hl, fd);
+    struct lws *wsi = (struct lws*)qdpn_connector_http(c);
     /* Make sure we are still tracking this fd, could have been closed by timer */
-    if (d) {
+    if (wsi) {
         pn_transport_t *t = qdpn_connector_transport(c);
         int flags =
             (qdpn_connector_activated(c, QDPN_CONNECTOR_READABLE) ? POLLIN : 0) |
             (qdpn_connector_activated(c, QDPN_CONNECTOR_WRITABLE) ? POLLOUT : 0);
         struct lws_pollfd pfd = { fd, flags, flags };
         if (pn_transport_pending(t) > 0) {
-            lws_callback_on_writable(d->wsi);
+            lws_callback_on_writable(wsi);
         }
-        lws_service_fd(hl->context, &pfd);
-        d = fd_data(hl, fd);    /* We may have stopped tracking during service */
+        lws_service_fd(h->context, &pfd);
         if (pn_transport_closed(t)) {
-            if (d) mark_closed(d->wsi);   /* Don't let the server close the FD. */
+            mark_closed(wsi);   /* Don't let the server close the FD. */
         } else {
             if (pn_transport_capacity(t) > 0)
                 qdpn_connector_activate(c, QDPN_CONNECTOR_READABLE);
-            if (pn_transport_pending(t) > 0 || (d && lws_partial_buffered(d->wsi)))
+            if (pn_transport_pending(t) > 0 || lws_partial_buffered(wsi))
                 qdpn_connector_activate(c, QDPN_CONNECTOR_WRITABLE);
             qdpn_connector_wakeup(c, pn_transport_tick(t, qdpn_now(NULL)));
         }
     }
-    sys_mutex_unlock(hl->lock);
-    check_timer(hl);             /* Make sure the timer is running */
+    sys_mutex_unlock(h->lock);
+    check_timer(h);             /* Make sure the timer is running */
 }
 
-void qd_http_listener_accept(qd_http_listener_t *hl, qdpn_connector_t *c) {
-    struct lws* wsi = lws_adopt_socket(hl->context, qdpn_connector_get_fd(c));
-    if (!wsi || !set_fd(hl, qdpn_connector_get_fd(c), c, wsi)) {
-        pn_transport_t *t = qdpn_connector_transport(c);
-        pn_condition_t *cond = pn_transport_condition(t);
-        pn_condition_format(cond, "qpid-dispatch-router",
-                           "Cannot enable HTTP support for %s", qdpn_connector_name(c));
-        pn_transport_close_tail(t);
-        pn_transport_close_head(t);
+qd_http_connector_t *qd_http_connector(qd_http_t *h, qdpn_connector_t *c) {
+    if (set_fd(h, qdpn_connector_get_fd(c), c)) {
+        return NULL;
     }
+    struct lws* wsi = lws_adopt_socket(h->context, qdpn_connector_get_fd(c));
+    return (qd_http_connector_t*)wsi;
 }
 
 static struct lws_protocols protocols[] = {
@@ -340,31 +328,29 @@ static struct lws_protocols protocols[] = {
     },
 };
 
-/* FIXME aconway 2016-12-07: LWS context per listener, could reduce to per-ssl-profile */
-qd_http_listener_t *qd_http_listener(qd_dispatch_t *d, const qd_server_config_t *config)
{
-    qd_http_listener_t *hl = calloc(1, sizeof(*hl));
-    if (!hl) return NULL;
-    hl->lock = sys_mutex();
-    hl->dispatch = d;
+qd_http_t *qd_http(qd_dispatch_t *d, qd_log_source_t *log) {
+    qd_http_t *h = calloc(1, sizeof(qd_http_t));
+    if (!h) return NULL;
+    h->lock = sys_mutex();
+    h->dispatch = d;
+    h->log = log;
     lws_set_log_level(0, NULL);
 
     struct lws_context_creation_info info = {0};
     info.port = CONTEXT_PORT_NO_LISTEN;
     info.protocols = protocols;
     info.gid = info.uid = -1;
-    info.user = hl;
+    info.user = h;
     info.mounts = &console_mount; /* Serve the console files */
     info.server_string = QD_CONNECTION_PROPERTY_PRODUCT_VALUE;
-    hl->context = lws_create_context(&info);
-
-    /* FIXME aconway 2016-12-07: could use a single timer for all. */
-    hl->timer = NULL;            /* Can't init timer here, server not initialized. */
-    return hl;
+    h->context = lws_create_context(&info);
+    h->timer = NULL;            /* Can't init timer here, server not initialized. */
+    return h;
 }
 
-void qd_http_listener_free(qd_http_listener_t *hl) {
-    sys_mutex_free(hl->lock);
-    if (hl->timer) qd_timer_free(hl->timer);
-    lws_context_destroy(hl->context);
-    free(hl);
+void qd_http_free(qd_http_t *h) {
+    sys_mutex_free(h->lock);
+    if (h->timer) qd_timer_free(h->timer);
+    lws_context_destroy(h->context);
+    free(h);
 }

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/b794973e/src/http.h
----------------------------------------------------------------------
diff --git a/src/http.h b/src/http.h
index 7472497..bbfdc80 100644
--- a/src/http.h
+++ b/src/http.h
@@ -20,16 +20,14 @@
  * under the License.
  */
 
-typedef struct qd_http_listener_t qd_http_listener_t;
-struct qd_dispatch_t;
-struct qd_server_config_t;
-struct qdpn_connector_t;
+#include <qpid/dispatch/dispatch.h>
 
-qd_http_listener_t *qd_http_listener(struct qd_dispatch_t *d,
-                                     const struct qd_server_config_t *config);
-void qd_http_listener_free(qd_http_listener_t *hl);
-void qd_http_listener_accept(qd_http_listener_t *hl, struct qdpn_connector_t *c);
+typedef struct qd_http_t qd_http_t;
+typedef struct qd_http_connector_t qd_http_connector_t;
 
-void qd_http_connector_process(struct qdpn_connector_t *c);
+qd_http_t *qd_http(qd_dispatch_t *d, qd_log_source_t *log);
+void qd_http_free(qd_http_t *http);
+qd_http_connector_t *qd_http_connector(qd_http_t *h, qdpn_connector_t *c);
+void qd_http_connector_process(qdpn_connector_t *c);
 
 #endif // QD_HTTP_H

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/b794973e/src/posix/driver.c
----------------------------------------------------------------------
diff --git a/src/posix/driver.c b/src/posix/driver.c
index a625903..741f500 100644
--- a/src/posix/driver.c
+++ b/src/posix/driver.c
@@ -106,7 +106,7 @@ struct qdpn_listener_t {
     DEQ_LINKS(qdpn_listener_t);
     qdpn_driver_t *driver;
     void *context;
-    qd_http_listener_t *http;
+    qd_http_t *http;
     int idx;
     int fd;
     bool pending:1;
@@ -126,6 +126,7 @@ struct qdpn_connector_t {
     qdpn_listener_t *listener;
     void *context;
     void (*process)(qdpn_connector_t *c);
+    qd_http_connector_t *http;
     int idx;
     int fd;
     int status;
@@ -263,7 +264,7 @@ qdpn_listener_t *qdpn_listener(qdpn_driver_t *driver,
                                const char *host,
                                const char *port,
                                const char *protocol_family,
-                               qd_http_listener_t *http,
+                               qd_http_t *http,
                                void* context)
 {
     if (!driver) return NULL;
@@ -314,7 +315,7 @@ qdpn_listener_t *qdpn_listener(qdpn_driver_t *driver,
 }
 
 qdpn_listener_t *qdpn_listener_fd(qdpn_driver_t *driver, int fd,
-                                  qd_http_listener_t *http, void *context)
+                                  qd_http_t *http, void *context)
 {
     if (!driver) return NULL;
 
@@ -417,7 +418,7 @@ qdpn_connector_t *qdpn_listener_accept(qdpn_listener_t *l,
     snprintf(c->hostip, PN_NAME_MAX, "%s", hostip);
     c->listener = l;
     if (l->http) {
-        qd_http_listener_accept(l->http, c);
+        c->http = qd_http_connector(l->http, c);
         c->process = qd_http_connector_process;
     }
     return c;
@@ -436,7 +437,7 @@ void qdpn_listener_close(qdpn_listener_t *l)
 void qdpn_listener_free(qdpn_listener_t *l)
 {
     if (!l) return;
-    if (l->http) qd_http_listener_free(l->http);
+
     if (l->driver) qdpn_driver_remove_listener(l->driver, l);
     free_qdpn_listener_t(l);
 }
@@ -635,6 +636,7 @@ void qdpn_connector_mark_closed(qdpn_connector_t *ctor)
         qd_log(ctor->driver->log, QD_LOG_TRACE, "closed %s", ctor->name);
         ctor->closed = true;
         ctor->driver->closed_count++;
+        ctor->http = NULL;
     }
     sys_mutex_unlock(ctor->driver->lock);
 }
@@ -1040,8 +1042,10 @@ qdpn_connector_t *qdpn_driver_connector(qdpn_driver_t *d)
     return NULL;
 }
 
+qd_http_connector_t *qdpn_connector_http(qdpn_connector_t* c) { return c->http; }
+
 void qdpn_connector_wakeup(qdpn_connector_t* c, pn_timestamp_t t) {
     c->wakeup = t;
 }
 
-qd_http_listener_t *qdpn_listener_http(qdpn_listener_t* l) { return l->http; }
+qd_http_t *qdpn_listener_http(qdpn_listener_t* l) { return l->http; }

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/b794973e/src/server.c
----------------------------------------------------------------------
diff --git a/src/server.c b/src/server.c
index 1589196..1e813aa 100644
--- a/src/server.c
+++ b/src/server.c
@@ -573,9 +573,8 @@ static const char *log_incoming(char *buf, size_t size, qdpn_connector_t
*cxtr)
     const char *cname = qdpn_connector_name(cxtr);
     const char *host = qd_listener->config->host;
     const char *port = qd_listener->config->port;
-    const char *protocol = qd_listener->config->http ? "HTTP" : "AMQP";
     snprintf(buf, size, "incoming %s connection from %s to %s:%s",
-             protocol, cname, host, port);
+             qdpn_connector_http(cxtr) ? "HTTP" : "AMQP", cname, host, port);
     return buf;
 }
 
@@ -1396,6 +1395,8 @@ qd_server_t *qd_server(qd_dispatch_t *qd, int thread_count, const char
*containe
     qd_server->heartbeat_timer        = 0;
     qd_server->next_connection_id     = 1;
     qd_server->py_displayname_obj     = 0;
+    qd_server->http = qd_http(qd, qd_server->log_source);
+
     qd_log(qd_server->log_source, QD_LOG_INFO, "Container Name: %s", qd_server->container_name);
 
     return qd_server;
@@ -1405,6 +1406,7 @@ qd_server_t *qd_server(qd_dispatch_t *qd, int thread_count, const char
*containe
 void qd_server_free(qd_server_t *qd_server)
 {
     if (!qd_server) return;
+    qd_http_free(qd_server->http);
     for (int i = 0; i < qd_server->thread_count; i++)
         thread_free(qd_server->threads[i]);
     qd_timer_finalize();
@@ -1697,10 +1699,16 @@ qd_listener_t *qd_server_listen(qd_dispatch_t *qd, const qd_server_config_t
*con
     li->server      = qd_server;
     li->config      = config;
     li->context     = context;
-    /* FIXME aconway 2016-12-07: free after. */
-    qd_http_listener_t *hl = qd_http_listener(qd, config);
+    qd_http_t *http = NULL;
+    if (config->http) {
+        http = qd->server->http;
+        if (!http) {
+            qd_log(qd_server->log_source, QD_LOG_CRITICAL, "HTTP support not available
for %s:%s",
+                   config->host, config->port);
+        }
+    }
     li->pn_listener = qdpn_listener(
-        qd_server->driver, config->host, config->port, config->protocol_family,
hl, li);
+        qd_server->driver, config->host, config->port, config->protocol_family,
http, li);
 
     if (!li->pn_listener) {
         free_qd_listener_t(li);
@@ -1717,6 +1725,7 @@ void qd_server_listener_free(qd_listener_t* li)
 {
     if (!li)
         return;
+
     qdpn_listener_free(li->pn_listener);
     free_qd_listener_t(li);
 }

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/b794973e/src/server_private.h
----------------------------------------------------------------------
diff --git a/src/server_private.h b/src/server_private.h
index 8ce429f..8c4d89e 100644
--- a/src/server_private.h
+++ b/src/server_private.h
@@ -192,6 +192,7 @@ struct qd_server_t {
     qd_timer_t               *heartbeat_timer;
     uint64_t                 next_connection_id;
     void                     *py_displayname_obj;
+    qd_http_t                *http;
 };
 
 ALLOC_DECLARE(qd_work_item_t);


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message