Author: aconway
Date: Fri Dec 12 04:15:20 2014
New Revision: 1644825
URL: http://svn.apache.org/r1644825
Log:
DISPATCH-85: Remove all direct printing to stdout and stderr.
The only thing qdrouterd was printing to stderr was the debugging information
about final status of allocators. This can't be logged normally because the
logging system is already finalized at that point.
Solution: a new container configuration attribute debugDump. If set to a file
name, allocator info is written to that file during shutdown.
Modified:
qpid/dispatch/trunk/python/qpid_dispatch/management/qdrouter.json
qpid/dispatch/trunk/src/alloc.c
qpid/dispatch/trunk/src/alloc_private.h
qpid/dispatch/trunk/src/dispatch.c
qpid/dispatch/trunk/tests/system_test.py
Modified: qpid/dispatch/trunk/python/qpid_dispatch/management/qdrouter.json
URL:
http://svn.apache.org/viewvc/qpid/dispatch/trunk/python/qpid_dispatch/management/qdrouter.json?rev=1644825&r1=1644824&r2=1644825&view=diff
==============================================================================
--- qpid/dispatch/trunk/python/qpid_dispatch/management/qdrouter.json (original)
+++ qpid/dispatch/trunk/python/qpid_dispatch/management/qdrouter.json Fri Dec
12 04:15:20 2014
@@ -129,6 +129,10 @@
"type": "Integer",
"default": 1,
"description": "The number of threads that will be created
to process message traffic and other application work (timers, non-amqp file
descriptors, etc.) ."
+ },
+ "debugDump": {
+ "type": "String",
+ "description": "A file to dump debugging information that
can't be logged normally."
}
}
},
Modified: qpid/dispatch/trunk/src/alloc.c
URL:
http://svn.apache.org/viewvc/qpid/dispatch/trunk/src/alloc.c?rev=1644825&r1=1644824&r2=1644825&view=diff
==============================================================================
--- qpid/dispatch/trunk/src/alloc.c (original)
+++ qpid/dispatch/trunk/src/alloc.c Fri Dec 12 04:15:20 2014
@@ -66,6 +66,7 @@ qd_alloc_config_t qd_alloc_default_confi
static sys_mutex_t *init_lock = 0;
static qd_alloc_type_list_t type_list;
+static char *debug_dump = 0;
static void qd_alloc_init(qd_alloc_type_desc_t *desc)
{
@@ -271,7 +272,7 @@ void qd_alloc_finalize(void)
{
//
// Note that the logging facility is already finalized by the time this is
called.
- // We will use fprintf(stderr, ...) for logging.
+ // We will dump debugging information into debug_dump if specified.
//
// The assumption coming into this finalizer is that all allocations have
been
// released. Any non-released objects shall be flagged.
@@ -285,6 +286,13 @@ void qd_alloc_finalize(void)
qd_alloc_item_t *item;
qd_alloc_type_t *type_item = DEQ_HEAD(type_list);
+
+ FILE *dump_file = 0;
+ if (debug_dump) {
+ dump_file = fopen(debug_dump, "w");
+ free(debug_dump);
+ }
+
while (type_item) {
qd_entity_cache_remove(QD_ALLOCATOR_TYPE, type_item);
qd_alloc_type_desc_t *desc = type_item->desc;
@@ -323,8 +331,9 @@ void qd_alloc_finalize(void)
//
// Check the stats for lost items
//
- if (desc->stats->total_free_to_heap <
desc->stats->total_alloc_from_heap)
- fprintf(stderr, "alloc.c: Items of type '%s' remain allocated at
shutdown: %"PRId64"\n",
+ if (dump_file && desc->stats->total_free_to_heap <
desc->stats->total_alloc_from_heap)
+ fprintf(dump_file,
+ "alloc.c: Items of type '%s' remain allocated at shutdown:
%"PRId64"\n",
desc->type_name,
desc->stats->total_alloc_from_heap -
desc->stats->total_free_to_heap);
@@ -342,6 +351,7 @@ void qd_alloc_finalize(void)
}
sys_mutex_free(init_lock);
+ if (dump_file) fclose(dump_file);
}
@@ -361,3 +371,7 @@ qd_error_t qd_entity_refresh_allocator(q
return QD_ERROR_NONE;
return qd_error_code();
}
+
+void qd_alloc_debug_dump(const char *file) {
+ debug_dump = file ? strdup(file) : 0;
+}
Modified: qpid/dispatch/trunk/src/alloc_private.h
URL:
http://svn.apache.org/viewvc/qpid/dispatch/trunk/src/alloc_private.h?rev=1644825&r1=1644824&r2=1644825&view=diff
==============================================================================
--- qpid/dispatch/trunk/src/alloc_private.h (original)
+++ qpid/dispatch/trunk/src/alloc_private.h Fri Dec 12 04:15:20 2014
@@ -23,6 +23,7 @@
#include <qpid/dispatch/dispatch.h>
void qd_alloc_initialize(void);
+void qd_alloc_debug_dump(const char *file);
void qd_alloc_finalize(void);
#endif
Modified: qpid/dispatch/trunk/src/dispatch.c
URL:
http://svn.apache.org/viewvc/qpid/dispatch/trunk/src/dispatch.c?rev=1644825&r1=1644824&r2=1644825&view=diff
==============================================================================
--- qpid/dispatch/trunk/src/dispatch.c (original)
+++ qpid/dispatch/trunk/src/dispatch.c Fri Dec 12 04:15:20 2014
@@ -92,6 +92,7 @@ qd_error_t qd_dispatch_configure_contain
const char *default_name = "00000000-0000-0000-0000-000000000000";
qd->thread_count = qd_entity_opt_long(entity, "workerThreads", 1);
QD_ERROR_RET();
qd->container_name = qd_entity_opt_string(entity, "containerName",
default_name); QD_ERROR_RET();
+ qd_alloc_debug_dump(qd_entity_opt_string(entity, "debugDump", 0));
QD_ERROR_RET();
return QD_ERROR_NONE;
}
Modified: qpid/dispatch/trunk/tests/system_test.py
URL:
http://svn.apache.org/viewvc/qpid/dispatch/trunk/tests/system_test.py?rev=1644825&r1=1644824&r2=1644825&view=diff
==============================================================================
--- qpid/dispatch/trunk/tests/system_test.py (original)
+++ qpid/dispatch/trunk/tests/system_test.py Fri Dec 12 04:15:20 2014
@@ -291,7 +291,8 @@ class Qdrouterd(Process):
DEFAULTS = {
'listener':{'addr':'0.0.0.0', 'sasl-mechanisms':'ANONYMOUS'},
- 'connector':{'addr':'0.0.0.0', 'sasl-mechanisms':'ANONYMOUS',
'role':'on-demand'}
+ 'connector':{'addr':'0.0.0.0', 'sasl-mechanisms':'ANONYMOUS',
'role':'on-demand'},
+ 'container':{'debugDump':"qddebug.txt"}
}
def sections(self, name):
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]