]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
fix for #882.
authorAnoop Saldanha <anoopsaldanha@gmail.com>
Thu, 18 Jul 2013 09:05:54 +0000 (14:35 +0530)
committerVictor Julien <victor@inliniac.net>
Fri, 19 Jul 2013 11:57:16 +0000 (13:57 +0200)
Refactor the code that initializes the cuda mpm environment.

src/suricata.c
src/util-mpm-ac.c
src/util-mpm.c
src/util-mpm.h

index fc2d3f2ce8e8aac688e7f8c52018494df64b6787..9f5f12507d4b288859c9a72fc76b4962d6b39709 100644 (file)
@@ -1361,6 +1361,9 @@ int main(int argc, char **argv)
 
     /* load the pattern matchers */
     MpmTableSetup();
+#ifdef __SC_CUDA_SUPPORT__
+    MpmCudaEnvironmentSetup();
+#endif
 
     AppLayerDetectProtoThreadInit();
     if (list_app_layer_protocols) {
index 8c218a089659473436a2029758239a146a7ddfed..0e149547b71e7c21228b70cd52fd19ebfd4d5300 100644 (file)
@@ -2163,19 +2163,6 @@ void MpmACCudaRegister(void)
     mpm_table[MPM_AC_CUDA].PrintThreadCtx = SCACPrintSearchStats;
     mpm_table[MPM_AC_CUDA].RegisterUnittests = SCACRegisterTests;
 
-    if (PatternMatchDefaultMatcher() == MPM_AC_CUDA) {
-        MpmCudaConf *conf = CudaHandlerGetCudaProfile("mpm");
-        if (conf == NULL) {
-            SCLogError(SC_ERR_AC_CUDA_ERROR, "Error obtaining cuda mpm profile.");
-            exit(EXIT_FAILURE);
-        }
-
-        if (MpmCudaBufferSetup() < 0) {
-            SCLogError(SC_ERR_AC_CUDA_ERROR, "Error setting up env for ac cuda");
-            exit(EXIT_FAILURE);
-        }
-    }
-
     return;
 }
 
index d9f105c98d2ea5346b1e92deebdb3412bd46fe49..1756f8bfb723c1982a6b7b4aeb2de4da68545802 100644 (file)
@@ -47,6 +47,7 @@
 #include "util-unittest.h"
 #ifdef __SC_CUDA_SUPPORT__
 #include "util-cuda-handlers.h"
+#include "detect-engine-mpm.h"
 #endif
 
 /**
@@ -378,6 +379,30 @@ static void *MpmCudaConfParse(ConfNode *node)
 
     return conf;
 }
+
+void MpmCudaEnvironmentSetup()
+{
+    if (PatternMatchDefaultMatcher() != MPM_AC_CUDA)
+        return;
+
+    CudaHandlerAddCudaProfileFromConf("mpm", MpmCudaConfParse, MpmCudaConfFree);
+
+    MpmCudaConf *conf = CudaHandlerGetCudaProfile("mpm");
+    if (conf == NULL) {
+        SCLogError(SC_ERR_AC_CUDA_ERROR, "Error obtaining cuda mpm "
+                       "profile.");
+        exit(EXIT_FAILURE);
+    }
+
+    if (MpmCudaBufferSetup() < 0) {
+        SCLogError(SC_ERR_AC_CUDA_ERROR, "Error setting up env for ac "
+                   "cuda");
+        exit(EXIT_FAILURE);
+    }
+
+    return;
+}
+
 #endif
 
 /**
@@ -565,7 +590,6 @@ void MpmTableSetup(void) {
     MpmACBSRegister();
     MpmACGfbsRegister();
 #ifdef __SC_CUDA_SUPPORT__
-    CudaHandlerAddCudaProfileFromConf("mpm", MpmCudaConfParse, MpmCudaConfFree);
     MpmACCudaRegister();
 #endif /* __SC_CUDA_SUPPORT__ */
 }
index 605b9c6ff6b9403e78a625d1b756aae7e3fafb48..a3524908111402435edd104932bbf0cce5a6acc7 100644 (file)
@@ -212,6 +212,8 @@ typedef struct MpmCudaConf_ {
     int cuda_streams;
 } MpmCudaConf;
 
+void MpmCudaEnvironmentSetup();
+
 #endif /* __SC_CUDA_SUPPORT__ */
 
 struct DetectEngineCtx_;