You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kg...@apache.org on 2021/08/04 15:45:58 UTC
[qpid-dispatch] branch main updated: DISPATCH-2222: avoid
per-message logging overhead when not tracing
This is an automated email from the ASF dual-hosted git repository.
kgiusti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-dispatch.git
The following commit(s) were added to refs/heads/main by this push:
new 182138c DISPATCH-2222: avoid per-message logging overhead when not tracing
182138c is described below
commit 182138cfe21b1f0b921590bb9344b18588e1c368
Author: Kenneth Giusti <kg...@apache.org>
AuthorDate: Tue Aug 3 17:00:41 2021 -0400
DISPATCH-2222: avoid per-message logging overhead when not tracing
This closes #1330
---
src/router_node.c | 47 +++++++++++++++++++++++++++--------------------
1 file changed, 27 insertions(+), 20 deletions(-)
diff --git a/src/router_node.c b/src/router_node.c
index f5a0e91..8c42676 100644
--- a/src/router_node.c
+++ b/src/router_node.c
@@ -407,27 +407,34 @@ static qd_iterator_t *router_annotate_message(qd_router_t *router,
static void log_link_message(qd_connection_t *conn, pn_link_t *pn_link, qd_message_t *msg)
{
- if (!conn || !pn_link || !msg) return;
- const qd_server_config_t *cf = qd_connection_config(conn);
- if (!cf) return;
- size_t repr_len = qd_message_repr_len();
- char *buf = qd_malloc(repr_len);
- const char *msg_str = qd_message_oversize(msg) ? "oversize message" :
- qd_message_aborted(msg) ? "aborted message" :
- qd_message_repr(msg, buf, repr_len, cf->log_bits);
- if (msg_str) {
- const char *src = pn_terminus_get_address(pn_link_source(pn_link));
- const char *tgt = pn_terminus_get_address(pn_link_target(pn_link));
- qd_log(qd_message_log_source(), QD_LOG_TRACE,
- "[C%"PRIu64"]: %s %s on link '%s' (%s -> %s)",
- qd_connection_connection_id(conn),
- pn_link_is_sender(pn_link) ? "Sent" : "Received",
- msg_str,
- pn_link_name(pn_link),
- src ? src : "",
- tgt ? tgt : "");
+ assert(conn && pn_link && msg);
+ qd_log_source_t *logger = qd_message_log_source();
+
+ // the message processing is expensive as this is done for every message received.
+ // Do not bother if not tracing.
+
+ if (qd_log_enabled(logger, QD_LOG_TRACE)) {
+ const qd_server_config_t *cf = qd_connection_config(conn);
+ if (!cf) return;
+ size_t repr_len = qd_message_repr_len();
+ char *buf = qd_malloc(repr_len);
+ const char *msg_str = qd_message_oversize(msg) ? "oversize message" :
+ qd_message_aborted(msg) ? "aborted message" :
+ qd_message_repr(msg, buf, repr_len, cf->log_bits);
+ if (msg_str) {
+ const char *src = pn_terminus_get_address(pn_link_source(pn_link));
+ const char *tgt = pn_terminus_get_address(pn_link_target(pn_link));
+ qd_log(logger, QD_LOG_TRACE,
+ "[C%"PRIu64"]: %s %s on link '%s' (%s -> %s)",
+ qd_connection_connection_id(conn),
+ pn_link_is_sender(pn_link) ? "Sent" : "Received",
+ msg_str,
+ pn_link_name(pn_link),
+ src ? src : "",
+ tgt ? tgt : "");
+ }
+ free(buf);
}
- free(buf);
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org