From patchwork Mon Jul 13 13:43:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zoltan Kiss X-Patchwork-Id: 51069 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f72.google.com (mail-wg0-f72.google.com [74.125.82.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4120720319 for ; Mon, 13 Jul 2015 13:44:06 +0000 (UTC) Received: by wgbbj7 with SMTP id bj7sf104105985wgb.2 for ; Mon, 13 Jul 2015 06:44:05 -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:cc: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=LmUt54szyRDlUlipl/KY1rdgII8zIy1lQu45sLKcpX0=; b=JCxXGoW89P+AAkOeyHv7zRhBBJa1LRHEF4Y+QgG+CJWN3fOeitGntwTfQl+XfRcEd6 ODKWsRaAmWmPwTe5t63s6iM12Zqzbn9ZaqPimOMVV+T5mUZUmcwt/n3K8dcUNzZRWaR6 sxtky9//vEGFN03hSdEyk4O7Rf/H0b+33OQoxzfQDOGAFuevqY8VJjnVDyLNPewagztC L9DZQ+FSYdZ7aoswDPOpg2xzQRm+6pXlfS/DWy7gg0E2zMDciQsUizPZr7C4R1JYnLyy cj0OXQ1kig//KnNK6x9uoffA2mfKeu8LXj1PQAEZeqanWWUioPJe8HQIXsX+pJkrlrbo J0lQ== X-Gm-Message-State: ALoCoQkHbV+JWm4gCP2dzAEFCMkt9furL5KQRS+Yb7lggsHsMOIaV3b7x0fqj6V3kbz4FCExHZ/m X-Received: by 10.112.253.135 with SMTP id aa7mr18801104lbd.11.1436795045530; Mon, 13 Jul 2015 06:44:05 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.87.164 with SMTP id az4ls1382306lab.16.gmail; Mon, 13 Jul 2015 06:44:05 -0700 (PDT) X-Received: by 10.112.13.166 with SMTP id i6mr4748323lbc.50.1436795045380; Mon, 13 Jul 2015 06:44:05 -0700 (PDT) Received: from mail-la0-f42.google.com (mail-la0-f42.google.com. [209.85.215.42]) by mx.google.com with ESMTPS id ms1si15334520lbb.53.2015.07.13.06.44.05 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Jul 2015 06:44:05 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) client-ip=209.85.215.42; Received: by lagw2 with SMTP id w2so14736818lag.3 for ; Mon, 13 Jul 2015 06:44:05 -0700 (PDT) X-Received: by 10.112.220.7 with SMTP id ps7mr32178269lbc.72.1436795045282; Mon, 13 Jul 2015 06:44:05 -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 hn6csp1741119lbb; Mon, 13 Jul 2015 06:44:03 -0700 (PDT) X-Received: by 10.140.93.199 with SMTP id d65mr52662819qge.27.1436795042733; Mon, 13 Jul 2015 06:44:02 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id a27si10307187qka.8.2015.07.13.06.43.59; Mon, 13 Jul 2015 06:44:02 -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 903C661CF6; Mon, 13 Jul 2015 13:43:59 +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 6410961CC6; Mon, 13 Jul 2015 13:43:53 +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 B252461CCB; Mon, 13 Jul 2015 13:43:51 +0000 (UTC) Received: from mail-wi0-f170.google.com (mail-wi0-f170.google.com [209.85.212.170]) by lists.linaro.org (Postfix) with ESMTPS id DA16C61CA2 for ; Mon, 13 Jul 2015 13:43:50 +0000 (UTC) Received: by widic2 with SMTP id ic2so12796097wid.0 for ; Mon, 13 Jul 2015 06:43:50 -0700 (PDT) X-Received: by 10.194.23.167 with SMTP id n7mr41335232wjf.112.1436795030149; Mon, 13 Jul 2015 06:43:50 -0700 (PDT) Received: from localhost.localdomain ([90.152.119.35]) by smtp.googlemail.com with ESMTPSA id dz4sm14713984wib.17.2015.07.13.06.43.48 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 13 Jul 2015 06:43:49 -0700 (PDT) From: Zoltan Kiss To: lng-odp@lists.linaro.org Date: Mon, 13 Jul 2015 14:43:27 +0100 Message-Id: <1436795007-16158-1-git-send-email-zoltan.kiss@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1436551839-27798-1-git-send-email-zoltan.kiss@linaro.org> References: <1436551839-27798-1-git-send-email-zoltan.kiss@linaro.org> X-Topics: patch Cc: Petri Savolainen Subject: [lng-odp] [API-NEXT PATCH v8] 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.42 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 --- v5: fix array use in last hunk v6: handle negative 'ret' in last hunk v7: refactor all hunks to similar than last one v8: fix pktio_txrx_multi and the commit message test/performance/odp_pktio_perf.c | 10 +++++++++- test/performance/odp_scheduling.c | 8 ++++++-- test/validation/pktio/pktio.c | 3 +++ test/validation/queue/queue.c | 4 ++++ 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/test/performance/odp_pktio_perf.c b/test/performance/odp_pktio_perf.c index f4d9d2d..c2e95fb 100644 --- a/test/performance/odp_pktio_perf.c +++ b/test/performance/odp_pktio_perf.c @@ -270,12 +270,20 @@ 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 i; + if (num_pkts == 0) return 0; else if (num_pkts == 1) return odp_queue_enq(outq, event_tbl[0]) == 0 ? 1 : 0; - return odp_queue_enq_multi(outq, event_tbl, num_pkts); + ret = odp_queue_enq_multi(outq, event_tbl, num_pkts); + i = ret < 0 ? 0 : ret; + for ( ; i < num_pkts; i++) + odp_event_free(event_tbl[i]); + return ret; + } /* diff --git a/test/performance/odp_scheduling.c b/test/performance/odp_scheduling.c index 99f0f9b..a9ebfaa 100644 --- a/test/performance/odp_scheduling.c +++ b/test/performance/odp_scheduling.c @@ -530,9 +530,13 @@ 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) { + num = odp_queue_enq_multi(queue, ev, MULTI_BUFS_MAX); + if (num != MULTI_BUFS_MAX) { LOG_ERR(" [%i] Queue enqueue failed.\n", thr); + j = num < 0 ? 0 : num; + for ( ; j < MULTI_BUFS_MAX; j++) + odp_event_free(ev[j]); + return -1; } } diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c index 82ced5c..d603b27 100644 --- a/test/validation/pktio/pktio.c +++ b/test/validation/pktio/pktio.c @@ -388,6 +388,9 @@ 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"); + i = ret < 0 ? 0 : ret; + for ( ; i < num_pkts; i++) + odp_packet_free(tx_pkt[i]); return; } } diff --git a/test/validation/queue/queue.c b/test/validation/queue/queue.c index f686b71..96dc932 100644 --- a/test/validation/queue/queue.c +++ b/test/validation/queue/queue.c @@ -88,6 +88,10 @@ static void queue_test_sunnydays(void) */ ret = odp_queue_enq_multi(queue_id, enev, MAX_BUFFER_QUEUE); CU_ASSERT(MAX_BUFFER_QUEUE == ret); + i = ret < 0 ? 0 : ret; + for ( ; i < MAX_BUFFER_QUEUE; i++) + odp_event_free(enev[i]); + pev_tmp = deev; do { deq_ret = odp_queue_deq_multi(queue_id, pev_tmp,