diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2015-03-03 16:27:15 -0500 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2015-03-03 16:27:15 -0500 |
commit | 8745b767d8b8b4a5e4261a636b128df54f2bd02c (patch) | |
tree | 1e37593f1a32fa4ce343a428449ef2965379857a /ntpshmread.c | |
parent | c93e0c28dfd8165d8ac66e04139f2111109acaa6 (diff) | |
download | gpsd-8745b767d8b8b4a5e4261a636b128df54f2bd02c.tar.gz |
Tell ntpshhmon to merely snoop SHM updates, not consume them.
Diffstat (limited to 'ntpshmread.c')
-rw-r--r-- | ntpshmread.c | 11 |
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(); /* |