[Oisf-devel] [PATCH 2/2] Flow: Increase refresh timer
Eric Leblond
eric at regit.org
Fri Dec 31 12:15:31 UTC 2010
FlowManagerThread function was running its check after a 10
microseconds sleep. nanosleep system call were causing a
consequent CPU load on my computer running running no trafic.
This patch modifies the timer to a default of 10 ms.
It also suppress a usleep(1) used in pcap file mode. This delay
seems to short to really bring something.
Signed-off-by: Eric Leblond <eric at regit.org>
---
src/flow.c | 17 ++++++++++-------
1 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/src/flow.c b/src/flow.c
index d955529..9c2b53b 100644
--- a/src/flow.c
+++ b/src/flow.c
@@ -955,6 +955,10 @@ void FlowShutdown(void) {
}
}
+
+#define FLOW_SLEEP_INTERVAL 10 * 1000
+#define FLOW_UPDATE_INTERVAL FLOW_SLEEP_INTERVAL * 10
+
/** \brief Thread that manages the various queue's and removes timed out flows.
* \param td ThreadVars casted to void ptr
*
@@ -995,7 +999,7 @@ void *FlowManagerThread(void *td)
{
TmThreadTestThreadUnPaused(th_v);
- if (sleeping >= 100 || flow_flags & FLOW_EMERGENCY)
+ if (sleeping >= FLOW_UPDATE_INTERVAL || flow_flags & FLOW_EMERGENCY)
{
if (flow_flags & FLOW_EMERGENCY) {
emerg = TRUE;
@@ -1075,8 +1079,8 @@ void *FlowManagerThread(void *td)
}
if (run_mode != MODE_PCAP_FILE) {
- usleep(10);
- sleeping += 10;
+ usleep(FLOW_SLEEP_INTERVAL);
+ sleeping += FLOW_SLEEP_INTERVAL;
} else {
/* If we are reading a pcap, how long the pcap timestamps
* says that has passed */
@@ -1085,8 +1089,8 @@ void *FlowManagerThread(void *td)
if (tsdiff.tv_sec == ts.tv_sec &&
tsdiff.tv_usec > ts.tv_usec &&
- tsdiff.tv_usec - ts.tv_usec < 10) {
- /* if it has passed less than 10 usec, sleep that usecs */
+ tsdiff.tv_usec - ts.tv_usec < FLOW_SLEEP_INTERVAL) {
+ /* if it has passed less than sleep interval usec, sleep that usecs */
sleeping += tsdiff.tv_usec - ts.tv_usec;
usleep(tsdiff.tv_usec - ts.tv_usec);
} else {
@@ -1096,8 +1100,7 @@ void *FlowManagerThread(void *td)
else if (tsdiff.tv_sec == ts.tv_sec + 1)
sleeping += tsdiff.tv_usec + (1000000 - ts.tv_usec);
else
- sleeping += 100;
- usleep(1);
+ sleeping += FLOW_UPDATE_INTERVAL;
}
}
}
--
1.7.1
More information about the Oisf-devel
mailing list