You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by tr...@apache.org on 2020/08/04 18:58:03 UTC

[qpid-dispatch] 17/32: Dataplane: Exposed access to connection-ids from server. Moved the generation of the "connection opened" log from router_node.c to the core module. This causes the log to be raised for all protocol adaptors.

This is an automated email from the ASF dual-hosted git repository.

tross pushed a commit to branch dev-protocol-adaptors
in repository https://gitbox.apache.org/repos/asf/qpid-dispatch.git

commit c2810643cd8f11258c268b2df09c9ee21a63ade1
Author: Ted Ross <tr...@apache.org>
AuthorDate: Thu Jun 4 11:58:46 2020 -0400

    Dataplane: Exposed access to connection-ids from server. Moved the generation of the "connection opened" log from router_node.c to the core module. This causes the log to be raised for all protocol adaptors.
---
 src/adaptors/reference_adaptor.c | 65 ++++++++++++++++++++--------------------
 src/router_core/connections.c    | 12 ++++++++
 src/router_node.c                | 11 -------
 src/server.c                     | 11 +++++++
 src/server_private.h             |  2 ++
 5 files changed, 57 insertions(+), 44 deletions(-)

diff --git a/src/adaptors/reference_adaptor.c b/src/adaptors/reference_adaptor.c
index 1680e8d..c7ca07c 100644
--- a/src/adaptors/reference_adaptor.c
+++ b/src/adaptors/reference_adaptor.c
@@ -238,39 +238,38 @@ static void on_startup(void *context)
 {
     qdr_ref_adaptor_t *adaptor = (qdr_ref_adaptor_t*) context;
 
-    qdr_connection_info_t *info = qdr_connection_info(false, //bool             is_encrypted,
-                                                      false, //bool             is_authenticated,
-                                                      true,  //bool             opened,
-                                                      "",   //char            *sasl_mechanisms,
-                                                      QD_INCOMING, //qd_direction_t   dir,
-                                                      "127.0.0.1:47756",    //const char      *host,
-                                                      "",    //const char      *ssl_proto,
-                                                      "",    //const char      *ssl_cipher,
-                                                      "",    //const char      *user,
-                                                      "",    //const char      *container,
-                                                      pn_data(0),     //pn_data_t       *connection_properties,
-                                                      0,     //int              ssl_ssf,
-                                                      false, //bool             ssl,
-                                                      // set if remote is a qdrouter
-                                                      0);    //const qdr_router_version_t *version)
-
-    adaptor->conn = qdr_connection_opened(adaptor->core,
-                                          adaptor->adaptor,
-                                          true,
-                                          QDR_ROLE_NORMAL,
-                                          1,
-                                          10000,  // get this from qd_connection_t
-                                          0,
-                                          0,
-                                          false,
-                                          false,
-                                          false,
-                                          false,
-                                          250,
-                                          0,
-                                          info,
-                                          0,
-                                          0);
+    qdr_connection_info_t *info = qdr_connection_info(false,               //bool            is_encrypted,
+                                                      false,               //bool            is_authenticated,
+                                                      true,                //bool            opened,
+                                                      "",                  //char           *sasl_mechanisms,
+                                                      QD_INCOMING,         //qd_direction_t  dir,
+                                                      "",                  //const char     *host,
+                                                      "",                  //const char     *ssl_proto,
+                                                      "",                  //const char     *ssl_cipher,
+                                                      "",                  //const char     *user,
+                                                      "reference-adaptor", //const char     *container,
+                                                      pn_data(0),          //pn_data_t      *connection_properties,
+                                                      0,                   //int             ssl_ssf,
+                                                      false,               //bool            ssl,
+                                                      0);                  //const qdr_router_version_t *version)
+
+    adaptor->conn = qdr_connection_opened(adaptor->core,    // core
+                                          adaptor->adaptor, // protocol_adaptor
+                                          true,             // incoming
+                                          QDR_ROLE_NORMAL,  // role
+                                          1,                // cost
+                                          qd_server_allocate_connection_id(adaptor->core->qd->server),
+                                          0,                // label
+                                          0,                // remote_container_id
+                                          false,            // strip_annotations_in
+                                          false,            // strip_annotations_out
+                                          false,            // policy_allow_dynamic_link_routes
+                                          false,            // policy_allow_admin_status_update
+                                          250,              // link_capacity
+                                          0,                // vhost
+                                          info,             // connection_info
+                                          0,                // context_binder
+                                          0);               // bind_token
 
     uint64_t link_id;
     qdr_terminus_t *dynamic_source = qdr_terminus(0);
diff --git a/src/router_core/connections.c b/src/router_core/connections.c
index 67ee1cb..d6c7e40 100644
--- a/src/router_core/connections.c
+++ b/src/router_core/connections.c
@@ -128,6 +128,18 @@ qdr_connection_t *qdr_connection_opened(qdr_core_t                   *core,
     action->args.connection.container_id     = qdr_field(remote_container_id);
     qdr_action_enqueue(core, action);
 
+    char   props_str[1000];
+    size_t props_len = 1000;
+
+    pn_data_format(connection_info->connection_properties, props_str, &props_len);
+
+    qd_log(core->log, QD_LOG_INFO, "[C%"PRIu64"] Connection Opened: dir=%s host=%s vhost=%s encrypted=%s"
+           " auth=%s user=%s container_id=%s props=%s",
+           management_id, incoming ? "in" : "out",
+           connection_info->host, vhost ? vhost : "", connection_info->is_encrypted ? connection_info->ssl_proto : "no",
+           connection_info->is_authenticated ? connection_info->sasl_mechanisms : "no",
+           connection_info->user, connection_info->container, props_str);
+
     return conn;
 }
 
diff --git a/src/router_node.c b/src/router_node.c
index 06c44d9..95f9619 100644
--- a/src/router_node.c
+++ b/src/router_node.c
@@ -1219,11 +1219,6 @@ static void AMQP_opened_handler(qd_router_t *router, qd_connection_t *conn, bool
                           bind_connection_context,
                           conn);
 
-    char   props_str[1000];
-    size_t props_len = 1000;
-
-    pn_data_format(props, props_str, &props_len);
-
     if (conn->connector) {
         char conn_msg[300];
         qd_format_string(conn_msg, 300, "[C%"PRIu64"] Connection Opened: dir=%s host=%s vhost=%s encrypted=%s"
@@ -1232,12 +1227,6 @@ static void AMQP_opened_handler(qd_router_t *router, qd_connection_t *conn, bool
                         authenticated ? mech : "no", (char*) user, container);
         strcpy(conn->connector->conn_msg, conn_msg);
     }
-
-
-    qd_log(router->log_source, QD_LOG_INFO, "[C%"PRIu64"] Connection Opened: dir=%s host=%s vhost=%s encrypted=%s"
-           " auth=%s user=%s container_id=%s props=%s",
-           connection_id, inbound ? "in" : "out", host, vhost ? vhost : "", encrypted ? proto : "no",
-           authenticated ? mech : "no", (char*) user, container, props_str);
 }
 
 
diff --git a/src/server.c b/src/server.c
index 27505b7..83b0802 100644
--- a/src/server.c
+++ b/src/server.c
@@ -1685,6 +1685,17 @@ bool qd_connection_handle(qd_connection_t *c, pn_event_t *e) {
     return true;
 }
 
+
+uint64_t qd_server_allocate_connection_id(qd_server_t *server)
+{
+    uint64_t id;
+    sys_mutex_lock(server->lock);
+    id = server->next_connection_id++;
+    sys_mutex_unlock(server->lock);
+    return id;
+}
+
+
 bool qd_connection_strip_annotations_in(const qd_connection_t *c) {
     return c->strip_annotations_in;
 }
diff --git a/src/server_private.h b/src/server_private.h
index 005f7ad..48a08bb 100644
--- a/src/server_private.h
+++ b/src/server_private.h
@@ -45,6 +45,8 @@ qd_connector_t* qd_connection_connector(const qd_connection_t *c);
 
 bool qd_connection_handle(qd_connection_t *c, pn_event_t *e);
 
+uint64_t qd_server_allocate_connection_id(qd_server_t *server);
+
 
 const qd_server_config_t *qd_connector_config(const qd_connector_t *c);
 


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