From patchwork Fri Jul 10 18:10:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zoltan Kiss X-Patchwork-Id: 51050 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 27BCF228E5 for ; Fri, 10 Jul 2015 18:11:30 +0000 (UTC) Received: by lbcjf8 with SMTP id jf8sf1784351lbc.0 for ; Fri, 10 Jul 2015 11:11:29 -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=k1vYDnaxZtsXdR13VfzgknysY5N44La39VVe3CF/GWc=; b=LeKKDML/36xyu2RSkNLG6Fm9zKrdxUNjp72RAsJvzxdBwM7eIV/jrgXWo6jMusGuXs hMZyFpS4kNBpUi2zoAlEfEFcuhzMWOwnR3edtWhF0RymFu+YUlveIi28cygbkcO2GO34 00QGa71kFdxoQbvCFeM5Z5IFCTtJJAOiAMhcG84jj/Nl0C+K5ZJ+z26ns8W4Raf6dZS6 rFVQQjk3PIE6+EqcH0V9A2IZpgG7vVxyvOV+iBlQIM66Hp5a7mYQUKtp04L9xToZxrA6 jw6mnRgZ4zTqeWJOOwVdF2gtYrPE70Yi/0ZdsTjpFZi4NlE9IaG5EPp/YWFBS8HOtMiA qQcg== X-Gm-Message-State: ALoCoQlBvniG2MnDHODkFvNbgqrVEep/dAPjUBDy9z8WKF6yEPDVUGmrRFy4kKLTGJbNyi0H8jOq X-Received: by 10.112.181.37 with SMTP id dt5mr11352397lbc.10.1436551889099; Fri, 10 Jul 2015 11:11:29 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.21.230 with SMTP id y6ls1368887lae.20.gmail; Fri, 10 Jul 2015 11:11:28 -0700 (PDT) X-Received: by 10.152.170.234 with SMTP id ap10mr21169825lac.28.1436551888947; Fri, 10 Jul 2015 11:11:28 -0700 (PDT) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com. [209.85.215.44]) by mx.google.com with ESMTPS id jm1si8245573lbc.84.2015.07.10.11.11.28 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Jul 2015 11:11:28 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by lagx9 with SMTP id x9so269804959lag.1 for ; Fri, 10 Jul 2015 11:11:28 -0700 (PDT) X-Received: by 10.152.36.102 with SMTP id p6mr20961928laj.19.1436551888630; Fri, 10 Jul 2015 11:11:28 -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 hn6csp151129lbb; Fri, 10 Jul 2015 11:11:27 -0700 (PDT) X-Received: by 10.55.41.229 with SMTP id p98mr8622855qkp.99.1436551887232; Fri, 10 Jul 2015 11:11:27 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id p25si10926052qkh.85.2015.07.10.11.10.57; Fri, 10 Jul 2015 11:11:27 -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 033B061D81; Fri, 10 Jul 2015 18:10:56 +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 6153861B53; Fri, 10 Jul 2015 18:10:54 +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 81E7461B53; Fri, 10 Jul 2015 18:10:52 +0000 (UTC) Received: from mail-wg0-f51.google.com (mail-wg0-f51.google.com [74.125.82.51]) by lists.linaro.org (Postfix) with ESMTPS id 855C06108E for ; Fri, 10 Jul 2015 18:10:51 +0000 (UTC) Received: by wgxm20 with SMTP id m20so72197412wgx.3 for ; Fri, 10 Jul 2015 11:10:50 -0700 (PDT) X-Received: by 10.180.231.40 with SMTP id td8mr212292wic.9.1436551850794; Fri, 10 Jul 2015 11:10:50 -0700 (PDT) Received: from localhost.localdomain ([90.152.119.35]) by smtp.googlemail.com with ESMTPSA id wx9sm14680922wjb.6.2015.07.10.11.10.49 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 10 Jul 2015 11:10:50 -0700 (PDT) From: Zoltan Kiss To: lng-odp@lists.linaro.org Date: Fri, 10 Jul 2015 19:10:39 +0100 Message-Id: <1436551839-27798-1-git-send-email-zoltan.kiss@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1436378469-20444-1-git-send-email-zoltan.kiss@linaro.org> References: <1436378469-20444-1-git-send-email-zoltan.kiss@linaro.org> X-Topics: patch Cc: Petri Savolainen Subject: [lng-odp] [API-NEXT PATCH v7] 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.44 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 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..283dd92 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_ev[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,