aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gns/nss/nss_gns_query.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/gns/nss/nss_gns_query.c b/src/gns/nss/nss_gns_query.c
index af5c91b72..11e46ad7f 100644
--- a/src/gns/nss/nss_gns_query.c
+++ b/src/gns/nss/nss_gns_query.c
@@ -60,15 +60,16 @@ gns_resolve_name (int af, const char *name, struct userdata *u)
60 FILE *p; 60 FILE *p;
61 char line[128]; 61 char line[128];
62 int ret; 62 int ret;
63 int retry = 0;
63 int out[2]; 64 int out[2];
64 pid_t pid; 65 pid_t pid;
65 66
66 if (0 == getuid ()) 67 if (0 == getuid ())
67 return -2; /* GNS via NSS is NEVER for root */ 68 return -2; /* GNS via NSS is NEVER for root */
68 if (0 != pipe (out))
69 return -1;
70 69
71query_gns: 70query_gns:
71 if (0 != pipe (out))
72 return -1;
72 pid = fork (); 73 pid = fork ();
73 if (-1 == pid) 74 if (-1 == pid)
74 return -1; 75 return -1;
@@ -140,21 +141,23 @@ query_gns:
140 } 141 }
141 (void) fclose (p); 142 (void) fclose (p);
142 waitpid (pid, &ret, 0); 143 waitpid (pid, &ret, 0);
143
144 if (! WIFEXITED (ret)) 144 if (! WIFEXITED (ret))
145 return -1; 145 return -1;
146 if (4 == WEXITSTATUS (ret)) 146 if (4 == WEXITSTATUS (ret))
147 return -2; /* not for GNS */ 147 return -2; /* not for GNS */
148 if (5 == WEXITSTATUS (ret)) 148 if (5 == WEXITSTATUS (ret))
149 goto restart_arm; /* timeout -> try restart */ 149 {
150 if (1 == retry)
151 return -2; /* no go -> service unavailable */
152 retry = 1;
153 system("gnunet-arm -s");
154 goto query_gns; /* Try again */
155 }
150 if (3 == WEXITSTATUS (ret)) 156 if (3 == WEXITSTATUS (ret))
151 return -2; /* timeout -> service unavailable */ 157 return -2; /* timeout -> service unavailable */
152 if ((2 == WEXITSTATUS (ret)) || (1 == WEXITSTATUS (ret))) 158 if ((2 == WEXITSTATUS (ret)) || (1 == WEXITSTATUS (ret)))
153 return -2; /* launch failure -> service unavailable */ 159 return -2; /* launch failure -> service unavailable */
154 return 0; 160 return 0;
155restart_arm:
156 system("gnunet-arm -s");
157 goto query_gns;
158} 161}
159 162
160 163