From patchwork Mon Apr 20 12:32:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ola Liljedahl X-Patchwork-Id: 47339 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3F04D2121F for ; Mon, 20 Apr 2015 12:32:36 +0000 (UTC) Received: by wiun10 with SMTP id n10sf17692175wiu.1 for ; Mon, 20 Apr 2015 05:32:35 -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: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=4rqxqemtS36vEcI+EmSeRQYjeAoHGv5gOAb26XNphAU=; b=OQD9hcKQYpjbR3s8PgYViCIeYb3eCSWXbUfzbxu1AyzHvOik1GEUAxISLlzo/ZNZsq Cjdt8XES/VwsH3kMpUprmwg9n7DTtvKG98ADmfoMxFdivhnEJTTd5xc+zUep/l4ILYlm hym788qJeMKuk5/Xavpca14tj+CFiqFGurhJZT6BtD71a+bLhcymMLTcyF4zziB5VKnd pDLNahsO5S8tEtRwl/vANVkCX9r7iQcriQnubt2o/o2yCtHRafZfApAcyHn65fVhNot5 UUiW0rdj4YjVOdtD13VnUg/kxpjqkZhVyX6KyaITplnVarQP+szgO5g92l1SyrBjm0z7 5UFw== X-Gm-Message-State: ALoCoQnW0XnYfsGxYp+lKFWAeEKlVylTbfssfyH7w6CYzhgYBiuD/QkRfUo5WAy6NRfHjp2fMZEa X-Received: by 10.112.42.236 with SMTP id r12mr7193211lbl.2.1429533155511; Mon, 20 Apr 2015 05:32:35 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.8.114 with SMTP id q18ls827143laa.8.gmail; Mon, 20 Apr 2015 05:32:35 -0700 (PDT) X-Received: by 10.112.77.234 with SMTP id v10mr15240211lbw.119.1429533155370; Mon, 20 Apr 2015 05:32:35 -0700 (PDT) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com. [209.85.217.182]) by mx.google.com with ESMTPS id v5si14923537laa.2.2015.04.20.05.32.35 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Apr 2015 05:32:35 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.182 as permitted sender) client-ip=209.85.217.182; Received: by lbbqq2 with SMTP id qq2so129083075lbb.3 for ; Mon, 20 Apr 2015 05:32:35 -0700 (PDT) X-Received: by 10.152.87.204 with SMTP id ba12mr15740649lab.35.1429533155250; Mon, 20 Apr 2015 05:32:35 -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.67.65 with SMTP id l1csp1407392lbt; Mon, 20 Apr 2015 05:32:34 -0700 (PDT) X-Received: by 10.140.89.37 with SMTP id u34mr16772263qgd.15.1429533154017; Mon, 20 Apr 2015 05:32:34 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 77si16613807qgf.113.2015.04.20.05.32.33; Mon, 20 Apr 2015 05:32:34 -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 03D9461D0F; Mon, 20 Apr 2015 12:32:32 +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=ham autolearn_force=no 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 E6B9A61CA1; Mon, 20 Apr 2015 12:32: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 4476861CCD; Mon, 20 Apr 2015 12:32:30 +0000 (UTC) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com [209.85.217.182]) by lists.linaro.org (Postfix) with ESMTPS id A33C561CA1 for ; Mon, 20 Apr 2015 12:32:29 +0000 (UTC) Received: by lbbqq2 with SMTP id qq2so129080792lbb.3 for ; Mon, 20 Apr 2015 05:32:28 -0700 (PDT) X-Received: by 10.152.29.133 with SMTP id k5mr15782676lah.78.1429533148424; Mon, 20 Apr 2015 05:32:28 -0700 (PDT) Received: from localhost.localdomain (78-82-118-40.tn.glocalnet.net. [78.82.118.40]) by mx.google.com with ESMTPSA id sv2sm4290408lbb.22.2015.04.20.05.32.27 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 20 Apr 2015 05:32:27 -0700 (PDT) From: Ola Liljedahl To: lng-odp@lists.linaro.org Date: Mon, 20 Apr 2015 14:32:30 +0200 Message-Id: <1429533151-15217-1-git-send-email-ola.liljedahl@linaro.org> X-Mailer: git-send-email 1.9.1 X-Topics: timers patch Subject: [lng-odp] [PATCH] example: timer: clean up prescheduled events 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: ola.liljedahl@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.182 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 Fixes https://bugs.linaro.org/show_bug.cgi?id=1450 Signed-off-by: Ola Liljedahl Reviewed-by: Mike Holmes --- (This document/code contribution attached is provided under the terms of agreement LES-LTM-21309) example/timer/odp_timer_test.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/example/timer/odp_timer_test.c b/example/timer/odp_timer_test.c index 6b60ec4..fd31466 100644 --- a/example/timer/odp_timer_test.c +++ b/example/timer/odp_timer_test.c @@ -79,6 +79,41 @@ struct test_timer { static struct test_timer tt[256]; /** @private test timeout */ +static void free_event(odp_event_t ev) +{ + switch (odp_event_type(ev)) { + case ODP_EVENT_BUFFER: + odp_buffer_free(odp_buffer_from_event(ev)); + break; + case ODP_EVENT_PACKET: + odp_packet_free(odp_packet_from_event(ev)); + break; + case ODP_EVENT_TIMEOUT: + odp_timeout_free(odp_timeout_from_event(ev)); + break; + case ODP_EVENT_CRYPTO_COMPL: + odp_crypto_compl_free(odp_crypto_compl_from_event(ev)); + break; + default: + fprintf(stderr, "Unrecognized event type %d\n", + odp_event_type(ev)); + abort(); + } +} + +/** @private test timeout */ +static void remove_prescheduled_events(void) +{ + odp_event_t ev; + odp_queue_t queue; + odp_schedule_pause(); + while ((ev = odp_schedule(&queue, ODP_SCHED_NO_WAIT)) != + ODP_EVENT_INVALID) { + free_event(ev); + } +} + +/** @private test timeout */ static void test_abs_timeouts(int thr, test_args_t *args) { uint64_t period; @@ -173,6 +208,9 @@ static void test_abs_timeouts(int thr, test_args_t *args) /* Since we have cancelled the timer, there is no timeout event to * return from odp_timer_free() */ (void)odp_timer_free(ttp->tim); + + /* Remove any prescheduled events */ + remove_prescheduled_events(); }