summaryrefslogtreecommitdiff
path: root/libgps_shm.c
diff options
context:
space:
mode:
authorGary E. Miller <gem@rellim.com>2015-03-12 12:49:59 -0700
committerGary E. Miller <gem@rellim.com>2015-03-12 12:49:59 -0700
commitcfd75178762a5b8f27c758bb97d8e58c66172c9e (patch)
tree2e7621f765d524707afdf02b35116b431801318d /libgps_shm.c
parent0fc51deea783be9a7dc272972a0141aca3bab227 (diff)
downloadgpsd-cfd75178762a5b8f27c758bb97d8e58c66172c9e.tar.gz
Document SHM and JSON timeout is in uSec. Fix SHM so that is true.
JSON wait was in uSec, but SHM wait was in Sec. Made both uSec and documented three places.
Diffstat (limited to 'libgps_shm.c')
-rw-r--r--libgps_shm.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/libgps_shm.c b/libgps_shm.c
index 90e962c8..bc245bea 100644
--- a/libgps_shm.c
+++ b/libgps_shm.c
@@ -75,9 +75,10 @@ int gps_shm_open(/*@out@*/struct gps_data_t *gpsdata)
bool gps_shm_waiting(const struct gps_data_t *gpsdata, int timeout)
/* check to see if new data has been written */
+/* timeout is in uSec */
{
volatile struct shmexport_t *shared = (struct shmexport_t *)PRIVATE(gpsdata)->shmseg;
- timestamp_t basetime = timestamp();
+ timestamp_t endtime = timestamp() + (((double)timeout)/1000000);;
volatile bool newdata = false;
/* busy-waiting sucks, but there's not really an alternative */
@@ -90,7 +91,7 @@ bool gps_shm_waiting(const struct gps_data_t *gpsdata, int timeout)
memory_barrier();
if (bookend1 == bookend2 && bookend1 > PRIVATE(gpsdata)->tick)
newdata = true;
- if (newdata || (timestamp() - basetime >= (double)timeout))
+ if (newdata || (timestamp() >= endtime))
break;
}