From 5f400785c850887b9e2856f2afbf89dfba7b53e2 Mon Sep 17 00:00:00 2001 From: Eric Leblond Date: Thu, 3 Jan 2013 20:29:54 +0100 Subject: [PATCH] af-packet: avoid test for each packet --- src/source-af-packet.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/source-af-packet.c b/src/source-af-packet.c index 942391dd4f..f9c368a40d 100644 --- a/src/source-af-packet.c +++ b/src/source-af-packet.c @@ -1128,9 +1128,16 @@ TmEcode ReceiveAFPLoop(ThreadVars *tv, void *data, void *slot) TmSlot *s = (TmSlot *)slot; time_t last_dump = 0; struct timeval current_time; + int (*AFPReadFunc) (AFPThreadVars *); ptv->slot = s->slot_next; + if (ptv->flags & AFP_RING_MODE) { + AFPReadFunc = AFPReadFromRing; + } else { + AFPReadFunc = AFPRead; + } + if (ptv->afp_state == AFP_STATE_DOWN) { /* Wait for our turn, threads before us must have opened the socket */ while (AFPPeersListWaitTurn(ptv->mpeer)) { @@ -1211,12 +1218,7 @@ TmEcode ReceiveAFPLoop(ThreadVars *tv, void *data, void *slot) continue; } } else if (r > 0) { - if (ptv->flags & AFP_RING_MODE) { - r = AFPReadFromRing(ptv); - } else { - /* AFPRead will call TmThreadsSlotProcessPkt on read packets */ - r = AFPRead(ptv); - } + r = AFPReadFunc(ptv); switch (r) { case AFP_READ_FAILURE: /* AFPRead in error: best to reset the socket */ -- 2.47.2