From patchwork Tue Apr 5 08:03:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Milard X-Patchwork-Id: 65057 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp294409lbc; Tue, 5 Apr 2016 00:04:23 -0700 (PDT) X-Received: by 10.140.100.225 with SMTP id s88mr27234099qge.35.1459839863276; Tue, 05 Apr 2016 00:04:23 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id d51si25178408qga.77.2016.04.05.00.04.22; Tue, 05 Apr 2016 00:04:23 -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 85E1B6195F; Tue, 5 Apr 2016 07:04:22 +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 BD2BA61958; Tue, 5 Apr 2016 07:04:17 +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 491926195B; Tue, 5 Apr 2016 07:04:15 +0000 (UTC) Received: from mail-lf0-f53.google.com (mail-lf0-f53.google.com [209.85.215.53]) by lists.linaro.org (Postfix) with ESMTPS id 2C0C0618E3 for ; Tue, 5 Apr 2016 07:04:11 +0000 (UTC) Received: by mail-lf0-f53.google.com with SMTP id e190so1685696lfe.0 for ; Tue, 05 Apr 2016 00:04:11 -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=M+QFadIIXZq1/UO0gVNdeSTXm3z/LPBSo23CDG7HS44=; b=EdOdT9mCIciFaXSpPkGflJfz0ci4n7o1SacyjitGjNz1gaIA23hGJfNC7H4Nmsxakb yUe0JLBzG/qrjIhr4yP0hZd2Qm4CKZWY4UsVtftwB0591Cexapf/vBu1YNBYBBTxfHLt yVviiRsnWzxTXsBf5j5khDERr0MLnEPvqMV9txJMpxYn6mvLWY/wnVdTjkJcamkvnVlu DIeWJGhhFdX5T9aKovSlIIST7Lom1UBu2yEPLphX00ITu303IqIVo3uMq7dU5O9VHunr 1sFsUjc6yhui8VXV8ilCTce/9Rh/F2OPrpOJ7w99jiO/f0x7yTTPALGrEpzu1O4Iwu64 DY2A== X-Gm-Message-State: AD7BkJKfV3TVk4rx36JRVoQ3B2u6oqqqIijKyYLamVUCIFUR6+HTOiYFxEHaiqM3KPndSP+Pfcg= X-Received: by 10.25.218.1 with SMTP id r1mr4630242lfg.130.1459839849744; Tue, 05 Apr 2016 00:04:09 -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 r191sm5510394lfe.28.2016.04.05.00.04.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 05 Apr 2016 00:04:08 -0700 (PDT) From: Christophe Milard To: anders.roxell@linaro.org, mike.holmes@linaro.org, maxim.uvarov@linaro.org Date: Tue, 5 Apr 2016 10:03:28 +0200 Message-Id: <1459843408-44840-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] [PATCHv5] 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 v4: test after loop (Maxim) 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 | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/platform/linux-generic/test/shmem/shmem_linux.c b/platform/linux-generic/test/shmem/shmem_linux.c index 12266cc..5a9be4d 100644 --- a/platform/linux-generic/test/shmem/shmem_linux.c +++ b/platform/linux-generic/test/shmem/shmem_linux.c @@ -50,6 +50,7 @@ #define ODP_APP_NAME "shmem_odp" /* name of the odp program, in this dir */ #define DEVNAME_FMT "odp-%d-%s" /* shm device format: odp-- */ +#define MAX_FIFO_WAIT 30 /* Max time waiting for the fifo (sec) */ void test_success(char *fifo_name, int fd, pid_t odp_app) { @@ -89,7 +90,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 +116,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 < MAX_FIFO_WAIT; nb_sec++) { + fifo_fd = open(fifo_name, O_WRONLY); + if (fifo_fd >= 0) + break; sleep(1); - if (nb_sec++ == 30) - exit(1); } - fifo_fd = open(fifo_name, O_WRONLY); + if (nb_sec >= MAX_FIFO_WAIT) + exit(1); printf("pipe found\n"); /* the linux named pipe has now been found, meaning that the