]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #989 in SNORT/snort3 from pause_fix to master
authorRuss Combs (rucombs) <rucombs@cisco.com>
Mon, 14 Aug 2017 20:28:10 +0000 (16:28 -0400)
committerRuss Combs (rucombs) <rucombs@cisco.com>
Mon, 14 Aug 2017 20:28:10 +0000 (16:28 -0400)
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

src/main.cc
src/main/analyzer.cc
src/main/analyzer.h
src/main/analyzer_command.cc
src/main/analyzer_command.h

index c3a3cf7d008f4d70ab2b73d46892cde742da1fdd..1c6df6f0b903db722a589f9b75f9cd753ccb1ec6 100644 (file)
@@ -757,12 +757,12 @@ static void handle(Pig& pig, unsigned& swine, unsigned& pending_privileges)
                 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;
 
@@ -796,7 +796,7 @@ static void main_loop()
     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 )
         {
@@ -813,7 +813,7 @@ static void main_loop()
 
             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);
index b5cc63b6fdb5605f801549853acb222c370bef78..38df21177112efe23eef95ec5db57701d19fb2b0 100644 (file)
@@ -182,11 +182,14 @@ void Analyzer::start()
     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");
 }
 
index 85a064f56da9eb4a71e3cba329519a80df63ee2f..5e43fb4bfff4f8a43ad5e0e339bfe374de1796fd 100644 (file)
@@ -58,7 +58,7 @@ public:
 
     // Functions called by analyzer commands
     void start();
-    void run();
+    void run(bool paused = false);
     void stop();
     void pause();
     void resume();
index 158e064ede428e5f08f6c743bbacb28f8b85c7f8..6cf682aebfeee80c6aabc950372ccbd59231b238 100644 (file)
@@ -41,7 +41,8 @@ void ACStart::execute(Analyzer& analyzer)
 
 void ACRun::execute(Analyzer& analyzer)
 {
-    analyzer.run();
+    analyzer.run(paused);
+    paused = false;
 }
 
 void ACStop::execute(Analyzer& analyzer)
index f4ae88e99d2eb8a28024eb853ac682e05280c49d..cefd005b0080356d175d5b19bd48da69aadf572e 100644 (file)
@@ -67,8 +67,12 @@ public:
 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