af-packet: loop on ring if there is data to read.

This patch should bring some improvements by looping on the
ring when there is some data available instead of getting back
to the poll. It also fix recovery in case of drops on the ring
because the poll command will not return correctly in this case.
remotes/origin/HEAD
Eric Leblond 14 years ago committed by Victor Julien
parent 4df509f87a
commit a369f8c359

@ -400,12 +400,14 @@ int AFPReadFromRing(AFPThreadVars *ptv)
Packet *p = NULL;
union thdr h;
/* Loop till we have packets available */
while (1) {
/* Read packet from ring */
h.raw = (((union thdr **)ptv->frame_buf)[ptv->frame_offset]);
if (h.raw == NULL) {
SCReturnInt(AFP_FAILURE);
}
if (h.h2->tp_status == 0) {
if (h.h2->tp_status == TP_STATUS_KERNEL) {
SCReturnInt(AFP_READ_OK);
}
@ -480,6 +482,7 @@ int AFPReadFromRing(AFPThreadVars *ptv)
if (++ptv->frame_offset >= ptv->req.tp_frame_nr) {
ptv->frame_offset = 0;
}
}
SCReturnInt(AFP_READ_OK);
}

Loading…
Cancel
Save