From patchwork Fri Jun 5 17:51:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zoltan Kiss X-Patchwork-Id: 49590 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2E1022154F for ; Fri, 5 Jun 2015 17:56:10 +0000 (UTC) Received: by labc7 with SMTP id c7sf21446804lab.1 for ; Fri, 05 Jun 2015 10:56:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:delivered-to:from:to:date :message-id:in-reply-to:references:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :mime-version:content-type:content-transfer-encoding:errors-to :sender:x-original-sender:x-original-authentication-results :mailing-list; bh=D+sED0sQjxi+7Q716QvbfZxxqDBS6U/Cl19dcuILTFo=; b=jNSDTviBHTpNva60TUA+OhQWoQoFU/R2Zs8JVEytb/DK8IA2X9J+5eMpFiIdT2AtyJ SXB14c5EmizsvNwRFaWtYB1v/9lrttVEr3Inw40ywAzGpk/sKwapD8PmsJmsYPmjXvFb UJ1fl2k4c02EHFs2XgCN5iDzjd4w/KMPe33c8CeC2ZKtJ5Thk6jfVS6cgqEyed1VS8H8 GTEory2WU8r+58KnOmo1UO/RjB850FtQydWpjMfQcAXGmM9gMv6a5HwPuGfj+Cn1HsmS 6FnGcvTAgDnMon/lHCnG2k4FNMcjnsQKXDgFl79wn/P2b96EaVsMiHXrqCIiexJZHy5E /z5Q== X-Gm-Message-State: ALoCoQn+dZI76yVzokTa9eq4HLrKYP3PxLb256ftFhn6/jSJOVH6hiaCuNX9ySxCAwqf9h9cIZNK X-Received: by 10.112.166.137 with SMTP id zg9mr4199506lbb.11.1433526969122; Fri, 05 Jun 2015 10:56:09 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.1 with SMTP id o1ls410053lao.12.gmail; Fri, 05 Jun 2015 10:56:09 -0700 (PDT) X-Received: by 10.152.170.165 with SMTP id an5mr4526286lac.100.1433526968968; Fri, 05 Jun 2015 10:56:08 -0700 (PDT) Received: from mail-la0-f45.google.com (mail-la0-f45.google.com. [209.85.215.45]) by mx.google.com with ESMTPS id ml5si5402881lbc.38.2015.06.05.10.56.08 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Jun 2015 10:56:08 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) client-ip=209.85.215.45; Received: by laar3 with SMTP id r3so10451126laa.3 for ; Fri, 05 Jun 2015 10:56:08 -0700 (PDT) X-Received: by 10.112.97.194 with SMTP id ec2mr4476570lbb.88.1433526968514; Fri, 05 Jun 2015 10:56:08 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp45651lbb; Fri, 5 Jun 2015 10:56:07 -0700 (PDT) X-Received: by 10.55.50.141 with SMTP id y135mr8991870qky.91.1433526966810; Fri, 05 Jun 2015 10:56:06 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id f9si6963335qka.100.2015.06.05.10.56.01; Fri, 05 Jun 2015 10:56:06 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Received: by lists.linaro.org (Postfix, from userid 109) id 4197462129; Fri, 5 Jun 2015 17:56:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from ip-10-142-244-252.ec2.internal (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 0377062147; Fri, 5 Jun 2015 17:52:48 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id A7BFF62145; Fri, 5 Jun 2015 17:52:44 +0000 (UTC) Received: from mail-wg0-f53.google.com (mail-wg0-f53.google.com [74.125.82.53]) by lists.linaro.org (Postfix) with ESMTPS id 9599D62131 for ; Fri, 5 Jun 2015 17:51:58 +0000 (UTC) Received: by wgez8 with SMTP id z8so62288849wge.0 for ; Fri, 05 Jun 2015 10:51:57 -0700 (PDT) X-Received: by 10.194.205.5 with SMTP id lc5mr8797910wjc.74.1433526717887; Fri, 05 Jun 2015 10:51:57 -0700 (PDT) Received: from localhost.localdomain ([90.152.119.35]) by mx.google.com with ESMTPSA id bg4sm11582752wjc.10.2015.06.05.10.51.56 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 05 Jun 2015 10:51:57 -0700 (PDT) From: Zoltan Kiss To: lng-odp@lists.linaro.org Date: Fri, 5 Jun 2015 18:51:31 +0100 Message-Id: <1433526691-20058-10-git-send-email-zoltan.kiss@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1433526691-20058-1-git-send-email-zoltan.kiss@linaro.org> References: <1433526691-20058-1-git-send-email-zoltan.kiss@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCH v3 9/9] queue: handle return value of odp_queue_enq_multi() X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: zoltan.kiss@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Unsent packet has to be released. If the event type is obvious from the context, use directly the relevant release functions, otherwise odp_event(free). Wider error handling is attempted, but this patch can't fix all the flaws in the many calling functions of odp_queue_enq() Signed-off-by: Zoltan Kiss --- test/performance/odp_pktio_perf.c | 15 ++++++++++++++- test/performance/odp_scheduling.c | 10 ++++++++-- test/validation/odp_pktio.c | 5 +++++ test/validation/odp_queue.c | 6 ++++++ 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/test/performance/odp_pktio_perf.c b/test/performance/odp_pktio_perf.c index 1ef07ae..27d0fef 100644 --- a/test/performance/odp_pktio_perf.c +++ b/test/performance/odp_pktio_perf.c @@ -270,6 +270,9 @@ static int alloc_packets(odp_event_t *event_tbl, int num_pkts) static int send_packets(odp_queue_t outq, odp_event_t *event_tbl, unsigned num_pkts) { + int ret; + unsigned cnt; + if (num_pkts == 0) return 0; else if (num_pkts == 1) { @@ -281,7 +284,17 @@ static int send_packets(odp_queue_t outq, } } - return odp_queue_enq_multi(outq, event_tbl, num_pkts); + ret = odp_queue_enq_multi(outq, event_tbl, num_pkts); + if (ret == (signed)num_pkts) + return ret; + + if (ret < 0) + ret = 0; + cnt = ret; + do + odp_event_free(event_tbl[cnt]); + while (++cnt < num_pkts); + return ret; } /* diff --git a/test/performance/odp_scheduling.c b/test/performance/odp_scheduling.c index 1283986..8b46eb2 100644 --- a/test/performance/odp_scheduling.c +++ b/test/performance/odp_scheduling.c @@ -535,9 +535,15 @@ static int test_schedule_multi(const char *str, int thr, } /* Assume we can enqueue all events */ - if (odp_queue_enq_multi(queue, ev, MULTI_BUFS_MAX) != - MULTI_BUFS_MAX) { + j = odp_queue_enq_multi(queue, ev, MULTI_BUFS_MAX); + if (j != MULTI_BUFS_MAX) { LOG_ERR(" [%i] Queue enqueue failed.\n", thr); + if (j < 0) + j = 0; + do + odp_event_free(ev[j]); + while (++j < MULTI_BUFS_MAX); + return -1; } } diff --git a/test/validation/odp_pktio.c b/test/validation/odp_pktio.c index 3027b25..d25e5fa 100644 --- a/test/validation/odp_pktio.c +++ b/test/validation/odp_pktio.c @@ -387,6 +387,11 @@ static void pktio_txrx_multi(pktio_info_t *pktio_a, pktio_info_t *pktio_b, ret = odp_queue_enq_multi(pktio_a->outq, tx_ev, num_pkts); if (ret != num_pkts) { CU_FAIL("failed to enqueue test packets"); + if (ret < 0) + ret = 0; + do + odp_packet_free(tx_pkt[ret]); + while (++ret < num_pkts); return; } } diff --git a/test/validation/odp_queue.c b/test/validation/odp_queue.c index f8c64f7..341b702 100644 --- a/test/validation/odp_queue.c +++ b/test/validation/odp_queue.c @@ -90,6 +90,12 @@ static void test_odp_queue_sunnyday(void) */ ret = odp_queue_enq_multi(queue_id, enev, MAX_BUFFER_QUEUE); CU_ASSERT(MAX_BUFFER_QUEUE == ret); + if (ret < 0) + ret = 0; + do + odp_event_free(enev[ret]); + while (++ret < MAX_BUFFER_QUEUE); + pev_tmp = deev; do { deq_ret = odp_queue_deq_multi(queue_id, pev_tmp,