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:
John-Mark Gurney 2005-03-02 21:59:39 +00:00
parent a5f50ef9e4
commit 7819da7944
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=143064

View File

@ -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);
}
/*