pcap has a callback function that is called for each packet. Once a
second, it's meant to 'dump stats'. However, the timing logic was
broken, so it would actually dump stats for each packet.
By moving the stats second timer into the thread vars, next calls of
the callback will be able to use the stored time.
/* ptr to string from config */
char *bpf_filter;
+ time_t last_stats_dump;
+
/* data link type for the thread */
int datalink;
PcapThreadVars *ptv = (PcapThreadVars *)user;
Packet *p = PacketGetFromQueueOrAlloc();
- time_t last_dump = 0;
struct timeval current_time;
if (unlikely(p == NULL)) {
/* Trigger one dump of stats every second */
TimeGet(¤t_time);
- if (current_time.tv_sec != last_dump) {
+ if (current_time.tv_sec != ptv->last_stats_dump) {
PcapDumpCounters(ptv);
- last_dump = current_time.tv_sec;
+ ptv->last_stats_dump = current_time.tv_sec;
}
SCReturn;