aboutsummaryrefslogtreecommitdiffstats
path: root/binding
diff options
context:
space:
mode:
Diffstat (limited to 'binding')
-rw-r--r--binding/afm-gps-binding.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/binding/afm-gps-binding.c b/binding/afm-gps-binding.c
index d09765a..873c264 100644
--- a/binding/afm-gps-binding.c
+++ b/binding/afm-gps-binding.c
@@ -265,13 +265,18 @@ static void add_record(json_object *jresp)
static void *data_poll(void *ptr)
{
+ int tries = 0;
+
/*
* keep reading till an error condition happens
*/
- while (gps_waiting(&data, MSECS_TO_USECS(2000)) && !errno)
- {
+ while (tries < 60) {
json_object *jresp = NULL;
+ if (gps_waiting(&data, MSECS_TO_USECS(2000)) < 0) {
+ tries++;
+ continue;
+ }
pthread_mutex_lock(&mutex);
if (gps_read(&data) == -1) {
AFB_ERROR("Cannot read from GPS daemon.\n");