fix a bug where bpf would try to wakeup before updating the state.. This
was causing kqueue not to see the correct state and not wake up a process that is waiting... Submitted by: nCircle Network Security, Inc.
This commit is contained in:
parent
a5f50ef9e4
commit
7819da7944
@ -1310,6 +1310,7 @@ catchpacket(d, pkt, pktlen, snaplen, cpfn)
|
||||
struct bpf_hdr *hp;
|
||||
int totlen, curlen;
|
||||
int hdrlen = d->bd_bif->bif_hdrlen;
|
||||
int do_wakeup = 0;
|
||||
|
||||
/*
|
||||
* Figure out how many bytes to move. If the packet is
|
||||
@ -1340,7 +1341,7 @@ catchpacket(d, pkt, pktlen, snaplen, cpfn)
|
||||
return;
|
||||
}
|
||||
ROTATE_BUFFERS(d);
|
||||
bpf_wakeup(d);
|
||||
do_wakeup = 1;
|
||||
curlen = 0;
|
||||
}
|
||||
else if (d->bd_immediate || d->bd_state == BPF_TIMED_OUT)
|
||||
@ -1349,7 +1350,7 @@ catchpacket(d, pkt, pktlen, snaplen, cpfn)
|
||||
* already expired during a select call. A packet
|
||||
* arrived, so the reader should be woken up.
|
||||
*/
|
||||
bpf_wakeup(d);
|
||||
do_wakeup = 1;
|
||||
|
||||
/*
|
||||
* Append the bpf header.
|
||||
@ -1363,6 +1364,9 @@ catchpacket(d, pkt, pktlen, snaplen, cpfn)
|
||||
*/
|
||||
(*cpfn)(pkt, (u_char *)hp + hdrlen, (hp->bh_caplen = totlen - hdrlen));
|
||||
d->bd_slen = curlen + totlen;
|
||||
|
||||
if (do_wakeup)
|
||||
bpf_wakeup(d);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user