From 37fc5df25417b632fab33d81e376b0c59ec2c976 Mon Sep 17 00:00:00 2001 From: Georg Reinke Date: Fri, 28 Jul 2017 12:15:56 +0200 Subject: [PATCH] add polling loop inside shmem_read --- lib/nodes/shmem.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/nodes/shmem.c b/lib/nodes/shmem.c index f98649bfd..1fcbc6054 100644 --- a/lib/nodes/shmem.c +++ b/lib/nodes/shmem.c @@ -110,14 +110,15 @@ int shmem_read(struct node *n, struct sample *smps[], unsigned cnt) int recv; struct sample *shared_smps[cnt]; - recv = shmem_int_read(&shm->intf, shared_smps, cnt); - if (recv < 0) + do { + recv = shmem_int_read(&shm->intf, shared_smps, cnt); + } while (recv == 0); + if (recv < 0) { /* This can only really mean that the other process has exited, so close * the interface to make sure the shared memory object is unlinked */ shmem_int_close(&shm->intf); - - if (recv <= 0) return recv; + } sample_copy_many(smps, shared_smps, recv); sample_put_many(shared_smps, recv);