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; TmSlot *s = (TmSlot *)slot;
time_t last_dump = 0; time_t last_dump = 0;
struct timeval current_time; struct timeval current_time;
int (*AFPReadFunc) (AFPThreadVars *);
ptv->slot = s->slot_next; ptv->slot = s->slot_next;
if (ptv->flags & AFP_RING_MODE) {
AFPReadFunc = AFPReadFromRing;
} else {
AFPReadFunc = AFPRead;
}
if (ptv->afp_state == AFP_STATE_DOWN) { if (ptv->afp_state == AFP_STATE_DOWN) {
/* Wait for our turn, threads before us must have opened the socket */ /* Wait for our turn, threads before us must have opened the socket */
while (AFPPeersListWaitTurn(ptv->mpeer)) { while (AFPPeersListWaitTurn(ptv->mpeer)) {
@ -1211,12 +1218,7 @@ TmEcode ReceiveAFPLoop(ThreadVars *tv, void *data, void *slot)
continue; continue;
} }
} else if (r > 0) { } else if (r > 0) {
if (ptv->flags & AFP_RING_MODE) { r = AFPReadFunc(ptv);
r = AFPReadFromRing(ptv);
} else {
/* AFPRead will call TmThreadsSlotProcessPkt on read packets */
r = AFPRead(ptv);
}
switch (r) { switch (r) {
case AFP_READ_FAILURE: case AFP_READ_FAILURE:
/* AFPRead in error: best to reset the socket */ /* AFPRead in error: best to reset the socket */

Loading…
Cancel
Save