diff options
author | Matt Ranostay <matt.ranostay@konsulko.com> | 2017-09-16 16:39:10 -0700 |
---|---|---|
committer | Matt Ranostay <matt.ranostay@konsulko.com> | 2017-09-16 21:14:08 -0700 |
commit | 7a7d1224cff19d5c6ebdc8e87df39234d7974a20 (patch) | |
tree | e2b4312d2d75b9ec4185f0377e67f0105406732e /binding | |
parent | 23f768d1b68ae83d927615057b2c1c9c4d3f88a2 (diff) |
binding: gps: add gpsd.socket race condition fix
Try up to 5 times with a 2500 ms interval to read data after
a subscription to gpsd stream. This assures an initial connection
to the gpsd.socket is in a known state.
Bug-AGL: SPEC-832
Change-Id: Ice74c8372e2f592a353f1bd43ddde7d447ab0c8d
Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
Diffstat (limited to 'binding')
-rw-r--r-- | binding/afm-gps-binding.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/binding/afm-gps-binding.c b/binding/afm-gps-binding.c index ffc787b..7fbd907 100644 --- a/binding/afm-gps-binding.c +++ b/binding/afm-gps-binding.c @@ -183,7 +183,7 @@ static void *data_poll(void *ptr) static int init() { const char *host, *port; - int ret; + int ret, tries = 5; location_event = afb_daemon_make_event("location"); @@ -196,6 +196,11 @@ static int init() gps_stream(&data, WATCH_ENABLE | WATCH_JSON, NULL); + // due to the gpsd.socket race condition need to loop till initial event + do { + gps_read(&data); + } while (!gps_waiting(&data, MSECS_TO_USECS(2500)) && tries--); + return pthread_create(&thread, NULL, &data_poll, NULL); } |