]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect-state: cleanup ContinueDetection
authorVictor Julien <victor@inliniac.net>
Thu, 26 Feb 2015 14:23:41 +0000 (15:23 +0100)
committerVictor Julien <victor@inliniac.net>
Mon, 16 Mar 2015 14:36:33 +0000 (15:36 +0100)
Only lock f->de_state->m when we start to access it. So after
declaration and initialization of local vars.

src/detect-engine-state.c

index 61445a6981bb4c00f86c6308e22843edecb091e5..1dd213c3af9754e026bb239b55a86ec893f0c1f9 100644 (file)
@@ -486,8 +486,6 @@ void DeStateDetectContinueDetection(ThreadVars *tv, DetectEngineCtx *de_ctx,
                                     Packet *p, Flow *f, uint8_t flags,
                                     AppProto alproto, uint16_t alversion)
 {
-    SCMutexLock(&f->de_state_m);
-
     DetectEngineAppInspectionEngine *engine = NULL;
     SigMatch *sm = NULL;
     uint16_t file_no_match = 0;
@@ -502,8 +500,6 @@ void DeStateDetectContinueDetection(ThreadVars *tv, DetectEngineCtx *de_ctx,
     int match = 0;
     uint8_t alert = 0;
 
-    DetectEngineStateDirection *dir_state = &f->de_state->dir_state[flags & STREAM_TOSERVER ? 0 : 1];
-    DeStateStore *store = dir_state->head;
     void *inspect_tx = NULL;
     uint64_t inspect_tx_id = 0;
     uint64_t total_txs = 0;
@@ -514,6 +510,10 @@ void DeStateDetectContinueDetection(ThreadVars *tv, DetectEngineCtx *de_ctx,
      * assume that we have an alert if engine == NULL */
     uint8_t total_matches = 0;
 
+    SCMutexLock(&f->de_state_m);
+    DetectEngineStateDirection *dir_state = &f->de_state->dir_state[flags & STREAM_TOSERVER ? 0 : 1];
+    DeStateStore *store = dir_state->head;
+
     DeStateResetFileInspection(f, alproto, alstate, flags);
 
     if (AppLayerParserProtocolSupportsTxs(f->proto, alproto)) {