Squashed commit of the following:
commit
22cbf9fe707272c9549ec81125fec4fbc69d961e
Author: Bhagya Tholpady <bbantwal@cisco.com>
Date: Fri Aug 11 13:34:12 2017 -0400
main: Fix pause command issued from command line to accept control commands while in paused state
commit
8519c9d98ebc9375e66234de9aa3a6d108d27fd8
Author: Bhagya Tholpady <bbantwal@cisco.com>
Date: Fri Aug 11 12:46:48 2017 -0400
main: Fix pause command issued from command line to accept control commands while in paused state
FatalError("Failed to drop privileges!\n");
Snort::do_pidfile();
- broadcast(new ACRun());
+ broadcast(new ACRun(paused));
}
else
{
Snort::do_pidfile();
- pig.queue_command(new ACRun());
+ pig.queue_command(new ACRun(paused));
}
break;
while ( swine or paused or (Trough::has_next() and !exit_requested) )
{
const char* src;
- int idx = paused ? -1 : main_read();
+ int idx = main_read();
if ( idx >= 0 )
{
continue;
}
- if ( !exit_requested and !paused and (swine < max_pigs) and (src = Trough::get_next()) )
+ if ( !exit_requested and (swine < max_pigs) and (src = Trough::get_next()) )
{
Pig* pig = get_lazy_pig(max_pigs);
pig->prep(src);
DebugMessage(DEBUG_ANALYZER, "Handled START command\n");
}
-void Analyzer::run()
+void Analyzer::run(bool paused)
{
assert(state == State::STARTED);
Snort::thread_init_unprivileged();
- set_state(State::RUNNING);
+ if ( paused )
+ set_state(State::PAUSED);
+ else
+ set_state(State::RUNNING);
DebugMessage(DEBUG_ANALYZER, "Handled RUN command\n");
}
// Functions called by analyzer commands
void start();
- void run();
+ void run(bool paused = false);
void stop();
void pause();
void resume();
void ACRun::execute(Analyzer& analyzer)
{
- analyzer.run();
+ analyzer.run(paused);
+ paused = false;
}
void ACStop::execute(Analyzer& analyzer)
class ACRun : public AnalyzerCommand
{
public:
+ ACRun() = delete;
+ ACRun(bool is_paused = false ) { paused = is_paused; }
void execute(Analyzer&) override;
const char* stringify() override { return "RUN"; }
+private:
+ bool paused = false;
};
class ACStart : public AnalyzerCommand