From 85eacf584c3e22a0e241fb22686ef1332afac633 Mon Sep 17 00:00:00 2001 From: Ralph Lange Date: Mon, 6 Feb 2006 16:08:04 +0000 Subject: [PATCH] Integrating change by Malcolm Waters: fix for "-c -w 0" hanging forever --- src/catools/caget.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/catools/caget.c b/src/catools/caget.c index 68da24777..f29ff011a 100644 --- a/src/catools/caget.c +++ b/src/catools/caget.c @@ -14,6 +14,9 @@ * * Author: Ralph Lange (BESSY) * + * Modification History + * 2006/01/17 Malcolm Walters (Tessella/Diamond Light Source) + * Fixed problem with "-c -w 0" hanging forever */ #include @@ -208,14 +211,22 @@ int caget (pv *pvs, int nPvs, RequestT request, OutputT format, if (request == callback) /* Also wait for callbacks */ { - double slice = caTimeout / PEND_EVENT_SLICES; - for (n = 0; n < PEND_EVENT_SLICES; n++) + if (caTimeout != 0) { - ca_pend_event(slice); - if (nRead >= nConn) break; + double slice = caTimeout / PEND_EVENT_SLICES; + for (n = 0; n < PEND_EVENT_SLICES; n++) + { + ca_pend_event(slice); + if (nRead >= nConn) break; + } + if (nRead < nConn) + fprintf(stderr, "Read operation timed out: some PV data was not read.\n"); + } else { + /* For 0 timeout keep waiting until all are done */ + while (nRead < nConn) { + ca_pend_event(1.0); + } } - if (nRead < nConn) - fprintf(stderr, "Read operation timed out: some PV data was not read.\n"); } /* Print the data */