--- libaitio/src/bpf.c 2013/06/26 16:22:12 1.1.2.19 +++ libaitio/src/bpf.c 2013/06/26 16:34:28 1.1.2.20 @@ -231,7 +231,7 @@ chkZCbuf(struct bpf_zbuf_header *bzh) return (bzh->bzh_user_gen != atomic_load_acq_int(&bzh->bzh_kernel_gen)); } -static inline ssize_t +static ssize_t nextZCbuf(int eth, struct bpf_zbuf * __restrict zbuf, void * __restrict buf, size_t buflen) { ssize_t rlen = 0; @@ -254,8 +254,11 @@ nextZCbuf(int eth, struct bpf_zbuf * __restrict zbuf, pos += rlen; } - if (!pos) - ioctl(eth, BIOCROTZBUF, &bz); + if (!pos) { + if ((rlen = ioctl(eth, BIOCROTZBUF, &bz)) == -1) + LOGERR; + } else + rlen = pos; return rlen; } #endif @@ -285,11 +288,9 @@ io_etherRecv(int eth, void * __restrict buf, size_t bu LOGERR; } else { #ifdef __FreeBSD__ - do { + rlen = nextZCbuf(eth, (struct bpf_zbuf*) zcbuf, buf, buflen); + if (!rlen) rlen = nextZCbuf(eth, (struct bpf_zbuf*) zcbuf, buf, buflen); - if (!rlen) - continue; - } while (0); #else rlen = -1; io_SetErr(ENOTSUP, "bpf zero copy buffer mode is not supported");