]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
threading: remove '1slot' functions
authorVictor Julien <victor@inliniac.net>
Thu, 4 Dec 2014 15:42:55 +0000 (16:42 +0100)
committerVictor Julien <victor@inliniac.net>
Thu, 4 Dec 2014 15:42:55 +0000 (16:42 +0100)
No longer in use after the 'auto' runmode removal.

All runmodes now use either varslot or pktacqloop support.

src/tm-threads.c

index 7cd06e9ea5b3106ef360e3e80d89cec7623938ea..0c9d50a9eb4d83bb624beb30d3d17c43b493283c 100644 (file)
@@ -120,439 +120,6 @@ TmEcode TmDummyFunc(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq, Pack
     return TM_ECODE_OK;
 }
 
-/* 1 slot functions */
-void *TmThreadsSlot1NoIn(void *td)
-{
-    /* block usr2.  usr2 to be handled by the main thread only */
-    UtilSignalBlock(SIGUSR2);
-
-    ThreadVars *tv = (ThreadVars *)td;
-    TmSlot *s = (TmSlot *)tv->tm_slots;
-    char run = 1;
-    TmEcode r = TM_ECODE_OK;
-
-    /* Set the thread name */
-    if (SCSetThreadName(tv->name) < 0) {
-        SCLogWarning(SC_ERR_THREAD_INIT, "Unable to set thread name");
-    }
-
-    if (tv->thread_setup_flags != 0)
-        TmThreadSetupOptions(tv);
-
-    /* Drop the capabilities for this thread */
-    SCDropCaps(tv);
-
-    PacketPoolInit();
-
-    if (s->SlotThreadInit != NULL) {
-        void *slot_data = NULL;
-        r = s->SlotThreadInit(tv, s->slot_initdata, &slot_data);
-        if (r != TM_ECODE_OK) {
-            EngineKill();
-
-            TmThreadsSetFlag(tv, THV_CLOSED | THV_RUNNING_DONE);
-            pthread_exit((void *) -1);
-            return NULL;
-        }
-        (void)SC_ATOMIC_SET(s->slot_data, slot_data);
-    }
-    memset(&s->slot_pre_pq, 0, sizeof(PacketQueue));
-    memset(&s->slot_post_pq, 0, sizeof(PacketQueue));
-
-    tv->sc_perf_pca = SCPerfGetAllCountersArray(&tv->sc_perf_pctx);
-    SCPerfAddToClubbedTMTable((tv->thread_group_name != NULL) ?
-            tv->thread_group_name : tv->name, &tv->sc_perf_pctx);
-
-    TmThreadsSetFlag(tv, THV_INIT_DONE);
-
-    while (run) {
-        if (TmThreadsCheckFlag(tv, THV_PAUSE)) {
-            TmThreadsSetFlag(tv, THV_PAUSED);
-            TmThreadTestThreadUnPaused(tv);
-            TmThreadsUnsetFlag(tv, THV_PAUSED);
-        }
-        TmSlotFunc SlotFunc = SC_ATOMIC_GET(s->SlotFunc);
-
-        r = SlotFunc(tv, NULL, SC_ATOMIC_GET(s->slot_data), &s->slot_pre_pq, &s->slot_post_pq);
-
-        /* handle error */
-        if (r == TM_ECODE_FAILED) {
-            TmqhReleasePacketsToPacketPool(&s->slot_pre_pq);
-
-            SCMutexLock(&s->slot_post_pq.mutex_q);
-            TmqhReleasePacketsToPacketPool(&s->slot_post_pq);
-            SCMutexUnlock(&s->slot_post_pq.mutex_q);
-
-            TmThreadsSetFlag(tv, THV_FAILED);
-            break;
-        }
-
-        /* handle pre queue */
-        while (s->slot_pre_pq.top != NULL) {
-            Packet *extra_p = PacketDequeue(&s->slot_pre_pq);
-            if (extra_p != NULL)
-                tv->tmqh_out(tv, extra_p);
-        }
-
-        /* handle post queue */
-        if (s->slot_post_pq.top != NULL) {
-            SCMutexLock(&s->slot_post_pq.mutex_q);
-            while (s->slot_post_pq.top != NULL) {
-                Packet *extra_p = PacketDequeue(&s->slot_post_pq);
-                if (extra_p != NULL)
-                    tv->tmqh_out(tv, extra_p);
-            }
-            SCMutexUnlock(&s->slot_post_pq.mutex_q);
-        }
-
-        if (TmThreadsCheckFlag(tv, THV_KILL)) {
-            SCPerfSyncCounters(tv);
-            run = 0;
-        }
-    } /* while (run) */
-
-    PacketPoolDestroy();
-
-    TmThreadsSetFlag(tv, THV_RUNNING_DONE);
-    TmThreadWaitForFlag(tv, THV_DEINIT);
-
-    if (s->SlotThreadExitPrintStats != NULL) {
-        s->SlotThreadExitPrintStats(tv, SC_ATOMIC_GET(s->slot_data));
-    }
-
-    if (s->SlotThreadDeinit != NULL) {
-        r = s->SlotThreadDeinit(tv, SC_ATOMIC_GET(s->slot_data));
-        if (r != TM_ECODE_OK) {
-            TmThreadsSetFlag(tv, THV_CLOSED);
-            pthread_exit((void *) -1);
-            return NULL;
-        }
-    }
-
-    TmThreadsSetFlag(tv, THV_CLOSED);
-    pthread_exit((void *) 0);
-    return NULL;
-}
-
-void *TmThreadsSlot1NoOut(void *td)
-{
-    /* block usr2.  usr2 to be handled by the main thread only */
-    UtilSignalBlock(SIGUSR2);
-
-    ThreadVars *tv = (ThreadVars *)td;
-    TmSlot *s = (TmSlot *)tv->tm_slots;
-    Packet *p = NULL;
-    char run = 1;
-    TmEcode r = TM_ECODE_OK;
-
-    /* Set the thread name */
-    if (SCSetThreadName(tv->name) < 0) {
-        SCLogWarning(SC_ERR_THREAD_INIT, "Unable to set thread name");
-    }
-
-    if (tv->thread_setup_flags != 0)
-        TmThreadSetupOptions(tv);
-
-    /* Drop the capabilities for this thread */
-    SCDropCaps(tv);
-
-    PacketPoolInit();
-
-    if (s->SlotThreadInit != NULL) {
-        void *slot_data = NULL;
-        r = s->SlotThreadInit(tv, s->slot_initdata, &slot_data);
-        if (r != TM_ECODE_OK) {
-            EngineKill();
-
-            TmThreadsSetFlag(tv, THV_CLOSED | THV_RUNNING_DONE);
-            pthread_exit((void *) -1);
-            return NULL;
-        }
-        (void)SC_ATOMIC_SET(s->slot_data, slot_data);
-    }
-    memset(&s->slot_pre_pq, 0, sizeof(PacketQueue));
-    memset(&s->slot_post_pq, 0, sizeof(PacketQueue));
-
-    tv->sc_perf_pca = SCPerfGetAllCountersArray(&tv->sc_perf_pctx);
-    SCPerfAddToClubbedTMTable((tv->thread_group_name != NULL) ?
-            tv->thread_group_name : tv->name, &tv->sc_perf_pctx);
-
-    TmThreadsSetFlag(tv, THV_INIT_DONE);
-
-    while (run) {
-        if (TmThreadsCheckFlag(tv, THV_PAUSE)) {
-            TmThreadsSetFlag(tv, THV_PAUSED);
-            TmThreadTestThreadUnPaused(tv);
-            TmThreadsUnsetFlag(tv, THV_PAUSED);
-        }
-        TmSlotFunc SlotFunc = SC_ATOMIC_GET(s->SlotFunc);
-
-        p = tv->tmqh_in(tv);
-
-        PACKET_PROFILING_TMM_START(p, s->tm_id);
-        r = SlotFunc(tv, p, SC_ATOMIC_GET(s->slot_data), /* no outqh no pq */ NULL,
-                        /* no outqh no pq */ NULL);
-        PACKET_PROFILING_TMM_END(p, s->tm_id);
-
-        /* handle error */
-        if (r == TM_ECODE_FAILED) {
-            TmqhOutputPacketpool(tv, p);
-            TmThreadsSetFlag(tv, THV_FAILED);
-            break;
-        }
-
-        if (TmThreadsCheckFlag(tv, THV_KILL)) {
-            SCPerfSyncCounters(tv);
-            run = 0;
-        }
-    } /* while (run) */
-
-    PacketPoolDestroy();
-
-    TmThreadsSetFlag(tv, THV_RUNNING_DONE);
-    TmThreadWaitForFlag(tv, THV_DEINIT);
-
-    if (s->SlotThreadExitPrintStats != NULL) {
-        s->SlotThreadExitPrintStats(tv, SC_ATOMIC_GET(s->slot_data));
-    }
-
-    if (s->SlotThreadDeinit != NULL) {
-        r = s->SlotThreadDeinit(tv, SC_ATOMIC_GET(s->slot_data));
-        if (r != TM_ECODE_OK) {
-            TmThreadsSetFlag(tv, THV_CLOSED);
-            pthread_exit((void *) -1);
-            return NULL;
-        }
-    }
-
-    TmThreadsSetFlag(tv, THV_CLOSED);
-    pthread_exit((void *) 0);
-    return NULL;
-}
-
-void *TmThreadsSlot1NoInOut(void *td)
-{
-    /* block usr2.  usr2 to be handled by the main thread only */
-    UtilSignalBlock(SIGUSR2);
-
-    ThreadVars *tv = (ThreadVars *)td;
-    TmSlot *s = (TmSlot *)tv->tm_slots;
-    char run = 1;
-    TmEcode r = TM_ECODE_OK;
-
-    /* Set the thread name */
-    if (SCSetThreadName(tv->name) < 0) {
-        SCLogWarning(SC_ERR_THREAD_INIT, "Unable to set thread name");
-    }
-
-    if (tv->thread_setup_flags != 0)
-        TmThreadSetupOptions(tv);
-
-    /* Drop the capabilities for this thread */
-    SCDropCaps(tv);
-
-    PacketPoolInit();
-
-    SCLogDebug("%s starting", tv->name);
-
-    if (s->SlotThreadInit != NULL) {
-        void *slot_data = NULL;
-        r = s->SlotThreadInit(tv, s->slot_initdata, &slot_data);
-        if (r != TM_ECODE_OK) {
-            EngineKill();
-
-            TmThreadsSetFlag(tv, THV_CLOSED | THV_RUNNING_DONE);
-            pthread_exit((void *) -1);
-            return NULL;
-        }
-        (void)SC_ATOMIC_SET(s->slot_data, slot_data);
-    }
-    memset(&s->slot_pre_pq, 0, sizeof(PacketQueue));
-    memset(&s->slot_post_pq, 0, sizeof(PacketQueue));
-
-    tv->sc_perf_pca = SCPerfGetAllCountersArray(&tv->sc_perf_pctx);
-    SCPerfAddToClubbedTMTable((tv->thread_group_name != NULL) ?
-            tv->thread_group_name : tv->name, &tv->sc_perf_pctx);
-
-    TmThreadsSetFlag(tv, THV_INIT_DONE);
-
-    while (run) {
-        TmSlotFunc SlotFunc = SC_ATOMIC_GET(s->SlotFunc);
-        if (TmThreadsCheckFlag(tv, THV_PAUSE)) {
-            TmThreadsSetFlag(tv, THV_PAUSED);
-            TmThreadTestThreadUnPaused(tv);
-            TmThreadsUnsetFlag(tv, THV_PAUSED);
-        }
-
-        r = SlotFunc(tv, NULL, SC_ATOMIC_GET(s->slot_data), /* no outqh, no pq */NULL, NULL);
-
-        /* handle error */
-        if (r == TM_ECODE_FAILED) {
-            TmThreadsSetFlag(tv, THV_FAILED);
-            break;
-        }
-
-        if (TmThreadsCheckFlag(tv, THV_KILL)) {
-            SCPerfSyncCounters(tv);
-            run = 0;
-        }
-    } /* while (run) */
-
-    PacketPoolDestroy();
-
-    TmThreadsSetFlag(tv, THV_RUNNING_DONE);
-    TmThreadWaitForFlag(tv, THV_DEINIT);
-
-    if (s->SlotThreadExitPrintStats != NULL) {
-        s->SlotThreadExitPrintStats(tv, SC_ATOMIC_GET(s->slot_data));
-    }
-
-    if (s->SlotThreadDeinit != NULL) {
-        r = s->SlotThreadDeinit(tv, SC_ATOMIC_GET(s->slot_data));
-        if (r != TM_ECODE_OK) {
-            TmThreadsSetFlag(tv, THV_CLOSED);
-            pthread_exit((void *) -1);
-            return NULL;
-        }
-    }
-
-    TmThreadsSetFlag(tv, THV_CLOSED);
-    pthread_exit((void *) 0);
-    return NULL;
-}
-
-void *TmThreadsSlot1(void *td)
-{
-    /* block usr2.  usr2 to be handled by the main thread only */
-    UtilSignalBlock(SIGUSR2);
-
-    ThreadVars *tv = (ThreadVars *)td;
-    TmSlot *s = (TmSlot *)tv->tm_slots;
-    Packet *p = NULL;
-    char run = 1;
-    TmEcode r = TM_ECODE_OK;
-
-    /* Set the thread name */
-    if (SCSetThreadName(tv->name) < 0) {
-        SCLogWarning(SC_ERR_THREAD_INIT, "Unable to set thread name");
-    }
-
-    if (tv->thread_setup_flags != 0)
-        TmThreadSetupOptions(tv);
-
-    /* Drop the capabilities for this thread */
-    SCDropCaps(tv);
-
-    PacketPoolInit();
-
-    SCLogDebug("%s starting", tv->name);
-
-    if (s->SlotThreadInit != NULL) {
-        void *slot_data = NULL;
-        r = s->SlotThreadInit(tv, s->slot_initdata, &slot_data);
-        if (r != TM_ECODE_OK) {
-            EngineKill();
-
-            TmThreadsSetFlag(tv, THV_CLOSED | THV_RUNNING_DONE);
-            pthread_exit((void *) -1);
-            return NULL;
-        }
-        (void)SC_ATOMIC_SET(s->slot_data, slot_data);
-    }
-    memset(&s->slot_pre_pq, 0, sizeof(PacketQueue));
-    SCMutexInit(&s->slot_pre_pq.mutex_q, NULL);
-    memset(&s->slot_post_pq, 0, sizeof(PacketQueue));
-    SCMutexInit(&s->slot_post_pq.mutex_q, NULL);
-
-    tv->sc_perf_pca = SCPerfGetAllCountersArray(&tv->sc_perf_pctx);
-    SCPerfAddToClubbedTMTable((tv->thread_group_name != NULL) ?
-            tv->thread_group_name : tv->name, &tv->sc_perf_pctx);
-
-    TmThreadsSetFlag(tv, THV_INIT_DONE);
-
-    while (run) {
-        if (TmThreadsCheckFlag(tv, THV_PAUSE)) {
-            TmThreadsSetFlag(tv, THV_PAUSED);
-            TmThreadTestThreadUnPaused(tv);
-            TmThreadsUnsetFlag(tv, THV_PAUSED);
-        }
-
-        /* input a packet */
-        p = tv->tmqh_in(tv);
-
-        if (p != NULL) {
-            TmSlotFunc SlotFunc = SC_ATOMIC_GET(s->SlotFunc);
-            PACKET_PROFILING_TMM_START(p, s->tm_id);
-            r = SlotFunc(tv, p, SC_ATOMIC_GET(s->slot_data), &s->slot_pre_pq,
-                            &s->slot_post_pq);
-            PACKET_PROFILING_TMM_END(p, s->tm_id);
-
-            /* handle error */
-            if (r == TM_ECODE_FAILED) {
-                TmqhReleasePacketsToPacketPool(&s->slot_pre_pq);
-
-                SCMutexLock(&s->slot_post_pq.mutex_q);
-                TmqhReleasePacketsToPacketPool(&s->slot_post_pq);
-                SCMutexUnlock(&s->slot_post_pq.mutex_q);
-
-                TmqhOutputPacketpool(tv, p);
-                TmThreadsSetFlag(tv, THV_FAILED);
-                break;
-            }
-
-            while (s->slot_pre_pq.top != NULL) {
-                /* handle new packets from this func */
-                Packet *extra_p = PacketDequeue(&s->slot_pre_pq);
-                if (extra_p != NULL) {
-                    tv->tmqh_out(tv, extra_p);
-                }
-            }
-
-            /* output the packet */
-            tv->tmqh_out(tv, p);
-        }
-        if (s->slot_post_pq.top != NULL) {
-            SCMutexLock(&s->slot_post_pq.mutex_q);
-            while (s->slot_post_pq.top != NULL) {
-                /* handle new packets from this func */
-                Packet *extra_p = PacketDequeue(&s->slot_post_pq);
-                if (extra_p != NULL) {
-                    tv->tmqh_out(tv, extra_p);
-                }
-            }
-            SCMutexUnlock(&s->slot_post_pq.mutex_q);
-        }
-
-        if (TmThreadsCheckFlag(tv, THV_KILL)) {
-            SCPerfSyncCounters(tv);
-            run = 0;
-        }
-    } /* while (run) */
-
-    PacketPoolDestroy();
-
-    TmThreadsSetFlag(tv, THV_RUNNING_DONE);
-    TmThreadWaitForFlag(tv, THV_DEINIT);
-
-    if (s->SlotThreadExitPrintStats != NULL) {
-        s->SlotThreadExitPrintStats(tv, SC_ATOMIC_GET(s->slot_data));
-    }
-
-    if (s->SlotThreadDeinit != NULL) {
-        r = s->SlotThreadDeinit(tv, SC_ATOMIC_GET(s->slot_data));
-        if (r != TM_ECODE_OK) {
-            TmThreadsSetFlag(tv, THV_CLOSED);
-            pthread_exit((void *) -1);
-            return NULL;
-        }
-    }
-
-    SCLogDebug("%s ending", tv->name);
-    TmThreadsSetFlag(tv, THV_CLOSED);
-    pthread_exit((void *) 0);
-    return NULL;
-}
-
 /**
  * \brief Separate run function so we can call it recursively.
  *
@@ -1004,15 +571,7 @@ TmEcode TmThreadSetSlots(ThreadVars *tv, char *name, void *(*fn_p)(void *))
         }
     }
 
-    if (strcmp(name, "1slot") == 0) {
-        tv->tm_func = TmThreadsSlot1;
-    } else if (strcmp(name, "1slot_noout") == 0) {
-        tv->tm_func = TmThreadsSlot1NoOut;
-    } else if (strcmp(name, "1slot_noin") == 0) {
-        tv->tm_func = TmThreadsSlot1NoIn;
-    } else if (strcmp(name, "1slot_noinout") == 0) {
-        tv->tm_func = TmThreadsSlot1NoInOut;
-    } else if (strcmp(name, "varslot") == 0) {
+    if (strcmp(name, "varslot") == 0) {
         tv->tm_func = TmThreadsSlotVar;
     } else if (strcmp(name, "pktacqloop") == 0) {
         tv->tm_func = TmThreadsSlotPktAcqLoop;