qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tr...@apache.org
Subject [1/2] qpid-dispatch git commit: DISPATCH-278 - Removed a lot of no-longer-used code in connection_manager.[ch]. This fixes the problem in the Jira whereby the router crashes if a listener is deleted and one of its connections is still open (actually cra
Date Mon, 18 Apr 2016 18:11:25 GMT
Repository: qpid-dispatch
Updated Branches:
  refs/heads/master b175a1d27 -> fac17aa75


DISPATCH-278 - Removed a lot of no-longer-used code in connection_manager.[ch].  This
fixes the problem in the Jira whereby the router crashes if a listener is deleted and one
of its connections is still open (actually crashes when the connection is closed).


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

Branch: refs/heads/master
Commit: ea42febf6de19308d9d9486956f51899cf8b4e62
Parents: b175a1d
Author: Ted Ross <tross@redhat.com>
Authored: Mon Apr 18 14:07:35 2016 -0400
Committer: Ted Ross <tross@redhat.com>
Committed: Mon Apr 18 14:07:35 2016 -0400

----------------------------------------------------------------------
 include/qpid/dispatch/connection_manager.h |  60 --------------
 src/connection_manager.c                   | 106 +++---------------------
 src/container.c                            |   5 --
 src/policy.c                               |   2 -
 4 files changed, 13 insertions(+), 160 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/ea42febf/include/qpid/dispatch/connection_manager.h
----------------------------------------------------------------------
diff --git a/include/qpid/dispatch/connection_manager.h b/include/qpid/dispatch/connection_manager.h
index 686cf3b..4c2b319 100644
--- a/include/qpid/dispatch/connection_manager.h
+++ b/include/qpid/dispatch/connection_manager.h
@@ -70,66 +70,6 @@ void qd_connection_manager_start(qd_dispatch_t *qd);
 
 
 /**
- * Given a connector-name, find and return a pointer to the on-demand connector.
- *
- * @param qd The dispatch handle returned by qd_dispatch.
- * @param name The name that uniquely identifies the on-demand connector.
- * @return The matching on-demand connector or NULL if the name is not found.
- */
-qd_config_connector_t *qd_connection_manager_find_on_demand(qd_dispatch_t *qd, const char
*name);
-
-
-/**
- * Set open and close handlers for a connector.
- *
- * @param cc A configured connector.
- * @param open_handler A handler callback
- * @param close_handler A handler callback
- * @param context Context to be passed back to the handler
- */
-void qd_connection_manager_set_handlers(qd_config_connector_t *cc,
-                                        qd_connection_manager_handler_t open_handler,
-                                        qd_connection_manager_handler_t close_handler,
-                                        void *context);
-
-
-/**
- * Start an on-demand connector.
- *
- * @param qd Pointer to the dispatch instance.
- * @param cc The pointer to an on-demand connector returned by qd_connections_find_on_demand.
- */
-void qd_connection_manager_start_on_demand(qd_dispatch_t *qd, qd_config_connector_t *cc);
-
-
-/**
- * Stop an on-demand connector.
- *
- * @param qd Pointer to the dispatch instance.
- * @param cc The pointer to an on-demand connector returned by qd_connections_find_on_demand.
- */
-void qd_connection_manager_stop_on_demand(qd_dispatch_t *qd, qd_config_connector_t *cc);
-
-
-/**
- * Get the user context for a configured connector.
- *
- * @param cc Connector handle returned by qd_connection_manager_find_on_demand
- * @return User context for the configured connector.
- */
-void *qd_config_connector_context(qd_config_connector_t *cc);
-
-
-/**
- * Set the user context for a configured connector.
- *
- * @param cc Connector handle returned by qd_connection_manager_find_on_demand
- * @param context User context to be stored with the configured connector
- */
-void qd_config_connector_set_context(qd_config_connector_t *cc, void *context);
-
-
-/**
  * Get the connector's name.
  *
  * @param cc Connector handle

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/ea42febf/src/connection_manager.c
----------------------------------------------------------------------
diff --git a/src/connection_manager.c b/src/connection_manager.c
index ede3838..5c338b9 100644
--- a/src/connection_manager.c
+++ b/src/connection_manager.c
@@ -19,6 +19,7 @@
 
 #include <qpid/dispatch/connection_manager.h>
 #include <qpid/dispatch/ctools.h>
+#include <qpid/dispatch/threading.h>
 #include "dispatch_private.h"
 #include "connection_manager_private.h"
 #include "server_private.h"
@@ -41,13 +42,8 @@ DEQ_DECLARE(qd_config_listener_t, qd_config_listener_list_t);
 struct qd_config_connector_t {
     bool is_connector;
     DEQ_LINKS(qd_config_connector_t);
-    void                            *context;
-    qd_connector_t                  *connector;
-    qd_server_config_t               configuration;
-    bool                             started;
-    qd_connection_manager_handler_t  open_handler;
-    qd_connection_manager_handler_t  close_handler;
-    void                            *handler_context;
+    qd_connector_t     *connector;
+    qd_server_config_t  configuration;
 };
 
 DEQ_DECLARE(qd_config_connector_t, qd_config_connector_list_t);
@@ -58,7 +54,6 @@ struct qd_connection_manager_t {
     qd_server_t                 *server;
     qd_config_listener_list_t    config_listeners;
     qd_config_connector_list_t   config_connectors;
-    qd_config_connector_list_t   on_demand_connectors;
 };
 
 // True if entity has any of attributes.
@@ -271,7 +266,6 @@ qd_connection_manager_t *qd_connection_manager(qd_dispatch_t *qd)
     cm->server     = qd->server;
     DEQ_INIT(cm->config_listeners);
     DEQ_INIT(cm->config_connectors);
-    DEQ_INIT(cm->on_demand_connectors);
 
     return cm;
 }
@@ -290,23 +284,13 @@ void qd_connection_manager_free(qd_connection_manager_t *cm)
     }
 
     qd_config_connector_t *cc = DEQ_HEAD(cm->config_connectors);
-    while(cc) {
+    while (cc) {
         DEQ_REMOVE_HEAD(cm->config_connectors);
         qd_server_connector_free(cc->connector);
         qd_server_config_free(&cc->configuration);
         free(cc);
         cc = DEQ_HEAD(cm->config_connectors);
     }
-
-    qd_config_connector_t *odc = DEQ_HEAD(cm->on_demand_connectors);
-    while(odc) {
-        DEQ_REMOVE_HEAD(cm->on_demand_connectors);
-        if (odc->connector)
-            qd_server_connector_free(odc->connector);
-        qd_server_config_free(&odc->configuration);
-        free(odc);
-        odc = DEQ_HEAD(cm->on_demand_connectors);
-    }
 }
 
 
@@ -328,6 +312,7 @@ void qd_connection_manager_start(qd_dispatch_t *qd)
     }
 }
 
+
 void qd_config_connector_free(qd_config_connector_t *cc)
 {
     if (cc->connector)
@@ -335,108 +320,43 @@ void qd_config_connector_free(qd_config_connector_t *cc)
     free(cc);
 }
 
+
 void qd_config_listener_free(qd_config_listener_t *cl)
 {
     if (cl->listener) {
         qd_server_listener_close(cl->listener);
         qd_server_listener_free(cl->listener);
+        cl->listener = 0;
     }
     free(cl);
 }
 
+
 void qd_connection_manager_delete_listener(qd_dispatch_t *qd, void *impl)
 {
-    qd_config_listener_t *cl = (qd_config_listener_t*)impl;
+    qd_config_listener_t *cl = (qd_config_listener_t*) impl;
 
-    if(cl) {
+    if (cl) {
         qd_server_listener_close(cl->listener);
         DEQ_REMOVE(qd->connection_manager->config_listeners, cl);
         qd_config_listener_free(cl);
     }
 }
 
+
 void qd_connection_manager_delete_connector(qd_dispatch_t *qd, void *impl)
 {
-    qd_config_connector_t *cc = (qd_config_connector_t*)impl;
+    qd_config_connector_t *cc = (qd_config_connector_t*) impl;
 
-    if(cc) {
+    if (cc) {
         DEQ_REMOVE(qd->connection_manager->config_connectors, cc);
         qd_config_connector_free(cc);
     }
 }
 
-qd_config_connector_t *qd_connection_manager_find_on_demand(qd_dispatch_t *qd, const char
*name)
-{
-    qd_config_connector_t *cc = DEQ_HEAD(qd->connection_manager->on_demand_connectors);
-
-    while (cc) {
-        if (strcmp(cc->configuration.name, name) == 0)
-            break;
-        cc = DEQ_NEXT(cc);
-    }
-
-    return cc;
-}
-
-
-void qd_connection_manager_set_handlers(qd_config_connector_t *cc,
-                                        qd_connection_manager_handler_t open_handler,
-                                        qd_connection_manager_handler_t close_handler,
-                                        void *context)
-{
-    if (cc) {
-        cc->open_handler    = open_handler;
-        cc->close_handler   = close_handler;
-        cc->handler_context = context;
-    }
-}
-
-
-void qd_connection_manager_start_on_demand(qd_dispatch_t *qd, qd_config_connector_t *cc)
-{
-    if (cc && cc->connector == 0) {
-        qd_log(qd->connection_manager->log_source, QD_LOG_INFO, "Starting on-demand
connector: %s",
-               cc->configuration.name);
-        cc->connector = qd_server_connect(qd, &cc->configuration, cc);
-    }
-}
-
-
-void qd_connection_manager_stop_on_demand(qd_dispatch_t *qd, qd_config_connector_t *cc)
-{
-}
-
-void *qd_config_connector_context(qd_config_connector_t *cc)
-{
-    return cc ? cc->context : 0;
-}
-
-
-void qd_config_connector_set_context(qd_config_connector_t *cc, void *context)
-{
-    if (cc)
-        cc->context = context;
-}
-
 
 const char *qd_config_connector_name(qd_config_connector_t *cc)
 {
     return cc ? cc->configuration.name : 0;
 }
 
-
-void qd_connection_manager_connection_opened(qd_connection_t *conn)
-{
-    qd_config_connector_t *cc = (qd_config_connector_t*) qd_connection_get_config_context(conn);
-    if (cc && cc->is_connector && cc->open_handler)
-        cc->open_handler(cc->handler_context, conn);
-}
-
-
-void qd_connection_manager_connection_closed(qd_connection_t *conn)
-{
-    qd_config_connector_t *cc = (qd_config_connector_t*) qd_connection_get_config_context(conn);
-    if (cc && cc->is_connector && cc->close_handler)
-        cc->close_handler(cc->handler_context, conn);
-}
-

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/ea42febf/src/container.c
----------------------------------------------------------------------
diff --git a/src/container.c b/src/container.c
index 54b1138..86f8413 100644
--- a/src/container.c
+++ b/src/container.c
@@ -20,7 +20,6 @@
 #include <stdio.h>
 #include <string.h>
 #include "dispatch_private.h"
-#include "connection_manager_private.h"
 #include "policy.h"
 #include <qpid/dispatch/container.h>
 #include <qpid/dispatch/server.h>
@@ -303,8 +302,6 @@ static void notify_closed(qd_container_t *container, qd_connection_t *conn,
void
 
 static int close_handler(qd_container_t *container, void* conn_context, pn_connection_t *conn,
qd_connection_t* qd_conn)
 {
-    qd_connection_manager_connection_closed(qd_conn);
-
     //
     // Close all links, passing QD_LOST as the reason.  These links are not
     // being properly 'detached'.  They are being orphaned.
@@ -384,7 +381,6 @@ int pn_event_handler(void *handler_context, void *conn_context, pn_event_t
*even
             qd_connection_invoke_deferred(qd_conn, qd_policy_amqp_open, qd_conn);
         } else {
             // This Open is in response to an internally initiated connection
-            qd_connection_manager_connection_opened(qd_conn);
             notify_opened(container, qd_conn, conn_context);
         }
         break;
@@ -392,7 +388,6 @@ int pn_event_handler(void *handler_context, void *conn_context, pn_event_t
*even
     case PN_CONNECTION_REMOTE_CLOSE :
         if (pn_connection_state(conn) == (PN_LOCAL_ACTIVE | PN_REMOTE_CLOSED))
             pn_connection_close(conn);
-        qd_connection_manager_connection_closed(qd_conn);
         break;
 
     case PN_SESSION_REMOTE_OPEN :

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/ea42febf/src/policy.c
----------------------------------------------------------------------
diff --git a/src/policy.c b/src/policy.c
index d75a2db..9f98315 100644
--- a/src/policy.c
+++ b/src/policy.c
@@ -24,7 +24,6 @@
 #include <stdio.h>
 #include <string.h>
 #include "dispatch_private.h"
-#include "connection_manager_private.h"
 #include "qpid/dispatch/container.h"
 #include "qpid/dispatch/server.h"
 #include <proton/message.h>
@@ -749,7 +748,6 @@ void qd_policy_amqp_open(void *context, bool discard)
         if (connection_allowed) {
             if (pn_connection_state(conn) & PN_LOCAL_UNINIT)
                 pn_connection_open(conn);
-            qd_connection_manager_connection_opened(qd_conn);
             policy_notify_opened(qd_conn->open_container, qd_conn, qd_conn->context);
         } else {
             qd_policy_private_deny_amqp_connection(conn, RESOURCE_LIMIT_EXCEEDED, CONNECTION_DISALLOWED);


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


Mime
View raw message