From: Tom Peters (thopeter) Date: Fri, 18 Jan 2019 20:42:45 +0000 (-0500) Subject: Merge pull request #1487 in SNORT/snort3 from ~MDAGON/snort3:packet_thread_start... X-Git-Tag: 3.0.0-251~64 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=325484c22f5106a3944dc62c7fc63d04333ac4ce;p=thirdparty%2Fsnort3.git Merge pull request #1487 in SNORT/snort3 from ~MDAGON/snort3:packet_thread_start to master Squashed commit of the following: commit 1e58687aaa264f82289d73c5bbc69f9c14aeccbc Author: Maya Dagon Date: Wed Jan 9 16:13:18 2019 -0500 main: log message when all pthreads started (REG_TEST only) --- diff --git a/src/main.cc b/src/main.cc index b703888a3..22cfc64ca 100644 --- a/src/main.cc +++ b/src/main.cc @@ -239,6 +239,9 @@ void Pig::reap_commands() } while (commands_to_reap > 1); } +#ifdef REG_TEST +static bool* pigs_started = nullptr; +#endif static Pig* pigs = nullptr; static unsigned max_pigs = 0; @@ -850,6 +853,10 @@ static void main_loop() { unsigned swine = 0, pending_privileges = 0; +#ifdef REG_TEST + static bool all_pthreads_started = false; +#endif + if (SnortConfig::change_privileges()) pending_privileges = max_pigs; @@ -873,8 +880,14 @@ static void main_loop() Pig& pig = pigs[idx]; if ( pig.analyzer ) + { handle(pig, swine, pending_privileges); - +#ifdef REG_TEST + if (!pigs_started[idx] && (pig.analyzer->get_state() == + Analyzer::State::STARTED)) + pigs_started[idx] = true; +#endif + } else if ( pending_privileges ) pending_privileges--; @@ -883,6 +896,19 @@ static void main_loop() continue; } + +#ifdef REG_TEST + if (!all_pthreads_started) + { + all_pthreads_started = true; + const unsigned num_threads = (!Trough::has_next()) ? swine : max_pigs; + for (unsigned i = 0; i < num_threads; i++) + all_pthreads_started &= pigs_started[i]; + if (all_pthreads_started) + LogMessage("All pthreads started\n"); + } +#endif + if ( !exit_requested and (swine < max_pigs) and (src = Trough::get_next()) ) { Pig* pig = get_lazy_pig(max_pigs); @@ -908,11 +934,17 @@ static void snort_main() pig_poke = new Ring((max_pigs*max_grunts)+1); pigs = new Pig[max_pigs]; +#ifdef REG_TEST + pigs_started = new bool[max_pigs]; +#endif for (unsigned idx = 0; idx < max_pigs; idx++) { Pig& pig = pigs[idx]; pig.set_index(idx); +#ifdef REG_TEST + pigs_started[idx] = false; +#endif } main_loop(); @@ -920,6 +952,10 @@ static void snort_main() delete pig_poke; delete[] pigs; pigs = nullptr; +#ifdef REG_TEST + delete[] pigs_started; + pigs_started = nullptr; +#endif #ifdef SHELL ControlMgmt::socket_term();