summaryrefslogtreecommitdiff
path: root/ntpshmread.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2015-02-25 05:42:50 -0500
committerEric S. Raymond <esr@thyrsus.com>2015-02-25 05:42:50 -0500
commit7e62d2edf0caa0d83db0786b22c1a43aff5ebc6c (patch)
tree73e1d1cb2cf9641195852047211d6150b8535924 /ntpshmread.c
parent352b62f793892590fb61cfe8395c2e09b44fe3eb (diff)
downloadgpsd-7e62d2edf0caa0d83db0786b22c1a43aff5ebc6c.tar.gz
ntpmon code polishing.
Diffstat (limited to 'ntpshmread.c')
-rw-r--r--ntpshmread.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/ntpshmread.c b/ntpshmread.c
index 6ee03552..c6fc06fc 100644
--- a/ntpshmread.c
+++ b/ntpshmread.c
@@ -3,6 +3,7 @@
* This file is Copyright (c) 2010 by the GPSD project
* BSD terms apply: see the file COPYING in the distribution root for details.
*
+ * Some of this was swiped from the NTPD distribution.
*/
#include <string.h>
#include <stdbool.h>
@@ -68,9 +69,12 @@ enum segstat_t shm_query(struct shmTime *shm_in, struct shm_stat_t *shm_stat)
shm_stat->now = 0;
time(&shm_stat->now);
- if (shm == NULL)
+ if (shm == NULL) {
+ shm_stat->mode = NO_SEGMENT;
return NO_SEGMENT;
+ }
if (!shm->valid) {
+ shm_stat->mode = NOT_READY;
return NOT_READY;
}
@@ -115,6 +119,7 @@ enum segstat_t shm_query(struct shmTime *shm_in, struct shm_stat_t *shm_stat)
shm_stat->tvt.tv_nsec = shm->clockTimeStampUSec * 1000;
cns_new = shm->clockTimeStampNSec;
if (cnt != shm->count) {
+ shm_stat->mode = CLASH;
return CLASH;
}
@@ -133,11 +138,14 @@ enum segstat_t shm_query(struct shmTime *shm_in, struct shm_stat_t *shm_stat)
break;
default:
+ shm_stat->mode = BAD_MODE;
return BAD_MODE;
+ break;
}
shm->valid = 0;
shm_stat->leap = shm->leap;
+ shm_stat->mode = OK;
return OK;
}