]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
revert unintended changes
authorRuss Combs <rucombs@cisco.com>
Sat, 4 Oct 2014 09:52:25 +0000 (05:52 -0400)
committerRuss Combs <rucombs@cisco.com>
Sat, 4 Oct 2014 09:52:25 +0000 (05:52 -0400)
src/main/thread.cc

index 8556df544ec76045a8e06dbae31099419495fc4c..434a8cbe33f1c3aabb34963b92c1f75585f88bb0 100644 (file)
@@ -80,7 +80,7 @@ bool set_cpu_affinity(SnortConfig* sc, const std::string& str, int cpu)
 
     auto search = sa.find(str);
     if(search != sa.end())
-        ParseError("multiple CPUs set for interface %s", str.c_str());
+        ParseError("Multiple CPU's set for interface %s", str.c_str());
 
     sa[std::string(str)] = cpu;
     return false;
@@ -126,39 +126,45 @@ void pin_thread_to_cpu(const char* source)
         cpu = ta[instance_id];
     }
 
-    if ( cpu < 0 )
-        return;
 
-#if LINUX
-    static THREAD_LOCAL cpu_set_t cpu_set;
-
-    if (cpu >= CPU_SETSIZE)
-        FatalError("Maximum CPU value for this Operating System is %d",
-            CPU_SETSIZE);
-
-    CPU_ZERO(&cpu_set);
-
-    if (!sched_getaffinity(0, sizeof(cpu_set), &cpu_set))
-        if (!CPU_ISSET(cpu, &cpu_set))
-            FatalError("CPU %d is not part of source %s's and thread "
-                "%d's CPU set\n", cpu, source, instance_id);
-
-    CPU_ZERO(&cpu_set);
-    CPU_SET(cpu, &cpu_set);
-
-    if (sched_setaffinity(0, sizeof(cpu_set), &cpu_set))
-        FatalError("Unable to pin source %s to CPU %d: %s\n",
-            source, cpu, std::strerror(errno));
-#else
-    static bool warning_printed = false;
-
-    if (!warning_printed)
+    if (cpu != -1)
     {
-        WarningMessage("Thread Pinning / CPU affinity support is currently"
-            " unsupported for this Operating System");
-        warning_printed = true;
+// PREPROCESSOR MACROS -- these are not actually if statements!
+#       if LINUX
+        {
+            static THREAD_LOCAL cpu_set_t cpu_set;
+
+            if (cpu >= CPU_SETSIZE)
+                FatalError("maximum CPU value for this Operating System is %d",
+                    CPU_SETSIZE);
+
+            CPU_ZERO(&cpu_set);
+
+            if (!sched_getaffinity(0, sizeof(cpu_set), &cpu_set))
+                if (!CPU_ISSET(cpu, &cpu_set))
+                    FatalError("CPU %d is not part of source %s's and thread "
+                        "%d's CPU set\n", cpu, source, instance_id);
+
+            CPU_ZERO(&cpu_set);
+            CPU_SET(cpu, &cpu_set);
+
+            if (sched_setaffinity(0, sizeof(cpu_set), &cpu_set))
+                FatalError("unable to pin source %s to CPU %d: %s\n",
+                    source, cpu, std::strerror(errno));
+
+        }
+#       else
+        {
+            static bool warning_printed = false;
+            if (!warning_printed)
+            {
+                WarningMessage("thread pinning / CPU affinity support is currently"
+                    " unsupported for this operating system");
+                warning_printed = true;
+            }
+        }
+#       endif
     }
-#endif
 }
 
 //-------------------------------------------------------------------------