af-packet: avoid test for each packet

pull/2091/head
Eric Leblond 14 years ago committed by Victor Julien
parent f77bc5195c
commit 5f400785c8

@ -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 */

Loading…
Cancel
Save