summaryrefslogtreecommitdiff
path: root/gnuradio-runtime/lib/tpb_thread_body.cc
diff options
context:
space:
mode:
authorTom Rondeau <tom@trondeau.com>2014-06-29 22:01:02 -0400
committerTom Rondeau <tom@trondeau.com>2014-06-29 22:01:02 -0400
commit0ae33fc67a7655b63a6384a1898319b7cc2c5bf6 (patch)
tree59e8d2b31b45e859716eaa73fc94f32162302735 /gnuradio-runtime/lib/tpb_thread_body.cc
parentdf8bd0bc31693a04b0096743d451c0c36cc7b297 (diff)
runtime: fix a memory leak in the logger when restarting a flowgraph due to adding new appenders to the logger. Now we clear them and set a
This adds a set of "set" functions to set a new appender. We can always add additional loggers using the old "add" functions.
Diffstat (limited to 'gnuradio-runtime/lib/tpb_thread_body.cc')
-rw-r--r--gnuradio-runtime/lib/tpb_thread_body.cc40
1 files changed, 20 insertions, 20 deletions
diff --git a/gnuradio-runtime/lib/tpb_thread_body.cc b/gnuradio-runtime/lib/tpb_thread_body.cc
index eb47a43ee3..d2f0fce833 100644
--- a/gnuradio-runtime/lib/tpb_thread_body.cc
+++ b/gnuradio-runtime/lib/tpb_thread_body.cc
@@ -36,7 +36,7 @@ namespace gr {
: d_exec(block, max_noutput_items)
{
//std::cerr << "tpb_thread_body: " << block << std::endl;
-
+
thread::set_thread_name(pthread_self(), boost::str(boost::format("%s%d") % block->name() % block->unique_id()));
block_detail *d = block->detail().get();
@@ -61,13 +61,13 @@ namespace gr {
GR_CONFIG_LOGGER(config_file);
if(log_file.size() > 0) {
if(log_file == "stdout") {
- GR_LOG_ADD_CONSOLE_APPENDER(LOG, "cout","gr::log :%p: %c{1} - %m%n");
+ GR_LOG_SET_CONSOLE_APPENDER(LOG, "cout","gr::log :%p: %c{1} - %m%n");
}
else if(log_file == "stderr") {
- GR_LOG_ADD_CONSOLE_APPENDER(LOG, "cerr","gr::log :%p: %c{1} - %m%n");
+ GR_LOG_SET_CONSOLE_APPENDER(LOG, "cerr","gr::log :%p: %c{1} - %m%n");
}
else {
- GR_LOG_ADD_FILE_APPENDER(LOG, log_file , true,"%r :%p: %c{1} - %m%n");
+ GR_LOG_SET_FILE_APPENDER(LOG, log_file , true,"%r :%p: %c{1} - %m%n");
}
}
#endif /* HAVE_LOG4CPP */
@@ -83,7 +83,7 @@ namespace gr {
if(block->thread_priority() > 0) {
gr::thread::set_thread_priority(d->thread, block->thread_priority());
}
-
+
// make sure our block isnt finished
block->clear_finished();
@@ -107,7 +107,7 @@ namespace gr {
if(block->nmsgs(i.first) > max_nmsgs){
GR_LOG_WARN(LOG,"asynchronous message buffer overflowing, dropping message");
msg = block->delete_head_nowait(i.first);
- }
+ }
}
}
@@ -154,19 +154,19 @@ namespace gr {
// handle all pending messages
BOOST_FOREACH(basic_block::msg_queue_map_t::value_type &i, block->msg_queue) {
if(block->has_msg_handler(i.first)) {
- while((msg = block->delete_head_nowait(i.first))) {
- guard.unlock(); // release lock while processing msg
- block->dispatch_msg(i.first, msg);
- guard.lock();
- }
+ while((msg = block->delete_head_nowait(i.first))) {
+ guard.unlock(); // release lock while processing msg
+ block->dispatch_msg(i.first, msg);
+ guard.lock();
+ }
}
else {
- // leave msg in queue if no handler is defined
- // start dropping if we have too many
- if(block->nmsgs(i.first) > max_nmsgs){
- GR_LOG_WARN(LOG,"asynchronous message buffer overflowing, dropping message");
- msg = block->delete_head_nowait(i.first);
- }
+ // leave msg in queue if no handler is defined
+ // start dropping if we have too many
+ if(block->nmsgs(i.first) > max_nmsgs){
+ GR_LOG_WARN(LOG,"asynchronous message buffer overflowing, dropping message");
+ msg = block->delete_head_nowait(i.first);
+ }
}
}
if (d->done()) {
@@ -197,11 +197,11 @@ namespace gr {
// leave msg in queue if no handler is defined
// start dropping if we have too many
if(block->nmsgs(i.first) > max_nmsgs){
- GR_LOG_WARN(LOG,"asynchronous message buffer overflowing, dropping message");
- msg = block->delete_head_nowait(i.first);
- }
+ GR_LOG_WARN(LOG,"asynchronous message buffer overflowing, dropping message");
+ msg = block->delete_head_nowait(i.first);
}
}
+ }
}
}
break;