Message ID | 1459272658-22667-1-git-send-email-christophe.milard@linaro.org |
---|---|
State | New |
Headers | show |
On 03/29/16 20:30, Christophe Milard wrote: > Fix for bug 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> > --- > platform/linux-generic/test/shmem/shmem_linux.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/platform/linux-generic/test/shmem/shmem_linux.c b/platform/linux-generic/test/shmem/shmem_linux.c > index 12266cc..be39e8a 100644 > --- a/platform/linux-generic/test/shmem/shmem_linux.c > +++ b/platform/linux-generic/test/shmem/shmem_linux.c > @@ -115,12 +115,13 @@ 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) { > + fifo_fd = open(fifo_name, O_WRONLY); > + while (fifo_fd < 0) { > sleep(1); > if (nb_sec++ == 30) > exit(1); > + fifo_fd = open(fifo_name, O_WRONLY); > } I think it's better to not duplicate code ofr open() for(nb_sec = 0; nb_sec < 30; nb_sec++) { fifo_fd = open(); if (fifo_fb) break sleep(1); } 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..be39e8a 100644 --- a/platform/linux-generic/test/shmem/shmem_linux.c +++ b/platform/linux-generic/test/shmem/shmem_linux.c @@ -115,12 +115,13 @@ 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) { + fifo_fd = open(fifo_name, O_WRONLY); + while (fifo_fd < 0) { sleep(1); if (nb_sec++ == 30) exit(1); + fifo_fd = open(fifo_name, O_WRONLY); } - fifo_fd = open(fifo_name, O_WRONLY); printf("pipe found\n"); /* the linux named pipe has now been found, meaning that the
Fix for bug 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> --- platform/linux-generic/test/shmem/shmem_linux.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)