~dobey/redshift/packaging-dailies

« back to all changes in this revision

Viewing changes to patches/retry-geoclue.patch

  • Committer: Rodney Dawes
  • Date: 2017-08-19 17:08:18 UTC
  • Revision ID: dobey@wayofthemonkey.com-20170819170818-h4ufobn0zrm56buf
Remove obsolete patches.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
=== modified file 'src/location-geoclue.c'
2
 
--- old/src/location-geoclue.c  2015-08-04 12:01:37 +0000
3
 
+++ new/src/location-geoclue.c  2015-12-28 19:39:58 +0000
4
 
@@ -20,6 +20,7 @@
5
 
 #include <stdio.h>
6
 
 #include <stdlib.h>
7
 
 #include <string.h>
8
 
+#include <unistd.h>
9
 
 
10
 
 #include <geoclue/geoclue-master.h>
11
 
 #include <geoclue/geoclue-position.h>
12
 
@@ -192,13 +193,24 @@ location_geoclue_get_location(location_g
13
 
        GError *error = NULL;
14
 
        double latitude = 0, longitude = 0;
15
 
 
16
 
-       fields = geoclue_position_get_position(state->position, NULL,
17
 
-                                              &latitude, &longitude, NULL,
18
 
-                                              NULL, &error);
19
 
-       if (error) {
20
 
-               g_printerr(_("Could not get location: %s.\n"), error->message);
21
 
-               g_error_free(error);
22
 
-               return -1;
23
 
+       /* Retry 3 times because this seems to timeout quite a bit */
24
 
+       int retries = 4;
25
 
+       while(--retries) {
26
 
+               fields = geoclue_position_get_position(state->position, NULL,
27
 
+                       &latitude, &longitude, NULL,
28
 
+                       NULL, &error);
29
 
+               if (error) {
30
 
+                       g_printerr(_("Could not get location: %s.\n"), error->message);
31
 
+                       g_error_free(error);
32
 
+                       return -1;
33
 
+               }
34
 
+               if (fields & GEOCLUE_POSITION_FIELDS_LATITUDE &&
35
 
+                       fields & GEOCLUE_POSITION_FIELDS_LONGITUDE) {
36
 
+                       break;
37
 
+               }
38
 
+               g_warning(_("Could not get location, %d retries left.\n"), retries);
39
 
+               /* Sleep for a while to let  */
40
 
+               usleep(1000000);
41
 
        }
42
 
 
43
 
        if (fields & GEOCLUE_POSITION_FIELDS_LATITUDE &&
44