From 8cad55161c98b95deacdb9c1a66980f5b24d3179 Mon Sep 17 00:00:00 2001 From: Mark McLoughlin Date: Thu, 18 Jun 2009 18:21:29 +0100 Subject: 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 Signed-off-by: Anthony Liguori --- net.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'net.c') diff --git a/net.c b/net.c index 5b092c7..cea545e 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; -- cgit v1.1