From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M6M2u-0005pi-V2 for qemu-devel@nongnu.org; Tue, 19 May 2009 05:55:41 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M6M2p-0005kv-Sa for qemu-devel@nongnu.org; Tue, 19 May 2009 05:55:39 -0400 Received: from [199.232.76.173] (port=34893 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M6M2p-0005kp-LU for qemu-devel@nongnu.org; Tue, 19 May 2009 05:55:35 -0400 Received: from mail24.svc.cra.dublin.eircom.net ([159.134.118.53]:46193) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1M6M2p-0006fO-3k for qemu-devel@nongnu.org; Tue, 19 May 2009 05:55:35 -0400 From: Mark McLoughlin Date: Tue, 19 May 2009 10:55:31 +0100 Message-Id: <1242726931-5726-10-git-send-email-markmc@redhat.com> In-Reply-To: <1242726931-5726-9-git-send-email-markmc@redhat.com> References: <1242726931-5726-1-git-send-email-markmc@redhat.com> <1242726931-5726-2-git-send-email-markmc@redhat.com> <1242726931-5726-3-git-send-email-markmc@redhat.com> <1242726931-5726-4-git-send-email-markmc@redhat.com> <1242726931-5726-5-git-send-email-markmc@redhat.com> <1242726931-5726-6-git-send-email-markmc@redhat.com> <1242726931-5726-7-git-send-email-markmc@redhat.com> <1242726931-5726-8-git-send-email-markmc@redhat.com> <1242726931-5726-9-git-send-email-markmc@redhat.com> Subject: [Qemu-devel] [PATCH 09/13] net: return status from qemu_deliver_packet() List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: Mark McLoughlin , qemu-devel@nongnu.org Will allow qemu_send_packet() handle queue full condition. Signed-off-by: Mark McLoughlin --- net.c | 20 +++++++++++++++++--- 1 files changed, 17 insertions(+), 3 deletions(-) diff --git a/net.c b/net.c index 7d0a428..07bf8d8 100644 --- a/net.c +++ b/net.c @@ -409,16 +409,30 @@ int qemu_can_send_packet(VLANClientState *sender) return 0; } -static void +static int qemu_deliver_packet(VLANClientState *sender, const uint8_t *buf, int size) { VLANClientState *vc; + int ret = -1; for (vc = sender->vlan->first_client; vc != NULL; vc = vc->next) { - if (vc != sender && !vc->link_down) { - vc->receive(vc, buf, size); + ssize_t len; + + if (vc == sender) { + continue; + } + + if (vc->link_down) { + ret = size; + continue; } + + len = vc->receive(vc, buf, size); + + ret = (ret >= 0) ? ret : len; } + + return ret; } void qemu_send_packet(VLANClientState *vc, const uint8_t *buf, int size) -- 1.6.0.6