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>
This commit is contained in:
parent
cb72b75824
commit
d6536b2c97
22
slirp/if.c
22
slirp/if.c
@ -96,8 +96,13 @@ if_output(struct socket *so, struct mbuf *ifm)
|
|||||||
ifs_insque(ifm, ifq->ifs_prev);
|
ifs_insque(ifm, ifq->ifs_prev);
|
||||||
goto diddit;
|
goto diddit;
|
||||||
}
|
}
|
||||||
} else
|
} else {
|
||||||
ifq = slirp->if_batchq.ifq_prev;
|
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 */
|
/* Create a new doubly linked list for this session */
|
||||||
ifm->ifq_so = so;
|
ifm->ifq_so = so;
|
||||||
@ -170,13 +175,8 @@ void if_start(Slirp *slirp)
|
|||||||
if (slirp->if_fastq.ifq_next != &slirp->if_fastq) {
|
if (slirp->if_fastq.ifq_next != &slirp->if_fastq) {
|
||||||
ifm = slirp->if_fastq.ifq_next;
|
ifm = slirp->if_fastq.ifq_next;
|
||||||
} else {
|
} else {
|
||||||
/* Nothing on fastq, see if next_m is valid */
|
/* Nothing on fastq, pick up from batchq via next_m */
|
||||||
if (slirp->next_m != &slirp->if_batchq) {
|
ifm = slirp->next_m;
|
||||||
ifm = slirp->next_m;
|
|
||||||
} else {
|
|
||||||
ifm = slirp->if_batchq.ifq_next;
|
|
||||||
}
|
|
||||||
|
|
||||||
from_batchq = true;
|
from_batchq = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,6 +202,12 @@ void if_start(Slirp *slirp)
|
|||||||
if (ifm->ifs_next != ifm) {
|
if (ifm->ifs_next != ifm) {
|
||||||
insque(ifm->ifs_next, ifqt);
|
insque(ifm->ifs_next, ifqt);
|
||||||
ifs_remque(ifm);
|
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 */
|
/* Update so_queued */
|
||||||
|
Loading…
Reference in New Issue
Block a user