summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNils Gillmann <ng0@n0.is>2018-07-03 06:49:02 +0000
committerNils Gillmann <ng0@n0.is>2018-07-03 06:49:02 +0000
commit061526a35bf19cd71e375ae7eb9dc3b5fd6c711f (patch)
tree29b3783f28375235c19b52a1148031a7b39c7f11
parentc579fa83c2652aac6a093ceeb36854bee3800cbe (diff)
parentbb3371542e3c1fff2c4abb4d2ba3decf925b4352 (diff)
Merge branch 'master' of gnunet.org:gnunet
-rw-r--r--contrib/.gitignore1
-rw-r--r--contrib/Makefile.am11
-rw-r--r--doc/man/Makefile.am1
-rw-r--r--doc/man/gnunet-gns.12
-rw-r--r--doc/man/gnunet-timeout.120
-rw-r--r--po/POTFILES.in1
-rw-r--r--src/gns/gns_api.c7
-rw-r--r--src/gns/gnunet-gns.c10
-rw-r--r--src/gns/nss/nss_gns.c269
-rw-r--r--src/gns/nss/nss_gns_query.c25
-rw-r--r--src/gns/nss/nss_gns_query.h30
-rw-r--r--src/identity/identity_api_lookup.c8
-rw-r--r--src/rps/gnunet-service-rps.c7
-rw-r--r--src/set/gnunet-service-set_intersection.c19
-rw-r--r--src/set/gnunet-service-set_union.c19
-rw-r--r--src/util/.gitignore5
-rw-r--r--src/util/Makefile.am16
-rw-r--r--src/util/client.c13
-rw-r--r--src/util/dnsparser.c9
-rw-r--r--src/util/gnunet-timeout-w32.c (renamed from contrib/timeout_watchdog_w32.c)6
-rw-r--r--src/util/gnunet-timeout.c (renamed from contrib/timeout_watchdog.c)82
21 files changed, 334 insertions, 227 deletions
diff --git a/contrib/.gitignore b/contrib/.gitignore
index 304706d7e..d6ef469ba 100644
--- a/contrib/.gitignore
+++ b/contrib/.gitignore
@@ -2,7 +2,6 @@ gnunet_janitor.py
gnunet_pyexpect.py
pydiffer.py
terminate.py
-timeout_watchdog
gnunet_pyexpect.py
gnunet_pyexpect.pyc
pydiffer.pyc
diff --git a/contrib/Makefile.am b/contrib/Makefile.am
index 158e43998..eec3300b9 100644
--- a/contrib/Makefile.am
+++ b/contrib/Makefile.am
@@ -5,17 +5,6 @@ tap32dir = $(pkgdatadir)/openvpn-tap32/tapw32/
tap64dir = $(pkgdatadir)/openvpn-tap32/tapw64/
-noinst_PROGRAMS = \
- timeout_watchdog
-
-if !MINGW
-timeout_watchdog_SOURCES = \
- timeout_watchdog.c
-else
-timeout_watchdog_SOURCES = \
- timeout_watchdog_w32.c
-endif
-
noinst_SCRIPTS = \
scripts/terminate.py \
scripts/pydiffer.py \
diff --git a/doc/man/Makefile.am b/doc/man/Makefile.am
index a6a116dca..37f881d60 100644
--- a/doc/man/Makefile.am
+++ b/doc/man/Makefile.am
@@ -37,6 +37,7 @@ man_MANS = \
gnunet-statistics.1 \
gnunet-testbed-profiler.1 \
gnunet-testing-run-service.1 \
+ gnunet-timeout.1 \
gnunet-transport.1 \
gnunet-transport-certificate-creation.1 \
gnunet-unindex.1 \
diff --git a/doc/man/gnunet-gns.1 b/doc/man/gnunet-gns.1
index 9466dae03..9e4482653 100644
--- a/doc/man/gnunet-gns.1
+++ b/doc/man/gnunet-gns.1
@@ -46,7 +46,7 @@ Print GNUnet version number.
.SH RETURN VALUE
gnunet\-gns will return 0 on success, 1 on internal failures, 2 on
-launch failures, 3 if the given name is not configured to use GNS.
+launch failures, 4 if the given name is not configured to use GNS.
.SH BUGS
diff --git a/doc/man/gnunet-timeout.1 b/doc/man/gnunet-timeout.1
new file mode 100644
index 000000000..e413254f4
--- /dev/null
+++ b/doc/man/gnunet-timeout.1
@@ -0,0 +1,20 @@
+.TH GNUNET\-TIMOUET 1 "Jun 5, 2018" "GNUnet"
+
+.SH NAME
+gnunet\-timeout \- run process with timeout
+
+.SH SYNOPSIS
+.B gnunet\-timeout
+.RI TIMEOUT PROGRAM ARGS
+.br
+
+.SH DESCRIPTION
+\fBgnunet\-timeout\fP can be used to run another process with a
+timeout. Provided as the standard "timout" utility may not be
+available on all platforms.
+
+.SH BUGS
+Report bugs by using Mantis <https://gnunet.org/bugs/> or by sending electronic mail to <gnunet\-developers@gnu.org>
+
+.SH SEE
+timeout(1)
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 38fa52508..8a95064a6 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -325,6 +325,7 @@ src/rps/gnunet-service-rps_sampler.c
src/rps/gnunet-service-rps_sampler_elem.c
src/rps/gnunet-service-rps_view.c
src/rps/rps_api.c
+src/rps/rps_test_lib.c
src/rps/rps-test_util.c
src/scalarproduct/gnunet-scalarproduct.c
src/scalarproduct/gnunet-service-scalarproduct_alice.c
diff --git a/src/gns/gns_api.c b/src/gns/gns_api.c
index 0ec9209da..3b658da92 100644
--- a/src/gns/gns_api.c
+++ b/src/gns/gns_api.c
@@ -11,7 +11,7 @@
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
-
+
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -232,7 +232,6 @@ reconnect (struct GNUNET_GNS_Handle *handle)
handle),
GNUNET_MQ_handler_end ()
};
- struct GNUNET_GNS_LookupRequest *lh;
GNUNET_assert (NULL == handle->mq);
LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -244,7 +243,9 @@ reconnect (struct GNUNET_GNS_Handle *handle)
handle);
if (NULL == handle->mq)
return;
- for (lh = handle->lookup_head; NULL != lh; lh = lh->next)
+ for (struct GNUNET_GNS_LookupRequest *lh = handle->lookup_head;
+ NULL != lh;
+ lh = lh->next)
GNUNET_MQ_send_copy (handle->mq,
lh->env);
}
diff --git a/src/gns/gnunet-gns.c b/src/gns/gnunet-gns.c
index 149c8a7bb..463348ed3 100644
--- a/src/gns/gnunet-gns.c
+++ b/src/gns/gnunet-gns.c
@@ -11,7 +11,7 @@
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
-
+
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -65,8 +65,9 @@ static struct GNUNET_GNS_LookupWithTldRequest *lr;
/**
* Global return value.
* 0 on success (default),
- * 1 on internal failures, 2 on launch failure,
- * 3 if the name is not a GNS-supported TLD,
+ * 1 on internal failures
+ * 2 on launch failure,
+ * 4 if the name is not a GNS-supported TLD,
*/
static int global_ret;
@@ -114,7 +115,7 @@ process_lookup_result (void *cls,
lr = NULL;
if (GNUNET_NO == was_gns)
{
- global_ret = 3;
+ global_ret = 4; /* not for GNS */
GNUNET_SCHEDULER_shutdown ();
return;
}
@@ -183,7 +184,6 @@ run (void *cls,
global_ret = 2;
return;
}
-
GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
NULL);
diff --git a/src/gns/nss/nss_gns.c b/src/gns/nss/nss_gns.c
index 9c9233d35..58aab47fd 100644
--- a/src/gns/nss/nss_gns.c
+++ b/src/gns/nss/nss_gns.c
@@ -54,121 +54,126 @@
* @return a nss_status code
*/
enum nss_status
-_nss_gns_gethostbyname2_r(
- const char *name,
- int af,
- struct hostent * result,
- char *buffer,
- size_t buflen,
- int *errnop,
- int *h_errnop) {
-
- struct userdata u;
- enum nss_status status = NSS_STATUS_UNAVAIL;
- int i;
- size_t address_length, l, idx, astart;
-
- if (af == AF_UNSPEC)
+_nss_gns_gethostbyname2_r(const char *name,
+ int af,
+ struct hostent *result,
+ char *buffer,
+ size_t buflen,
+ int *errnop,
+ int *h_errnop)
+{
+ struct userdata u;
+ enum nss_status status = NSS_STATUS_UNAVAIL;
+ int i;
+ size_t address_length;
+ size_t l;
+ size_t idx;
+ size_t astart;
+
+ if (af == AF_UNSPEC)
#ifdef NSS_IPV6_ONLY
- af = AF_INET6;
+ af = AF_INET6;
#else
- af = AF_INET;
+ af = AF_INET;
#endif
#ifdef NSS_IPV4_ONLY
- if (af != AF_INET)
+ if (af != AF_INET)
#elif NSS_IPV6_ONLY
- if (af != AF_INET6)
+ if (af != AF_INET6)
#else
- if (af != AF_INET && af != AF_INET6)
+ if ( (af != AF_INET) &&
+ (af != AF_INET6) )
#endif
- {
- *errnop = EINVAL;
- *h_errnop = NO_RECOVERY;
-
- goto finish;
- }
-
- address_length = af == AF_INET ? sizeof(ipv4_address_t) : sizeof(ipv6_address_t);
- if (buflen <
- sizeof(char*)+ /* alias names */
- strlen(name)+1) { /* official name */
-
- *errnop = ERANGE;
- *h_errnop = NO_RECOVERY;
- status = NSS_STATUS_TRYAGAIN;
-
- goto finish;
- }
-
- u.count = 0;
- u.data_len = 0;
-
- i = gns_resolve_name(af, name, &u);
- if (-3 == i)
- {
- status = NSS_STATUS_NOTFOUND;
- goto finish;
- }
- if (-2 == i)
- {
- status = NSS_STATUS_UNAVAIL;
- goto finish;
- }
- if ( (-1 == i) ||
- (u.count == 0) )
- {
- *errnop = ETIMEDOUT;
- *h_errnop = HOST_NOT_FOUND;
- status = NSS_STATUS_NOTFOUND;
- goto finish;
- }
-
-
- /* Alias names */
- *((char**) buffer) = NULL;
- result->h_aliases = (char**) buffer;
- idx = sizeof(char*);
-
- /* Official name */
- strcpy(buffer+idx, name);
- result->h_name = buffer+idx;
- idx += strlen(name)+1;
-
- ALIGN(idx);
-
- result->h_addrtype = af;
- result->h_length = address_length;
-
- /* Check if there's enough space for the addresses */
- if (buflen < idx+u.data_len+sizeof(char*)*(u.count+1)) {
- *errnop = ERANGE;
- *h_errnop = NO_RECOVERY;
- status = NSS_STATUS_TRYAGAIN;
- goto finish;
- }
+ {
+ *errnop = EINVAL;
+ *h_errnop = NO_RECOVERY;
+
+ goto finish;
+ }
+ address_length = (af == AF_INET) ? sizeof(ipv4_address_t) : sizeof(ipv6_address_t);
+ if (buflen <
+ sizeof(char*)+ /* alias names */
+ strlen(name)+1)
+ { /* official name */
+ *errnop = ERANGE;
+ *h_errnop = NO_RECOVERY;
+ status = NSS_STATUS_TRYAGAIN;
+
+ goto finish;
+ }
+ u.count = 0;
+ u.data_len = 0;
+ i = gns_resolve_name (af,
+ name,
+ &u);
+ if (-3 == i)
+ {
+ status = NSS_STATUS_NOTFOUND;
+ goto finish;
+ }
+ if (-2 == i)
+ {
+ status = NSS_STATUS_UNAVAIL;
+ goto finish;
+ }
+ if ( (-1 == i) ||
+ (u.count == 0) )
+ {
+ *errnop = ETIMEDOUT;
+ *h_errnop = HOST_NOT_FOUND;
+ status = NSS_STATUS_NOTFOUND;
+ goto finish;
+ }
+ /* Alias names */
+ *((char**) buffer) = NULL;
+ result->h_aliases = (char**) buffer;
+ idx = sizeof(char*);
+
+ /* Official name */
+ strcpy (buffer+idx,
+ name);
+ result->h_name = buffer+idx;
+ idx += strlen (name)+1;
+
+ ALIGN(idx);
+
+ result->h_addrtype = af;
+ result->h_length = address_length;
+
+ /* Check if there's enough space for the addresses */
+ if (buflen < idx+u.data_len+sizeof(char*)*(u.count+1))
+ {
+ *errnop = ERANGE;
+ *h_errnop = NO_RECOVERY;
+ status = NSS_STATUS_TRYAGAIN;
+ goto finish;
+ }
/* Addresses */
- astart = idx;
- l = u.count*address_length;
- if (0 != l)
- memcpy(buffer+astart, &u.data, l);
- /* address_length is a multiple of 32bits, so idx is still aligned
- * correctly */
- idx += l;
-
- /* Address array address_length is always a multiple of 32bits */
- for (i = 0; i < u.count; i++)
- ((char**) (buffer+idx))[i] = buffer+astart+address_length*i;
- ((char**) (buffer+idx))[i] = NULL;
- result->h_addr_list = (char**) (buffer+idx);
-
- status = NSS_STATUS_SUCCESS;
+ astart = idx;
+ l = u.count*address_length;
+ if (0 != l)
+ memcpy (buffer+astart,
+ &u.data,
+ l);
+ /* address_length is a multiple of 32bits, so idx is still aligned
+ * correctly */
+ idx += l;
+
+ /* Address array address_length is always a multiple of 32bits */
+ for (i = 0; i < u.count; i++)
+ ((char**) (buffer+idx))[i] = buffer+astart+address_length*i;
+ ((char**) (buffer+idx))[i] = NULL;
+ result->h_addr_list = (char**) (buffer+idx);
+
+ status = NSS_STATUS_SUCCESS;
finish:
- return status;
+ return status;
}
+
/**
* The gethostbyname hook executed by nsswitch
*
@@ -176,29 +181,28 @@ finish:
* @param result the result hostent
* @param buffer the result buffer
* @param buflen length of the buffer
- * @param errnop idk
+ * @param errnop[out] the low-level error code to return to the application
* @param h_errnop idk
* @return a nss_status code
*/
enum nss_status
-_nss_gns_gethostbyname_r (
- const char *name,
- struct hostent *result,
- char *buffer,
- size_t buflen,
- int *errnop,
- int *h_errnop) {
-
- return _nss_gns_gethostbyname2_r(
- name,
- AF_UNSPEC,
- result,
- buffer,
- buflen,
- errnop,
- h_errnop);
+_nss_gns_gethostbyname_r (const char *name,
+ struct hostent *result,
+ char *buffer,
+ size_t buflen,
+ int *errnop,
+ int *h_errnop)
+{
+ return _nss_gns_gethostbyname2_r (name,
+ AF_UNSPEC,
+ result,
+ buffer,
+ buflen,
+ errnop,
+ h_errnop);
}
+
/**
* The gethostbyaddr hook executed by nsswitch
* We can't do this so we always return NSS_STATUS_UNAVAIL
@@ -209,23 +213,22 @@ _nss_gns_gethostbyname_r (
* @param result the result hostent
* @param buffer the result buffer
* @param buflen length of the buffer
- * @param errnop idk
+ * @param errnop[out] the low-level error code to return to the application
* @param h_errnop idk
* @return NSS_STATUS_UNAVAIL
*/
enum nss_status
-_nss_gns_gethostbyaddr_r(
- const void* addr,
- int len,
- int af,
- struct hostent *result,
- char *buffer,
- size_t buflen,
- int *errnop,
- int *h_errnop) {
-
- *errnop = EINVAL;
- *h_errnop = NO_RECOVERY;
- //NOTE we allow to leak this into DNS so no NOTFOUND
- return NSS_STATUS_UNAVAIL;
+_nss_gns_gethostbyaddr_r (const void* addr,
+ int len,
+ int af,
+ struct hostent *result,
+ char *buffer,
+ size_t buflen,
+ int *errnop,
+ int *h_errnop)
+{
+ *errnop = EINVAL;
+ *h_errnop = NO_RECOVERY;
+ //NOTE we allow to leak this into DNS so no NOTFOUND
+ return NSS_STATUS_UNAVAIL;
}
diff --git a/src/gns/nss/nss_gns_query.c b/src/gns/nss/nss_gns_query.c
index 094e25ed5..867ead624 100644
--- a/src/gns/nss/nss_gns_query.c
+++ b/src/gns/nss/nss_gns_query.c
@@ -11,7 +11,7 @@
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
-
+
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -48,14 +48,16 @@ gns_resolve_name (int af,
{
if (-1 == asprintf (&cmd,
"%s -t AAAA -u %s\n",
- "gnunet-gns -r", name))
+ "gnunet-gns -r",
+ name))
return -1;
}
else
{
if (-1 == asprintf (&cmd,
"%s %s\n",
- "gnunet-gns -r -u", name))
+ "gnunet-gns -r -u",
+ name))
return -1;
}
if (NULL == (p = popen (cmd, "r")))
@@ -63,7 +65,9 @@ gns_resolve_name (int af,
free (cmd);
return -1;
}
- while (NULL != fgets (line, sizeof(line), p))
+ while (NULL != fgets (line,
+ sizeof(line),
+ p))
{
if (u->count >= MAX_ENTRIES)
break;
@@ -72,7 +76,9 @@ gns_resolve_name (int af,
line[strlen(line)-1] = '\0';
if (AF_INET == af)
{
- if (inet_pton(af, line, &(u->data.ipv4[u->count])))
+ if (inet_pton(af,
+ line,
+ &u->data.ipv4[u->count]))
{
u->count++;
u->data_len += sizeof(ipv4_address_t);
@@ -86,7 +92,9 @@ gns_resolve_name (int af,
}
else if (AF_INET6 == af)
{
- if (inet_pton(af, line, &(u->data.ipv6[u->count])))
+ if (inet_pton(af,
+ line,
+ &u->data.ipv6[u->count]))
{
u->count++;
u->data_len += sizeof(ipv6_address_t);
@@ -105,7 +113,10 @@ gns_resolve_name (int af,
if (4 == ret)
return -2; /* not for GNS */
if (3 == ret)
- return -3; /* timeout */
+ return -3; /* timeout -> not found */
+ if ( (2 == ret) || (1 == ret) )
+ return -2; /* launch failure -> service unavailable */
return 0;
}
+
/* end of nss_gns_query.c */
diff --git a/src/gns/nss/nss_gns_query.h b/src/gns/nss/nss_gns_query.h
index bb04f9004..48cab4b22 100644
--- a/src/gns/nss/nss_gns_query.h
+++ b/src/gns/nss/nss_gns_query.h
@@ -11,7 +11,7 @@
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
-
+
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -26,25 +26,30 @@
/* Maximum number of entries to return */
#define MAX_ENTRIES 16
-typedef struct {
- uint32_t address;
+typedef struct
+{
+ uint32_t address;
} ipv4_address_t;
-typedef struct {
- uint8_t address[16];
+
+typedef struct
+{
+ uint8_t address[16];
} ipv6_address_t;
-struct userdata {
+struct userdata
+{
int count;
int data_len; /* only valid when doing reverse lookup */
union {
- ipv4_address_t ipv4[MAX_ENTRIES];
- ipv6_address_t ipv6[MAX_ENTRIES];
- char *name[MAX_ENTRIES];
+ ipv4_address_t ipv4[MAX_ENTRIES];
+ ipv6_address_t ipv6[MAX_ENTRIES];
+ char *name[MAX_ENTRIES];
} data;
};
+
/**
* Wrapper function that uses gnunet-gns cli tool to resolve
* an IPv4/6 address.
@@ -54,8 +59,9 @@ struct userdata {
* @param u the userdata (result struct)
* @return -1 on error else 0
*/
-int gns_resolve_name(int af,
- const char *name,
- struct userdata *userdata);
+int
+gns_resolve_name(int af,
+ const char *name,
+ struct userdata *userdata);
#endif
diff --git a/src/identity/identity_api_lookup.c b/src/identity/identity_api_lookup.c
index 593a5dbb0..25aec8ede 100644
--- a/src/identity/identity_api_lookup.c
+++ b/src/identity/identity_api_lookup.c
@@ -11,7 +11,7 @@
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
-
+
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -131,6 +131,12 @@ GNUNET_IDENTITY_ego_lookup (const struct GNUNET_CONFIGURATION_Handle *cfg,
el->identity = GNUNET_IDENTITY_connect (cfg,
&identity_cb,
el);
+ if (NULL == el->identity)
+ {
+ GNUNET_free (el->name);
+ GNUNET_free (el);
+ return NULL;
+ }
return el;
}
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index 84fb33be2..5a75ac55a 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -1666,10 +1666,11 @@ Peers_cleanup_destroyed_channel (void *cls,
{
struct GNUNET_PeerIdentity *peer = cls;
struct PeerContext *peer_ctx;
+ uint32_t *channel_flag;
if (GNUNET_NO == Peers_check_peer_known (peer))
{/* We don't want to implicitly create a context that we're about to kill */
- LOG (GNUNET_ERROR_TYPE_DEBUG,
+ LOG (GNUNET_ERROR_TYPE_WARNING,
"channel (%s) without associated context was destroyed\n",
GNUNET_i2s (peer));
return;
@@ -1697,12 +1698,16 @@ Peers_cleanup_destroyed_channel (void *cls,
if (NULL != peer_ctx->send_channel)
{
GNUNET_CADET_channel_destroy (peer_ctx->send_channel);
+ channel_flag = Peers_get_channel_flag (&peer_ctx->peer_id, Peers_CHANNEL_ROLE_SENDING);
+ Peers_set_channel_flag (channel_flag, Peers_CHANNEL_DESTROING);
peer_ctx->send_channel = NULL;
peer_ctx->mq = NULL;
}
if (NULL != peer_ctx->recv_channel)
{
GNUNET_CADET_channel_destroy (peer_ctx->recv_channel);
+ channel_flag = Peers_get_channel_flag (&peer_ctx->peer_id, Peers_CHANNEL_ROLE_RECEIVING);
+ Peers_set_channel_flag (channel_flag, Peers_CHANNEL_DESTROING);
peer_ctx->recv_channel = NULL;
}
/* Set the #Peers_ONLINE flag accordingly */
diff --git a/src/set/gnunet-service-set_intersection.c b/src/set/gnunet-service-set_intersection.c
index 254763b45..1083384f5 100644
--- a/src/set/gnunet-service-set_intersection.c
+++ b/src/set/gnunet-service-set_intersection.c
@@ -11,7 +11,7 @@
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
-
+
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -23,6 +23,7 @@
*/
#include "platform.h"
#include "gnunet_util_lib.h"
+#include "gnunet_statistics_service.h"
#include "gnunet-service-set.h"
#include "gnunet_block_lib.h"
#include "gnunet-service-set_protocol.h"
@@ -215,6 +216,10 @@ send_client_removed_element (struct Operation *op,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Sending removed element (size %u) to client\n",
element->size);
+ GNUNET_STATISTICS_update (_GSS_statistics,
+ "# Element removed messages sent",
+ 1,
+ GNUNET_NO);
GNUNET_assert (0 != op->client_request_id);
ev = GNUNET_MQ_msg_extra (rm,
element->size,
@@ -406,6 +411,10 @@ fail_intersection_operation (struct Operation *op)
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Intersection operation failed\n");
+ GNUNET_STATISTICS_update (_GSS_statistics,
+ "# Intersection operations failed",
+ 1,
+ GNUNET_NO);
if (NULL != op->state->my_elements)
{
GNUNET_CONTAINER_multihashmap_destroy (op->state->my_elements);
@@ -466,6 +475,10 @@ send_bloomfilter (struct Operation *op)
op);
/* send our Bloom filter */
+ GNUNET_STATISTICS_update (_GSS_statistics,
+ "# Intersection Bloom filters sent",
+ 1,
+ GNUNET_NO);
chunk_size = 60 * 1024 - sizeof (struct BFMessage);
if (bf_size <= chunk_size)
{
@@ -534,6 +547,10 @@ send_client_done_and_destroy (void *cls)
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Intersection succeeded, sending DONE to local client\n");
+ GNUNET_STATISTICS_update (_GSS_statistics,
+ "# Intersection operations succeeded",
+ 1,
+ GNUNET_NO);
ev = GNUNET_MQ_msg (rm,
GNUNET_MESSAGE_TYPE_SET_RESULT);
rm->request_id = htonl (op->client_request_id);
diff --git a/src/set/gnunet-service-set_union.c b/src/set/gnunet-service-set_union.c
index c3c14f1ba..c1268948a 100644
--- a/src/set/gnunet-service-set_union.c
+++ b/src/set/gnunet-service-set_union.c
@@ -11,7 +11,7 @@
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
-
+
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -758,8 +758,8 @@ get_order_from_difference (unsigned int diff)
*/
static int
send_full_element_iterator (void *cls,
- const struct GNUNET_HashCode *key,
- void *value)
+ const struct GNUNET_HashCode *key,
+ void *value)
{
struct Operation *op = cls;
struct GNUNET_SET_ElementMessage *emsg;
@@ -1371,7 +1371,8 @@ send_client_element (struct Operation *op,
*
* @param op operation
*/
-void destroy_channel (struct Operation *op)
+static void
+destroy_channel (struct Operation *op)
{
struct GNUNET_CADET_Channel *channel;
@@ -1404,7 +1405,11 @@ send_client_done (void *cls)
if (PHASE_DONE != op->state->phase) {
LOG (GNUNET_ERROR_TYPE_WARNING,
- "union operation failed\n");
+ "Union operation failed\n");
+ GNUNET_STATISTICS_update (_GSS_statistics,
+ "# Union operations failed",
+ 1,
+ GNUNET_NO);
ev = GNUNET_MQ_msg (rm, GNUNET_MESSAGE_TYPE_SET_RESULT);
rm->result_status = htons (GNUNET_SET_STATUS_FAILURE);
rm->request_id = htonl (op->client_request_id);
@@ -1416,6 +1421,10 @@ send_client_done (void *cls)
op->state->client_done_sent = GNUNET_YES;
+ GNUNET_STATISTICS_update (_GSS_statistics,
+ "# Union operations succeeded",
+ 1,
+ GNUNET_NO);
LOG (GNUNET_ERROR_TYPE_INFO,
"Signalling client that union operation is done\n");
ev = GNUNET_MQ_msg (rm,
diff --git a/src/util/.gitignore b/src/util/.gitignore
index 8e7093568..7b190ca76 100644
--- a/src/util/.gitignore
+++ b/src/util/.gitignore
@@ -69,4 +69,7 @@ perf_crypto_hash
perf_crypto_symmetric
perf_crypto_rsa
perf_crypto_ecc_dlog
-test_hexcoder test_regex test_tun
+test_hexcoder
+test_regex
+test_tun
+gnunet-timeout
diff --git a/src/util/Makefile.am b/src/util/Makefile.am
index ec7bcb016..4ae073c2c 100644
--- a/src/util/Makefile.am
+++ b/src/util/Makefile.am
@@ -166,6 +166,7 @@ lib_LTLIBRARIES = libgnunetutil.la
libexec_PROGRAMS = \
gnunet-service-resolver \
+ gnunet-timeout \
$(W32CONSOLEHELPER)
bin_SCRIPTS =\
@@ -192,6 +193,15 @@ endif
endif
+if !MINGW
+gnunet_timeout_SOURCES = \
+ gnunet-timeout.c
+else
+gnunet_timeout_SOURCES = \
+ gnunet-timeout-w32.c
+endif
+
+
do_subst = $(SED) -e 's,[@]PYTHON[@],$(PYTHON),g'
gnunet-qr: gnunet-qr.py.in Makefile
@@ -334,12 +344,12 @@ test_hexcoder_LDADD = \
test_tun_SOURCES = \
test_tun.c
test_tun_LDADD = \
- libgnunetutil.la
+ libgnunetutil.la
test_regex_SOURCES = \
test_regex.c
test_regex_LDADD = \
- libgnunetutil.la
+ libgnunetutil.la
test_os_start_process_SOURCES = \
test_os_start_process.c
@@ -622,4 +632,4 @@ EXTRA_DIST = \
test_resolver_api_data.conf \
test_service_data.conf \
test_speedup_data.conf \
- gnunet-qr.py.in
+ gnunet-qr.py.in
diff --git a/src/util/client.c b/src/util/client.c
index 44e326eab..1f569255a 100644
--- a/src/util/client.c
+++ b/src/util/client.c
@@ -11,7 +11,7 @@
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
-
+
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -721,6 +721,17 @@ test_service_configuration (const char *service_name,
&unixpath)) &&
(0 < strlen (unixpath)))
ret = GNUNET_OK;
+ else if ((GNUNET_OK ==
+ GNUNET_CONFIGURATION_have_value (cfg,
+ service_name,
+ "UNIXPATH")))
+ {
+ GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
+ service_name,
+ "UNIXPATH",
+ _("not a valid filename"));
+ return GNUNET_SYSERR; /* UNIXPATH specified but invalid! */
+ }
GNUNET_free_non_null (unixpath);
#endif
diff --git a/src/util/dnsparser.c b/src/util/dnsparser.c
index 57d0a014c..6fb6d657f 100644
--- a/src/util/dnsparser.c
+++ b/src/util/dnsparser.c
@@ -11,7 +11,7 @@
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
-
+
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -956,8 +956,11 @@ GNUNET_DNSPARSER_builder_add_name (char *dst,
len = dot - idna_name;
if ( (len >= 64) || (0 == len) )
{
- GNUNET_break (0);
- goto fail; /* segment too long or empty */
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Invalid DNS name `%s': label with %u characters encountered\n",
+ name,
+ len);
+ goto fail; /* label too long or empty */
}
dst[pos++] = (char) (uint8_t) len;
GNUNET_memcpy (&dst[pos],
diff --git a/contrib/timeout_watchdog_w32.c b/src/util/gnunet-timeout-w32.c
index 901eb6207..78b268fe2 100644
--- a/contrib/timeout_watchdog_w32.c
+++ b/src/util/gnunet-timeout-w32.c
@@ -11,13 +11,13 @@
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
-
+
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
- * @file contrib/timeout_watchdog_w32.c
+ * @file src/util/gnunet-timeout-w32.c
* @brief small tool starting a child process, waiting that it terminates or killing it after a given timeout period
* @author LRN
*/
@@ -182,7 +182,7 @@ main (int argc, char *argv[])
exit (0);
}
printf ("Child processes were killed after timeout of %u seconds\n",
- timeout);
+ timeout);
TerminateJobObject (job, 1);
CloseHandle (proc.hProcess);
exit (1);
diff --git a/contrib/timeout_watchdog.c b/src/util/gnunet-timeout.c
index 70e840d55..8dfb6ad17 100644
--- a/contrib/timeout_watchdog.c
+++ b/src/util/gnunet-timeout.c
@@ -11,13 +11,13 @@
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
-
+
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
- * @file contrib/timeout_watchdog.c
+ * @file src/util/gnunet-timeout.c
* @brief small tool starting a child process, waiting that it terminates or killing it after a given timeout period
* @author Matthias Wachs
*/
@@ -39,25 +39,35 @@ sigchld_handler (int val)
int ret = 0;
(void) val;
- waitpid (child, &status, 0);
+ waitpid (child,
+ &status,
+ 0);
if (WIFEXITED (status) != 0)
- {
- ret = WEXITSTATUS (status);
- printf ("Test process exited with result %u\n", ret);
- }
+ {
+ ret = WEXITSTATUS (status);
+ fprintf (stderr,
+ "Process exited with result %u\n",
+ ret);
+ exit (ret); /* return same status code */
+ }
if (WIFSIGNALED (status) != 0)
- {
- ret = WTERMSIG (status);
- printf ("Test process was signaled %u\n", ret);
- }
- exit (ret);
+ {
+ ret = WTERMSIG (status);
+ fprintf (stderr,
+ "Process received signal %u\n",
+ ret);
+ kill (getpid (),
+ ret); /* kill self with the same signal */
+ }
+ exit (-1);
}
static void
sigint_handler (int val)
{
- kill (0, val);
+ kill (0,
+ val);
exit (val);
}
@@ -70,18 +80,18 @@ main (int argc,
pid_t gpid = 0;
if (argc < 3)
- {
- printf
- ("arg 1: timeout in sec., arg 2: executable, arg<n> arguments\n");
- exit (1);
- }
+ {
+ fprintf (stderr,
+ "arg 1: timeout in sec., arg 2: executable, arg<n> arguments\n");
+ exit (-1);
+ }
timeout = atoi (argv[1]);
if (timeout == 0)
timeout = 600;
-/* with getpgid() it does not compile, but getpgrp is the BSD version and working */
+ /* with getpgid() it does not compile, but getpgrp is the BSD version and working */
gpid = getpgrp ();
signal (SIGCHLD, sigchld_handler);
@@ -94,23 +104,25 @@ main (int argc,
child = fork ();
if (child == 0)
- {
- /* int setpgrp(pid_t pid, pid_t pgid); is not working on this machine */
- //setpgrp (0, pid_t gpid);
- if (-1 != gpid)
- setpgid (0, gpid);
- execvp (argv[2], &argv[2]);
- exit (1);
- }
+ {
+ /* int setpgrp(pid_t pid, pid_t pgid); is not working on this machine */
+ //setpgrp (0, pid_t gpid);
+ if (-1 != gpid)
+ setpgid (0, gpid);
+ execvp (argv[2],
+ &argv[2]);
+ exit (-1);
+ }
if (child > 0)
- {
- sleep (timeout);
- printf ("Child processes were killed after timeout of %u seconds\n",
- timeout);
- kill (0, SIGTERM);
- exit (1);
- }
- exit (1);
+ {
+ sleep (timeout);
+ printf ("Child processes were killed after timeout of %u seconds\n",
+ timeout);
+ kill (0,
+ SIGTERM);
+ exit (3);
+ }
+ exit (-1);
}
/* end of timeout_watchdog.c */