From patchwork Fri Jun 5 11:53:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zoltan Kiss X-Patchwork-Id: 49569 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C71E62154F for ; Fri, 5 Jun 2015 11:58:21 +0000 (UTC) Received: by lbcak1 with SMTP id ak1sf17342224lbc.2 for ; Fri, 05 Jun 2015 04:58:20 -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=z1a+vt0XivmJLmlxuNKOGqiWoJqY40IEEsHTvOf3vdE=; b=GihE9MmKUIx2/vNUORzb2jP7LIMtHhVZGHULGmc/Qtp7uBb0HUdJWdi9FohySs7xh5 Ojh7XJGbroqobtQOQf5wktBGEejO9ROQgg7nbE0HD/v6hRV3shg9jG7KgZlH6Q2RiMJS uY3cXZnna+gSQ2cwCVSDm22PUW4GBg2moslhmBczJ8lOwRcc8gmrgH8vmOOMO/WN1rdj 9QJzb27ktV+r4t0hY0SCSRDFPGatxXdZm7W3Tc+i2rRVPrnudVKVBI3eP7G+qb8lJr5j dLzu/tGSlwG1sOLWh4n0r+ztaE0ihI/7YC75GQXF7DeIAMp3a4SS70ESr2Z4C61iOtB1 eX+w== X-Gm-Message-State: ALoCoQl6yZ/TbRHiyzqc45qztSvYa4P4sv77cQR1uXWauDic5dWhmY7BbRs8j/KamzxYlZ1Jh6N9 X-Received: by 10.112.53.102 with SMTP id a6mr2985961lbp.16.1433505500336; Fri, 05 Jun 2015 04:58:20 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.88.41 with SMTP id bd9ls357971lab.109.gmail; Fri, 05 Jun 2015 04:58:20 -0700 (PDT) X-Received: by 10.112.93.37 with SMTP id cr5mr3069090lbb.106.1433505500188; Fri, 05 Jun 2015 04:58:20 -0700 (PDT) Received: from mail-lb0-f176.google.com (mail-lb0-f176.google.com. [209.85.217.176]) by mx.google.com with ESMTPS id xr5si4633765lbb.76.2015.06.05.04.58.20 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Jun 2015 04:58:20 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.176 as permitted sender) client-ip=209.85.217.176; Received: by lbbtu8 with SMTP id tu8so28522238lbb.2 for ; Fri, 05 Jun 2015 04:58:20 -0700 (PDT) X-Received: by 10.112.41.196 with SMTP id h4mr3050137lbl.36.1433505500087; Fri, 05 Jun 2015 04:58:20 -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 hn6csp1370184lbb; Fri, 5 Jun 2015 04:58:19 -0700 (PDT) X-Received: by 10.140.146.22 with SMTP id 22mr3688120qhs.44.1433505498401; Fri, 05 Jun 2015 04:58:18 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id g31si7272313qkh.0.2015.06.05.04.58.17; Fri, 05 Jun 2015 04:58:18 -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 5022F62032; Fri, 5 Jun 2015 11:58:17 +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 6CA7E6204F; Fri, 5 Jun 2015 11:55:31 +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 31C47620AB; Fri, 5 Jun 2015 11:55:27 +0000 (UTC) Received: from mail-wg0-f50.google.com (mail-wg0-f50.google.com [74.125.82.50]) by lists.linaro.org (Postfix) with ESMTPS id AFB566204A for ; Fri, 5 Jun 2015 11:54:22 +0000 (UTC) Received: by wgbgq6 with SMTP id gq6so54934894wgb.3 for ; Fri, 05 Jun 2015 04:54:22 -0700 (PDT) X-Received: by 10.180.20.12 with SMTP id j12mr60382493wie.4.1433505261969; Fri, 05 Jun 2015 04:54:21 -0700 (PDT) Received: from localhost.localdomain ([90.152.119.35]) by mx.google.com with ESMTPSA id b20sm10268741wjb.46.2015.06.05.04.54.21 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 05 Jun 2015 04:54:21 -0700 (PDT) From: Zoltan Kiss To: lng-odp@lists.linaro.org Date: Fri, 5 Jun 2015 12:53:51 +0100 Message-Id: <1433505231-28843-10-git-send-email-zoltan.kiss@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1433505231-28843-1-git-send-email-zoltan.kiss@linaro.org> References: <1433505231-28843-1-git-send-email-zoltan.kiss@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCH v2 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.217.176 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 f572633..4bef389 100644 --- a/test/performance/odp_pktio_perf.c +++ b/test/performance/odp_pktio_perf.c @@ -268,6 +268,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) { @@ -279,7 +282,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 4bd95ff..9d01f45 100644 --- a/test/validation/odp_queue.c +++ b/test/validation/odp_queue.c @@ -96,6 +96,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,