From patchwork Mon Apr 4 10:31:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Milard X-Patchwork-Id: 64981 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp1080995lbc; Mon, 4 Apr 2016 02:32:38 -0700 (PDT) X-Received: by 10.55.78.207 with SMTP id c198mr32100593qkb.34.1459762358657; Mon, 04 Apr 2016 02:32:38 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id h206si21632331qhd.62.2016.04.04.02.32.38; Mon, 04 Apr 2016 02:32:38 -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 2570E61653; Mon, 4 Apr 2016 09:32:38 +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, 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 16232615AE; Mon, 4 Apr 2016 09:32:34 +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 E3A2E615C9; Mon, 4 Apr 2016 09:32:31 +0000 (UTC) Received: from mail-lf0-f48.google.com (mail-lf0-f48.google.com [209.85.215.48]) by lists.linaro.org (Postfix) with ESMTPS id E4DE8611FB for ; Mon, 4 Apr 2016 09:32:29 +0000 (UTC) Received: by mail-lf0-f48.google.com with SMTP id g184so86354557lfb.3 for ; Mon, 04 Apr 2016 02:32: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:from:to:cc:subject:date:message-id; bh=neOpZtW/XhfPxz8oEEriRVigKFgFYx4M6bkpuZbq4wI=; b=LEoPn7xEZybzjhlrMCw+Cd2ds995t17r490dEq8zbPXnU4D9u4uIM0DgZ54/Tk8PA+ grWjLq9V1oSDgCtOQWJWtuW+IlDcgCVoTxsPT9CAMlQKLafNUY7h7sxoEjnUE2qf226m 54sj1F0mBAPlsDf2pfms8BhmJUF/78rsYhDcYQufG68OpPrPUNXI3TOMAU/D9saofzI1 1aRg5HH6rE4kiRRc+V+80Wy4qVSnpJ79aQ0vMcEpTWDwiyQAO1uZG+JjcnHsVtpwoZ/j C7zxsBgHNumAHS2+iKNYVLxMEEQd/XvLjHOBdDRaBf2MVtFICcjPhtiLYdbALScnith5 6bRQ== X-Gm-Message-State: AD7BkJKjDUQelbA3AyOVB0ZYiloDXXugF6akDDo4+zjrK0eFik9arI5p59+xbRHI/MuxmlZj+T8= X-Received: by 10.25.44.195 with SMTP id s186mr4605633lfs.81.1459762348129; Mon, 04 Apr 2016 02:32:28 -0700 (PDT) Received: from erachmi-ericsson.ki.sw.ericsson.se (c-83-233-90-46.cust.bredband2.com. [83.233.90.46]) by smtp.gmail.com with ESMTPSA id tm4sm4612132lbb.42.2016.04.04.02.32.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 04 Apr 2016 02:32:27 -0700 (PDT) From: Christophe Milard To: anders.roxell@linaro.org, mike.holmes@linaro.org, bill.fischofer@linaro.org Date: Mon, 4 Apr 2016 12:31:42 +0200 Message-Id: <1459765902-8179-1-git-send-email-christophe.milard@linaro.org> X-Mailer: git-send-email 2.1.4 X-Topics: patch Cc: lng-odp@lists.linaro.org Subject: [lng-odp] [PATCHv4] linux-generic: test: shmem: atomic check+open fifo 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: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" Fixes: https://bugs.linaro.org/show_bug.cgi?id=2146 (CID 159395) The open system call is directely used to check the presence of the fifo and open it at the same time. Signed-off-by: Christophe Milard --- since v3: nb_sec incremented in loop rather then at test time. (Maxim) since v2: bug URL added (Anders) since v1: changed loop to avoid open() line duplication (Maxim) platform/linux-generic/test/shmem/shmem_linux.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/platform/linux-generic/test/shmem/shmem_linux.c b/platform/linux-generic/test/shmem/shmem_linux.c index 12266cc..770ec90 100644 --- a/platform/linux-generic/test/shmem/shmem_linux.c +++ b/platform/linux-generic/test/shmem/shmem_linux.c @@ -89,7 +89,7 @@ int main(int argc __attribute__((unused)), char *argv[]) { char prg_name[PATH_MAX]; char odp_name[PATH_MAX]; - int nb_sec = 0; + int nb_sec; int size; pid_t odp_app; char *odp_params = NULL; @@ -115,12 +115,14 @@ int main(int argc __attribute__((unused)), char *argv[]) * Just die if time expire as there is no fifo to communicate * through... */ sprintf(fifo_name, FIFO_NAME_FMT, odp_app); - while (access(fifo_name, W_OK) != 0) { + for (nb_sec = 0; ; nb_sec++) { + fifo_fd = open(fifo_name, O_WRONLY); + if (fifo_fd >= 0) + break; sleep(1); - if (nb_sec++ == 30) + if (nb_sec == 30) exit(1); } - fifo_fd = open(fifo_name, O_WRONLY); printf("pipe found\n"); /* the linux named pipe has now been found, meaning that the