Skip to content

Commit

Permalink
slirp: Keep next_m always valid
Browse files Browse the repository at this point in the history
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 <[email protected]>
CC: Zhi Yong Wu <[email protected]>
CC: Stefan Weil <[email protected]>
Signed-off-by: Jan Kiszka <[email protected]>
  • Loading branch information
jan-kiszka committed Mar 13, 2012
1 parent cb72b75 commit d6536b2
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions slirp/if.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,13 @@ 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;
Expand Down Expand Up @@ -170,13 +175,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;
}

Expand All @@ -202,6 +202,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 */
Expand Down

0 comments on commit d6536b2

Please sign in to comment.