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 2015/10/06 16:06:56 UTC
qpid-dispatch git commit: DISPATCH-178 - Added code to route proton
trace messages to the dispatch router log file instead of console
Repository: qpid-dispatch
Updated Branches:
refs/heads/master 4c1d50e66 -> 478082f27
DISPATCH-178 - Added code to route proton trace messages to the dispatch router log file instead of console
Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/478082f2
Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/478082f2
Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/478082f2
Branch: refs/heads/master
Commit: 478082f274eaacde39de40d4f706cfca6e02889f
Parents: 4c1d50e
Author: ganeshmurthy <gm...@redhat.com>
Authored: Mon Oct 5 21:41:27 2015 -0400
Committer: ganeshmurthy <gm...@redhat.com>
Committed: Tue Oct 6 09:21:09 2015 -0400
----------------------------------------------------------------------
src/server.c | 61 +++++++++++++++++++++++++++++++++++++----------
src/server_private.h | 2 ++
2 files changed, 50 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/478082f2/src/server.c
----------------------------------------------------------------------
diff --git a/src/server.c b/src/server.c
index ea86f4d..623a587 100644
--- a/src/server.c
+++ b/src/server.c
@@ -64,6 +64,15 @@ static qd_thread_t *thread(qd_server_t *qd_server, int id)
qd_error_t qd_entity_update_connection(qd_entity_t* entity, void *impl);
+/**
+ * This function is set as the pn_transport->tracer and is invoked when proton tries to write the log message to pn_transport->tracer
+ */
+static void qd_transport_tracer(pn_transport_t *transport, const char *message)
+{
+ qd_connection_t *ctx = (qd_connection_t*) pn_transport_get_context(transport);
+ qd_log(ctx->server->log_source, QD_LOG_TRACE, "[%d]:%s", ctx->connection_id, message);
+}
+
static qd_error_t connection_entity_update_host(qd_entity_t* entity, qd_connection_t *conn)
{
const qd_server_config_t *config;
@@ -239,19 +248,21 @@ static void thread_process_listeners_LH(qd_server_t *qd_server)
log_incoming(logbuf, sizeof(logbuf), cxtr));
ctx = new_qd_connection_t();
DEQ_ITEM_INIT(ctx);
- ctx->opened = false;
- ctx->closed = false;
- ctx->owner_thread = CONTEXT_UNSPECIFIED_OWNER;
- ctx->enqueued = 0;
- ctx->pn_cxtr = cxtr;
- ctx->collector = 0;
- ctx->ssl = 0;
- ctx->listener = qdpn_listener_context(listener);
- ctx->connector = 0;
- ctx->context = ctx->listener->context;
- ctx->user_context = 0;
- ctx->link_context = 0;
- ctx->ufd = 0;
+ ctx->server = qd_server;
+ ctx->opened = false;
+ ctx->closed = false;
+ ctx->owner_thread = CONTEXT_UNSPECIFIED_OWNER;
+ ctx->enqueued = 0;
+ ctx->pn_cxtr = cxtr;
+ ctx->collector = 0;
+ ctx->ssl = 0;
+ ctx->listener = qdpn_listener_context(listener);
+ ctx->connector = 0;
+ ctx->context = ctx->listener->context;
+ ctx->user_context = 0;
+ ctx->link_context = 0;
+ ctx->ufd = 0;
+ ctx->connection_id = qd_server->next_connection_id++; // Increment the connection id so the next connection can use it
DEQ_INIT(ctx->deferred_calls);
ctx->deferred_call_lock = sys_mutex();
@@ -282,6 +293,16 @@ static void thread_process_listeners_LH(qd_server_t *qd_server)
pn_transport_set_max_frame(tport, config->max_frame_size);
pn_transport_set_idle_timeout(tport, config->idle_timeout_seconds * 1000);
+ //
+ // Proton pushes out its trace to qd_transport_tracer() which in turn writes a trace message to the qdrouter log
+ // If trace level logging is enabled on the router set PN_TRACE_FRM on the proton transport
+ //
+ pn_transport_set_context(tport, ctx);
+ if (qd_log_enabled(qd_server->log_source, QD_LOG_TRACE)) {
+ pn_transport_trace(tport, PN_TRACE_FRM);
+ pn_transport_set_tracer(tport, qd_transport_tracer);
+ }
+
// Set up SSL if configured
if (config->ssl_enabled) {
qd_log(qd_server->log_source, QD_LOG_TRACE, "Configuring SSL on %s",
@@ -787,6 +808,7 @@ static void cxtr_try_open(void *context)
ctx->user_context = 0;
ctx->link_context = 0;
ctx->ufd = 0;
+
DEQ_INIT(ctx->deferred_calls);
ctx->deferred_call_lock = sys_mutex();
@@ -799,6 +821,8 @@ static void cxtr_try_open(void *context)
// qdpn_connector is not thread safe
//
sys_mutex_lock(ct->server->lock);
+ // Increment the connection id so the next connection can use it
+ ctx->connection_id = ct->server->next_connection_id++;
ctx->pn_cxtr = qdpn_connector(ct->server->driver, ct->config->host, ct->config->port, (void*) ctx);
if (ctx->pn_cxtr) {
DEQ_INSERT_TAIL(ct->server->connections, ctx);
@@ -835,6 +859,16 @@ static void cxtr_try_open(void *context)
pn_transport_set_idle_timeout(tport, config->idle_timeout_seconds * 1000);
//
+ // Proton pushes out its trace to qd_transport_tracer() which in turn writes a trace message to the qdrouter log
+ //
+ // If trace level logging is enabled on the router set PN_TRACE_FRM on the proton transport
+ pn_transport_set_context(tport, ctx);
+ if (qd_log_enabled(ct->server->log_source, QD_LOG_TRACE)) {
+ pn_transport_trace(tport, PN_TRACE_FRM);
+ pn_transport_set_tracer(tport, qd_transport_tracer);
+ }
+
+ //
// Set up SSL if appropriate
//
if (config->ssl_enabled) {
@@ -953,6 +987,7 @@ qd_server_t *qd_server(qd_dispatch_t *qd, int thread_count, const char *containe
qd_server->pause_now_serving = 0;
qd_server->pending_signal = 0;
qd_server->heartbeat_timer = 0;
+ qd_server->next_connection_id = 1;
qd_log(qd_server->log_source, QD_LOG_INFO, "Container Name: %s", qd_server->container_name);
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/478082f2/src/server_private.h
----------------------------------------------------------------------
diff --git a/src/server_private.h b/src/server_private.h
index 6cc5eb7..a40a503 100644
--- a/src/server_private.h
+++ b/src/server_private.h
@@ -98,6 +98,7 @@ struct qd_connection_t {
void *user_context;
void *link_context; // Context shared by this connection's links
qd_user_fd_t *ufd;
+ uint64_t connection_id; // A unique identifier for the qd_connection_t. The underlying pn_connection already has one but it is long and clunky.
qd_deferred_call_list_t deferred_calls;
sys_mutex_t *deferred_call_lock;
@@ -162,6 +163,7 @@ struct qd_server_t {
int pending_signal;
qd_connection_list_t connections;
qd_timer_t *heartbeat_timer;
+ uint64_t next_connection_id;
};
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