summaryrefslogtreecommitdiff
path: root/net.c
diff options
context:
space:
mode:
authorMark McLoughlin <markmc@redhat.com>2009-06-18 18:21:29 +0100
committerAnthony Liguori <aliguori@us.ibm.com>2009-06-22 10:15:30 -0500
commit8cad55161c98b95deacdb9c1a66980f5b24d3179 (patch)
treea04068a9130c6df2bc6a43367737cd38e399ed20 /net.c
parent08b9d66b96f7afe77448e73882281586680a58c6 (diff)
downloadqemu-8cad55161c98b95deacdb9c1a66980f5b24d3179.tar.gz
qemu-8cad55161c98b95deacdb9c1a66980f5b24d3179.tar.bz2
qemu-8cad55161c98b95deacdb9c1a66980f5b24d3179.zip
net: add qemu_purge_queued_packets()
If net client sends packets asynchronously, it needs to purge its queued packets in cleanup() so as to prevent sent callbacks being invoked with a freed client. Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'net.c')
-rw-r--r--net.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/net.c b/net.c
index 5b092c7482..cea545e4c0 100644
--- a/net.c
+++ b/net.c
@@ -439,6 +439,22 @@ qemu_deliver_packet(VLANClientState *sender, const uint8_t *buf, int size)
return ret;
}
+void qemu_purge_queued_packets(VLANClientState *vc)
+{
+ VLANPacket **pp = &vc->vlan->send_queue;
+
+ while (*pp != NULL) {
+ VLANPacket *packet = *pp;
+
+ if (packet->sender == vc) {
+ *pp = packet->next;
+ qemu_free(packet);
+ } else {
+ pp = &packet->next;
+ }
+ }
+}
+
void qemu_flush_queued_packets(VLANClientState *vc)
{
VLANPacket *packet;