summaryrefslogtreecommitdiff
path: root/ntpshmread.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2015-03-03 16:27:15 -0500
committerEric S. Raymond <esr@thyrsus.com>2015-03-03 16:27:15 -0500
commit8745b767d8b8b4a5e4261a636b128df54f2bd02c (patch)
tree1e37593f1a32fa4ce343a428449ef2965379857a /ntpshmread.c
parentc93e0c28dfd8165d8ac66e04139f2111109acaa6 (diff)
downloadgpsd-8745b767d8b8b4a5e4261a636b128df54f2bd02c.tar.gz
Tell ntpshhmon to merely snoop SHM updates, not consume them.
Diffstat (limited to 'ntpshmread.c')
-rw-r--r--ntpshmread.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/ntpshmread.c b/ntpshmread.c
index 7a9206e3..33f9c8e5 100644
--- a/ntpshmread.c
+++ b/ntpshmread.c
@@ -58,7 +58,7 @@ char *shm_name(const int unit)
}
/*@+statictrans@*/
-enum segstat_t shm_query(/*@null@*/struct shmTime *shm_in, /*@out@*/struct shm_stat_t *shm_stat)
+enum segstat_t shm_query(/*@null@*/struct shmTime *shm_in, /*@out@*/struct shm_stat_t *shm_stat, const bool consume)
/* try to grab a sample from the specified SHM segment */
{
volatile struct shmTime shmcopy, *shm = shm_in;
@@ -91,7 +91,14 @@ enum segstat_t shm_query(/*@null@*/struct shmTime *shm_in, /*@out@*/struct shm_s
*/
memory_barrier();
memcpy((void *)&shmcopy, (void *)shm, sizeof(struct shmTime));
- shm->valid = 0;
+
+ /*
+ * An update consumer such as ntp should zero the valid flag at this point.
+ * A program snooping the updates to collect statistics should not, lest
+ * it make the data unavailable for consumers.
+ */
+ if (consume)
+ shm->valid = 0;
memory_barrier();
/*