diff options
-rw-r--r-- | gpsd.h-tail | 2 | ||||
-rw-r--r-- | gpxlogger.c | 11 | ||||
-rw-r--r-- | libgps_shm.c | 2 | ||||
-rw-r--r-- | shmexport.c | 6 |
4 files changed, 14 insertions, 7 deletions
diff --git a/gpsd.h-tail b/gpsd.h-tail index bd859e8f..2174d86c 100644 --- a/gpsd.h-tail +++ b/gpsd.h-tail @@ -759,7 +759,7 @@ void cfmakeraw(struct termios *); #define DEVICEHOOKPATH SYSCONFDIR"/gpsd/device-hook" /* memory barriers */ -static inline void barrier(void) { +static /*@unused@*/ inline void barrier(void) { #ifdef __GNUC__ #ifndef S_SPLINT_S asm volatile("sfence"); diff --git a/gpxlogger.c b/gpxlogger.c index 2bab9270..2d6c9a90 100644 --- a/gpxlogger.c +++ b/gpxlogger.c @@ -351,10 +351,15 @@ static int shm_mainloop(void) print_gpx_header(); for (;;) { - (void)gps_shm_read(&gpsdata); - conditionally_log_fix(&gpsdata); + status = gps_shm_read(&gpsdata); + + if (status == -1) + break; + if (status > 0) + conditionally_log_fix(&gpsdata); } - /* (void)gps_shm_close(&gpsdata); */ + (void)gps_shm_close(&gpsdata); + return 0; } /*@+mustfreefresh +compdestroy@*/ diff --git a/libgps_shm.c b/libgps_shm.c index 8c90f524..99457842 100644 --- a/libgps_shm.c +++ b/libgps_shm.c @@ -74,7 +74,7 @@ int gps_shm_read(struct gps_data_t *gpsdata) after = shared->bookend2; /*@i1@*/gpsdata->privdata = shared; - return (before == after) ? 0 : -1; + return (before == after) ? sizeof(struct gps_data_t) : 0; } } diff --git a/shmexport.c b/shmexport.c index 4d615abf..c79d4c08 100644 --- a/shmexport.c +++ b/shmexport.c @@ -63,6 +63,7 @@ void shm_update(struct gps_context_t *context, struct gps_data_t *gpsdata) if (context->shmexport != NULL) { static int tick; + struct shmexport_t *shared = (struct shmexport_t *)context->shmexport; ++tick; /* @@ -76,13 +77,14 @@ void shm_update(struct gps_context_t *context, struct gps_data_t *gpsdata) * start to write the segment during the read, the second bookend will * get clobbered first and the data can be detected as bad. */ - ((struct shmexport_t *)context->shmexport)->bookend2 = tick; + shared->bookend2 = tick; barrier(); memcpy((void *)(context->shmexport + offsetof(struct shmexport_t, gpsdata)), (void *)gpsdata, sizeof(struct gps_data_t)); + shared->gpsdata.gps_fd = -1; barrier(); - ((struct shmexport_t *)context->shmexport)->bookend1 = tick; + shared->bookend1 = tick; } } |