Message ID | 1459765902-8179-1-git-send-email-christophe.milard@linaro.org |
---|---|
State | New |
Headers | show |
On 04/04/16 13:31, Christophe Milard wrote: > 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 <christophe.milard@linaro.org> > --- > 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++) { for (nb_sec = 0; nb_sec < 30 ; 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); > } then just one check after cycle: if (nb_sec == 30) exit(1); no need to test nb_sec in the loop. Maxim. > - fifo_fd = open(fifo_name, O_WRONLY); > printf("pipe found\n"); > > /* the linux named pipe has now been found, meaning that the
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
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 <christophe.milard@linaro.org> --- 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(-)