diff options
author | Jan Kiszka <jan.kiszka@siemens.com> | 2012-02-29 09:27:33 +0100 |
---|---|---|
committer | Jan Kiszka <jan.kiszka@siemens.com> | 2012-03-13 14:05:48 +0100 |
commit | e9c188c5d109483b3d8bba0468303c298a87c314 (patch) | |
tree | c3a85a9a32faec958daae10265feda74b792521a | |
parent | 2a3860ac9679fbe01b3aba96c6d5be610e4ce99e (diff) | |
download | slirp-e9c188c5d109483b3d8bba0468303c298a87c314.zip slirp-e9c188c5d109483b3d8bba0468303c298a87c314.tar.gz slirp-e9c188c5d109483b3d8bba0468303c298a87c314.tar.bz2 |
slirp: Keep next_m always valid
Make sure that next_m always points to a packet if batchq is non-empty.
This will simplify walking the queues in if_start.
CC: Fabien Chouteau <chouteau@adacore.com>
CC: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
CC: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
-rw-r--r-- | if.c | 22 |
1 files changed, 14 insertions, 8 deletions
@@ -93,8 +93,13 @@ void if_output(struct socket *so, struct mbuf *ifm) ifs_insque(ifm, ifq->ifs_prev); goto diddit; } - } else + } else { ifq = slirp->if_batchq.ifq_prev; + /* Set next_m if the queue was empty so far */ + if (slirp->next_m == &slirp->if_batchq) { + slirp->next_m = ifm; + } + } /* Create a new doubly linked list for this session */ ifm->ifq_so = so; @@ -166,13 +171,8 @@ void if_start(Slirp *slirp) if (slirp->if_fastq.ifq_next != &slirp->if_fastq) { ifm = slirp->if_fastq.ifq_next; } else { - /* Nothing on fastq, see if next_m is valid */ - if (slirp->next_m != &slirp->if_batchq) { - ifm = slirp->next_m; - } else { - ifm = slirp->if_batchq.ifq_next; - } - + /* Nothing on fastq, pick up from batchq via next_m */ + ifm = slirp->next_m; from_batchq = true; } @@ -198,6 +198,12 @@ void if_start(Slirp *slirp) if (ifm->ifs_next != ifm) { insque(ifm->ifs_next, ifqt); ifs_remque(ifm); + /* Set next_m if the session packet is now the only one on + * batchq */ + if (ifqt == &slirp->if_batchq && + slirp->next_m == &slirp->if_batchq) { + slirp->next_m = ifm->ifs_next; + } } /* Update so_queued */ |