[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] branch master updated: towards bettwe nss handling
From: |
gnunet |
Subject: |
[gnunet] branch master updated: towards bettwe nss handling |
Date: |
Sat, 09 May 2020 23:41:02 +0200 |
This is an automated email from the git hooks/post-receive script.
martin-schanzenbach pushed a commit to branch master
in repository gnunet.
The following commit(s) were added to refs/heads/master by this push:
new 2cd529519 towards bettwe nss handling
2cd529519 is described below
commit 2cd529519d3f9d5034ed222536f8c79ef9e6b86d
Author: Schanzenbach, Martin <address@hidden>
AuthorDate: Sat May 9 23:35:32 2020 +0200
towards bettwe nss handling
---
src/gns/nss/nss_gns_query.c | 48 +++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 46 insertions(+), 2 deletions(-)
diff --git a/src/gns/nss/nss_gns_query.c b/src/gns/nss/nss_gns_query.c
index 77ad3a358..7f6bef90d 100644
--- a/src/gns/nss/nss_gns_query.c
+++ b/src/gns/nss/nss_gns_query.c
@@ -61,12 +61,15 @@ gns_resolve_name (int af, const char *name, struct userdata
*u)
char line[128];
int ret;
int out[2];
+ int tried_arm_start = 0;
pid_t pid;
if (0 == getuid ())
return -2; /* GNS via NSS is NEVER for root */
if (0 != pipe (out))
return -1;
+
+query_gns:
pid = fork ();
if (-1 == pid)
return -1;
@@ -138,15 +141,56 @@ gns_resolve_name (int af, const char *name, struct
userdata *u)
}
(void) fclose (p);
waitpid (pid, &ret, 0);
+
if (! WIFEXITED (ret))
return -1;
if (4 == WEXITSTATUS (ret))
return -2; /* not for GNS */
- if (3 == ret)
- return -3; /* timeout -> not found */
+ if ((3 == ret) &&
+ (1 != tried_arm_start))
+ return -3; /* timeout -> try restart */
+ if ((3 == ret) &&
+ (1 == tried_arm_start))
+ return -2; /* timeout -> service unavailable */
if ((2 == WEXITSTATUS (ret)) || (1 == WEXITSTATUS (ret)))
return -2; /* launch failure -> service unavailable */
return 0;
+
+ pid = fork ();
+ if (-1 == pid)
+ return -1;
+ if (0 == pid)
+ {
+ char *argv[] = { "gnunet-arm",
+ "-s", /* Raw output for easier parsing */
+ NULL };
+
+ (void) close (STDOUT_FILENO);
+ if ((0 != close (out[0])) ||
+ (STDOUT_FILENO != dup2 (out[1], STDOUT_FILENO)))
+ _exit (1);
+ (void) execvp ("gnunet-arm", argv);
+ _exit (1);
+ }
+ (void) close (out[1]);
+ p = fdopen (out[0], "r");
+ if (NULL == p)
+ {
+ kwait (pid);
+ return -1;
+ }
+ while (NULL != fgets (line, sizeof(line), p))
+ {
+ /**
+ * Read output
+ */
+ }
+ (void) fclose (p);
+ waitpid (pid, &ret, 0);
+ tried_arm_start = 1;
+ goto query_gns;
+
+
}
--
To stop receiving notification emails like this one, please contact
address@hidden.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnunet] branch master updated: towards bettwe nss handling,
gnunet <=