From patchwork Thu Oct 27 09:02:25 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Wu X-Patchwork-Id: 122096 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C8F5AB6F7F for ; Thu, 27 Oct 2011 20:04:10 +1100 (EST) Received: from localhost ([::1]:55002 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJLsb-0001TR-Fj for incoming@patchwork.ozlabs.org; Thu, 27 Oct 2011 05:04:05 -0400 Received: from eggs.gnu.org ([140.186.70.92]:36507) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJLsV-0001TC-9g for qemu-devel@nongnu.org; Thu, 27 Oct 2011 05:04:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RJLsQ-0000dt-QG for qemu-devel@nongnu.org; Thu, 27 Oct 2011 05:03:59 -0400 Received: from e28smtp01.in.ibm.com ([122.248.162.1]:58090) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJLsP-0000d7-Tu for qemu-devel@nongnu.org; Thu, 27 Oct 2011 05:03:54 -0400 Received: from d28relay05.in.ibm.com (d28relay05.in.ibm.com [9.184.220.62]) by e28smtp01.in.ibm.com (8.14.4/8.13.1) with ESMTP id p9R93kfE001910 for ; Thu, 27 Oct 2011 14:33:46 +0530 Received: from d28av02.in.ibm.com (d28av02.in.ibm.com [9.184.220.64]) by d28relay05.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p9R93kHe1380538 for ; Thu, 27 Oct 2011 14:33:46 +0530 Received: from d28av02.in.ibm.com (loopback [127.0.0.1]) by d28av02.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p9R93kMt025178 for ; Thu, 27 Oct 2011 20:03:46 +1100 Received: from oc4654482034.ibm.com ([9.115.122.78]) by d28av02.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p9R93jER023810; Thu, 27 Oct 2011 20:03:45 +1100 Received: by oc4654482034.ibm.com (Postfix, from userid 500) id 8DAE1447A6; Thu, 27 Oct 2011 17:02:51 +0800 (CST) From: Mark Wu To: Anthony Liguori , Mark McLoughlin Date: Thu, 27 Oct 2011 17:02:25 +0800 Message-Id: <1319706145-26599-1-git-send-email-wudxw@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Received-From: 122.248.162.1 Cc: qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH] net: Only flush queue or call sent callback on successful delivery X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Now queue flushing and sent callback could be invoked even on delivery failure. We add a checking of receiver's return value to avoid this case. Signed-off-by: Mark Wu --- net/queue.c | 12 +++++++----- 1 files changed, 7 insertions(+), 5 deletions(-) diff --git a/net/queue.c b/net/queue.c index 1ab5247..c9a027c 100644 --- a/net/queue.c +++ b/net/queue.c @@ -190,8 +190,9 @@ ssize_t qemu_net_queue_send(NetQueue *queue, qemu_net_queue_append(queue, sender, flags, data, size, sent_cb); return 0; } - - qemu_net_queue_flush(queue); + if (ret > 0) { + qemu_net_queue_flush(queue); + } return ret; } @@ -214,8 +215,9 @@ ssize_t qemu_net_queue_send_iov(NetQueue *queue, qemu_net_queue_append_iov(queue, sender, flags, iov, iovcnt, sent_cb); return 0; } - - qemu_net_queue_flush(queue); + if (ret > 0) { + qemu_net_queue_flush(queue); + } return ret; } @@ -251,7 +253,7 @@ void qemu_net_queue_flush(NetQueue *queue) break; } - if (packet->sent_cb) { + if (ret > 0 && packet->sent_cb) { packet->sent_cb(packet->sender, ret); }