From patchwork Mon Oct 24 09:24:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Milard X-Patchwork-Id: 78897 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp2452178qge; Mon, 24 Oct 2016 01:37:30 -0700 (PDT) X-Received: by 10.107.133.199 with SMTP id p68mr11532182ioi.227.1477298250038; Mon, 24 Oct 2016 01:37:30 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id b15si9785890ioa.150.2016.10.24.01.37.29; Mon, 24 Oct 2016 01:37:30 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 9280760B0F; Mon, 24 Oct 2016 08:37:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 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 autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 4A52061618; Mon, 24 Oct 2016 08:26:59 +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 74E5B61601; Mon, 24 Oct 2016 08:26:46 +0000 (UTC) Received: from mail-lf0-f49.google.com (mail-lf0-f49.google.com [209.85.215.49]) by lists.linaro.org (Postfix) with ESMTPS id 5DA42615C8 for ; Mon, 24 Oct 2016 08:25:04 +0000 (UTC) Received: by mail-lf0-f49.google.com with SMTP id f134so24526200lfg.2 for ; Mon, 24 Oct 2016 01:25:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=KnCOtWHCGt+nbuk675YYG1PTJXKFNq0IMsMWtQCktYg=; b=UGF3z3S94D2z83Vl5FUYUVoGUrD1PJz8lEvXsCcHCrah2W+DcSH0DxFqgqsWiFn9Sn GVJVGDUL+HOFZQ4++OUoTfDvXe3Uwp8diSEAyJsAGB8kl/BDWJWjDeO3sWyU4M6p7Sl4 igGvLFtbwhfor2y8M5mYbTE7nIGcn9oYVL3tet/gCo5xfgaDsF9SiNtlokKTMCDW29OI euUIlcJT4blBSRc12fTEdrtiXRWtilXgKWBX48DZTFCTEeoI5tl6GiW8ZBLCLiw7Tqqz HHZLW2w8yAsdKOavlMe2m9J4BUe8UGqZGpvDN8kP+ot9ZLYMgr9U7HmWQqQrIZofMSWc pGvA== X-Gm-Message-State: ABUngvcKh14yPvQ1lbi7RBYVX2NDdRL8inboJBvfoHpl7fQIOEDC6P3L4sZXAeepVtpLyfYIxdI= X-Received: by 10.25.131.195 with SMTP id f186mr6036101lfd.16.1477297503219; Mon, 24 Oct 2016 01:25:03 -0700 (PDT) Received: from erachmi-ericsson.ki.sw.ericsson.se (c-83-233-76-66.cust.bredband2.com. [83.233.76.66]) by smtp.gmail.com with ESMTPSA id y131sm2849878lfd.26.2016.10.24.01.25.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 24 Oct 2016 01:25:02 -0700 (PDT) From: Christophe Milard To: mike.holmes@linaro.org, bill.fischofer@linaro.org, lng-odp@lists.linaro.org Date: Mon, 24 Oct 2016 11:24:11 +0200 Message-Id: <1477301053-35938-15-git-send-email-christophe.milard@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1477301053-35938-1-git-send-email-christophe.milard@linaro.org> References: <1477301053-35938-1-git-send-email-christophe.milard@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv4 14/16] linux-gen: _ishm: cleaning remaining block at odp_term_global X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" Remaining (forgotten, not freed) blocks are gathered and related files cleaned when odp_term_global() is called. An error message is also issued so the application writters get to know about these blocks Signed-off-by: Christophe Milard --- platform/linux-generic/_ishm.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) -- 2.7.4 diff --git a/platform/linux-generic/_ishm.c b/platform/linux-generic/_ishm.c index 7624eca..11bb316 100644 --- a/platform/linux-generic/_ishm.c +++ b/platform/linux-generic/_ishm.c @@ -1435,12 +1435,28 @@ int _odp_ishm_term_local(void) int _odp_ishm_term_global(void) { int ret = 0; + int index; + ishm_block_t *block; if ((getpid() != odp_global_data.main_pid) || (syscall(SYS_gettid) != getpid())) ODP_ERR("odp_term_global() must be performed by the main " "ODP process!\n."); + /* cleanup possibly non freed memory (and complain a bit): */ + for (index = 0; index < ISHM_MAX_NB_BLOCKS; index++) { + block = &ishm_tbl->block[index]; + if (block->len != 0) { + ODP_ERR("block '%s' (file %s) was never freed " + "(cleaning up...).\n", + block->name, block->filename); + if (block->filename[0] != 0) + unlink(block->filename); + if (block->linkname[0] != 0) + unlink(block->linkname); + } + } + /* perform the last thread terminate which was postponed: */ ret = do_odp_ishm_term_local();