From c9b40f1ca7bdbf9c0cb799477e695b93fcf3ba04 Mon Sep 17 00:00:00 2001 From: Jon Siwek Date: Tue, 15 Apr 2014 16:36:47 -0500 Subject: [PATCH] Change how input/logging threads set their name. Setting the thread name on every heartbeat uses a mild amount of cycles and there's not much benefit to doing it there to get the additional info regarding the number of processed messages since thread names usually get truncated to 16 characters and omit that part anyway. --- src/input/ReaderBackend.cc | 2 ++ src/logging/WriterBackend.cc | 1 + src/threading/MsgThread.cc | 9 --------- src/threading/MsgThread.h | 2 +- 4 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/input/ReaderBackend.cc b/src/input/ReaderBackend.cc index abf369dd54..4c7540609c 100644 --- a/src/input/ReaderBackend.cc +++ b/src/input/ReaderBackend.cc @@ -215,6 +215,8 @@ bool ReaderBackend::Init(const int arg_num_fields, if ( Failed() ) return true; + SetOSName(Fmt("bro: %s", Name())); + num_fields = arg_num_fields; fields = arg_fields; diff --git a/src/logging/WriterBackend.cc b/src/logging/WriterBackend.cc index 5e4230c8e3..35d3137c76 100644 --- a/src/logging/WriterBackend.cc +++ b/src/logging/WriterBackend.cc @@ -180,6 +180,7 @@ void WriterBackend::DisableFrontend() bool WriterBackend::Init(int arg_num_fields, const Field* const* arg_fields) { + SetOSName(Fmt("bro: %s", Name())); num_fields = arg_num_fields; fields = arg_fields; diff --git a/src/threading/MsgThread.cc b/src/threading/MsgThread.cc index c713f65986..cf1facbba5 100644 --- a/src/threading/MsgThread.cc +++ b/src/threading/MsgThread.cc @@ -254,15 +254,6 @@ void MsgThread::Heartbeat() SendIn(new HeartbeatMessage(this, network_time, current_time())); } -void MsgThread::HeartbeatInChild() - { - string n = Fmt("bro: %s (%" PRIu64 "/%" PRIu64 ")", Name(), - cnt_sent_in - queue_in.Size(), - cnt_sent_out - queue_out.Size()); - - SetOSName(n.c_str()); - } - void MsgThread::Finished() { child_finished = true; diff --git a/src/threading/MsgThread.h b/src/threading/MsgThread.h index c5ba5b676f..e0a6f6dc01 100644 --- a/src/threading/MsgThread.h +++ b/src/threading/MsgThread.h @@ -199,7 +199,7 @@ protected: /** Internal heartbeat processing. Called from child. */ - void HeartbeatInChild(); + void HeartbeatInChild() {} /** Returns true if a child command has reported a failure. In that case, we'll * be in the process of killing this thread and no further activity