From patchwork Thu Jul 20 20:00:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 108439 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp2558827qge; Thu, 20 Jul 2017 13:01:16 -0700 (PDT) X-Received: by 10.55.54.17 with SMTP id d17mr4939811qka.301.1500580876895; Thu, 20 Jul 2017 13:01:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500580876; cv=none; d=google.com; s=arc-20160816; b=kUEhiEMXfHyjLdjgNsDal6vKzcrl8SbJfAnYmFgfcdKIcm+RExvxiobaVKIqoburIl NX3sFkw8LLwXaDtcEVR+3snYZ3ulmJl+svrgbUwaSAlZDbUHKkisoc6DDheS4hsjkE6c cL5fmuNqRe+g3jRMDy1EIUJqwnCp85KZLfKc0PISOAb7MG49GV8QwvsRr6a398tEUDqJ kFLxDDzB2xWgU3wHztN3z0vBubud6c3HxN5MOV92oeE3P6lusIJGldFMbfHPE9lU9RMe vprcQV8htl6V3N6sRnf5Q9JJAjed2hegtUP8G3omzn8pqD7T8ZfbT4DFehuXph9zUjwO 2SoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=d4PlQWTSOjNm4lzimECLWfXPaeY0PKwwBuO1ViZSioY=; b=kc5UmJjEPyemVR7kD/ZzK9K+aiSW2naxxehNFcs/8cYDSzoGuaMLqzwLzBB6ZaisZR rt2i6YHsEj6086V8jRUbViC4n1cEbe+/dpVO/Da0e0IIFUb9pVxQWyb2fYZ2fBdkrckE x4izhsWKO+Fi6EvXP6qno+7N7DLnOQdvCsz0zyQnKJqGcYmktCG0IytFgMeR05A2gl0V nYUDr92dqnJdI33KufOv06wG8+IaCPuXfxDIxeFnk1VE60zz9pRBGA5I6PYv4AKqcZvo K1rxlVy3k8KVtX56FXSv8F93hjLrV9HHesNZXuYr/3f5ztMG3xGGCC8Duabw9JR/IWYy e44Q== ARC-Authentication-Results: i=1; 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=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id w194si2452127qka.445.2017.07.20.13.01.16; Thu, 20 Jul 2017 13:01:16 -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=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 78E6565BB7; Thu, 20 Jul 2017 20:01:16 +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,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,URIBL_BLOCKED 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 CB7D1609D2; Thu, 20 Jul 2017 20:00:32 +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 9B420644E6; Thu, 20 Jul 2017 20:00:26 +0000 (UTC) Received: from forward4p.cmail.yandex.net (forward4p.cmail.yandex.net [77.88.31.19]) by lists.linaro.org (Postfix) with ESMTPS id 0732B644DA for ; Thu, 20 Jul 2017 20:00:23 +0000 (UTC) Received: from smtp2j.mail.yandex.net (smtp2j.mail.yandex.net [IPv6:2a02:6b8:0:801::ac]) by forward4p.cmail.yandex.net (Yandex) with ESMTP id 0103B20BB8 for ; Thu, 20 Jul 2017 23:00:20 +0300 (MSK) Received: from smtp2j.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp2j.mail.yandex.net (Yandex) with ESMTP id C9D383EC1062 for ; Thu, 20 Jul 2017 23:00:19 +0300 (MSK) Received: by smtp2j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id McormhNb31-0ID0AB5K; Thu, 20 Jul 2017 23:00:18 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) X-Yandex-Suid-Status: 1 0 From: Github ODP bot To: lng-odp@lists.linaro.org Date: Thu, 20 Jul 2017 23:00:15 +0300 Message-Id: <1500580816-25415-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1500580816-25415-1-git-send-email-odpbot@yandex.ru> References: <1500580816-25415-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 83 Subject: [lng-odp] [PATCH v1 1/2] linux-gen: ishm fix defining directory for shm files 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" From: Maxim Uvarov Code missed getenv() return code check and did not use value of env variable to change default derection. Signed-off-by: Maxim Uvarov --- /** Email created from pull request 83 (muvarov:master_shm_dir_fix) ** https://github.com/Linaro/odp/pull/83 ** Patch: https://github.com/Linaro/odp/pull/83.patch ** Base sha: 95ba4b394009d92c29c2e22f0776e90bb4c6edec ** Merge commit sha: a7d94443cbc414cd68dc576b3e3757f65aa9b789 **/ platform/linux-generic/_ishm.c | 15 +++++++++++---- platform/linux-generic/include/odp_internal.h | 1 + 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/platform/linux-generic/_ishm.c b/platform/linux-generic/_ishm.c index cde2dbc3..892e889b 100644 --- a/platform/linux-generic/_ishm.c +++ b/platform/linux-generic/_ishm.c @@ -1442,9 +1442,15 @@ int _odp_ishm_init_global(void) odp_global_data.main_pid = getpid(); odp_global_data.shm_dir = getenv("ODP_SHM_DIR"); - odp_global_data.shm_dir = - calloc(1, sizeof(ISHM_FILENAME_NORMAL_PAGE_DIR)); - sprintf(odp_global_data.shm_dir, "%s", ISHM_FILENAME_NORMAL_PAGE_DIR); + if (odp_global_data.shm_dir) { + odp_global_data.shm_dir_from_env = 1; + } else { + odp_global_data.shm_dir = + calloc(1, sizeof(ISHM_FILENAME_NORMAL_PAGE_DIR)); + sprintf(odp_global_data.shm_dir, "%s", + ISHM_FILENAME_NORMAL_PAGE_DIR); + odp_global_data.shm_dir_from_env = 0; + } ODP_DBG("ishm: using dir %s\n", odp_global_data.shm_dir); @@ -1661,7 +1667,8 @@ int _odp_ishm_term_global(void) if (_odp_ishmphy_unbook_va()) ret |= -1; - free(odp_global_data.shm_dir); + if (!odp_global_data.shm_dir_from_env) + free(odp_global_data.shm_dir); return ret; } diff --git a/platform/linux-generic/include/odp_internal.h b/platform/linux-generic/include/odp_internal.h index dd3374b7..ec17b199 100644 --- a/platform/linux-generic/include/odp_internal.h +++ b/platform/linux-generic/include/odp_internal.h @@ -43,6 +43,7 @@ typedef struct { struct odp_global_data_s { char *shm_dir; /*< directory for odp mmaped files */ + int shm_dir_from_env; /*< overload default with env */ pid_t main_pid; char uid[UID_MAXLEN]; odp_log_func_t log_fn;