aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSchanzenbach, Martin <mschanzenbach@posteo.de>2019-02-20 16:51:51 +0100
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2019-02-20 16:51:51 +0100
commit609e4becfe496ed62c2007db18d04fbc8d523476 (patch)
treeab5b4afd852c85e7e194bf4b88b15fae7ed7185e /src
parent6d527ae5fd36ae9f61bb0832a7a890372ab44bb6 (diff)
parent311f47494f931aefd9dc1e247831d88a3bcebdb4 (diff)
downloadgnunet-609e4becfe496ed62c2007db18d04fbc8d523476.tar.gz
gnunet-609e4becfe496ed62c2007db18d04fbc8d523476.zip
Merge branch 'master' of git+ssh://gnunet.org/gnunet
Diffstat (limited to 'src')
-rw-r--r--src/arm/arm.conf.in2
-rw-r--r--src/consensus/test_consensus.conf4
-rw-r--r--src/datastore/plugin_datastore_postgres.c8
-rw-r--r--src/fs/Makefile.am5
-rw-r--r--src/fs/fs.conf.in2
-rw-r--r--src/fs/fs_dirmetascan.c8
-rw-r--r--src/fs/fs_publish.c18
-rw-r--r--src/fs/gnunet-publish.c4
-rw-r--r--src/fs/gnunet-service-fs_cadet_client.c21
-rw-r--r--src/gns/.gitignore1
-rw-r--r--src/gns/Makefile.am20
-rw-r--r--src/gns/gnunet-gns-proxy-setup-ca.in7
-rw-r--r--src/include/gnunet_protocols.h2
-rw-r--r--src/include/gnunet_rps_service.h2
-rw-r--r--src/integration-tests/gnunet_testing.py.in93
-rwxr-xr-xsrc/integration-tests/test_integration_bootstrap_and_connect.py.in2
-rwxr-xr-xsrc/integration-tests/test_integration_disconnect.py.in22
-rwxr-xr-xsrc/integration-tests/test_integration_disconnect_nat.py.in2
-rwxr-xr-xsrc/integration-tests/test_integration_reconnect.py.in110
-rwxr-xr-xsrc/integration-tests/test_integration_reconnect_nat.py.in2
-rw-r--r--src/namestore/test_plugin_namestore.c3
-rw-r--r--src/peerinfo/peerinfo_api.c5
-rw-r--r--src/peerstore/peerstore_api.c140
-rw-r--r--src/pq/pq_result_helper.c2
-rw-r--r--src/rps/gnunet-rps-profiler.c4
-rw-r--r--src/rps/gnunet-service-rps.c34
-rw-r--r--src/rps/rps-test_util.h4
-rw-r--r--src/rps/rps.h2
-rw-r--r--src/rps/rps_api.c2
-rw-r--r--src/rps/test_rps.c4
-rw-r--r--src/secretsharing/test_secretsharing.conf4
-rw-r--r--src/sq/sq.c2
-rw-r--r--src/testbed/test_testbed_api_template.conf4
-rw-r--r--src/testing/test_testing_defaults.conf4
-rw-r--r--src/testing/test_testing_sharedservices.conf4
-rw-r--r--src/topology/test_gnunet_daemon_topology_data.conf4
-rw-r--r--src/transport/transport_api2_address.c2
-rw-r--r--src/transport/transport_api_core.c2
-rw-r--r--src/util/container_multihashmap.c23
-rw-r--r--src/util/container_multihashmap32.c26
-rw-r--r--src/util/container_multipeermap.c34
-rw-r--r--src/util/container_multishortmap.c36
-rw-r--r--src/util/mq.c1
43 files changed, 372 insertions, 309 deletions
diff --git a/src/arm/arm.conf.in b/src/arm/arm.conf.in
index 64ae35786..dc32f5498 100644
--- a/src/arm/arm.conf.in
+++ b/src/arm/arm.conf.in
@@ -16,7 +16,7 @@ UNIX_MATCH_GID = YES
16# logging with a new log file each day. Note that only the last 3 16# logging with a new log file each day. Note that only the last 3
17# log files are preserved. 17# log files are preserved.
18# GLOBAL_POSTFIX = -l $GNUNET_CACHE_HOME/{}-%Y-%m-%d.log 18# GLOBAL_POSTFIX = -l $GNUNET_CACHE_HOME/{}-%Y-%m-%d.log
19GLOBAL_PREFIX = @MONKEYPREFIX@ 19GLOBAL_PREFIX =
20 20
21# If set to YES, ARM will only start services that are marked as 21# If set to YES, ARM will only start services that are marked as
22# system-level services (and we'll expect a second ARM to be 22# system-level services (and we'll expect a second ARM to be
diff --git a/src/consensus/test_consensus.conf b/src/consensus/test_consensus.conf
index fa42c3c1a..4f17fa359 100644
--- a/src/consensus/test_consensus.conf
+++ b/src/consensus/test_consensus.conf
@@ -81,3 +81,7 @@ WAN_QUOTA_OUT = unlimited
81 81
82[core] 82[core]
83USE_EPHEMERAL_KEYS = NO 83USE_EPHEMERAL_KEYS = NO
84
85[rps]
86START_ON_DEMAND = NO
87IMMEDIATE_START = NO
diff --git a/src/datastore/plugin_datastore_postgres.c b/src/datastore/plugin_datastore_postgres.c
index 94db6e116..0a3018411 100644
--- a/src/datastore/plugin_datastore_postgres.c
+++ b/src/datastore/plugin_datastore_postgres.c
@@ -11,7 +11,7 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
@@ -153,7 +153,11 @@ init_connection (struct Plugin *plugin)
153 "SELECT hash FROM gn090", 153 "SELECT hash FROM gn090",
154 0), 154 0),
155 GNUNET_PQ_make_prepare ("estimate_size", 155 GNUNET_PQ_make_prepare ("estimate_size",
156 "SELECT SUM(LENGTH(value))+256*COUNT(*) AS total FROM gn090", 156 "SELECT CASE WHEN NOT EXISTS"
157 " (SELECT 1 FROM gn090)"
158 " THEN 0"
159 " ELSE (SELECT SUM(LENGTH(value))+256*COUNT(*) FROM gn090)"
160 "END AS total",
157 0), 161 0),
158 GNUNET_PQ_PREPARED_STATEMENT_END 162 GNUNET_PQ_PREPARED_STATEMENT_END
159 }; 163 };
diff --git a/src/fs/Makefile.am b/src/fs/Makefile.am
index 33260a794..d452bbf3c 100644
--- a/src/fs/Makefile.am
+++ b/src/fs/Makefile.am
@@ -282,11 +282,6 @@ check_SCRIPTS += \
282endif 282endif
283endif 283endif
284 284
285if ENABLE_MONKEY
286 MONKEY = @MONKEYPREFIX@
287 AM_LDFLAGS = -no-install
288endif
289
290 285
291if ENABLE_TEST_RUN 286if ENABLE_TEST_RUN
292AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME; $(MONKEY) 287AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME; $(MONKEY)
diff --git a/src/fs/fs.conf.in b/src/fs/fs.conf.in
index 92bcf776d..1e4c5c268 100644
--- a/src/fs/fs.conf.in
+++ b/src/fs/fs.conf.in
@@ -11,6 +11,8 @@ BINARY = gnunet-service-fs
11ACCEPT_FROM = 127.0.0.1; 11ACCEPT_FROM = 127.0.0.1;
12ACCEPT_FROM6 = ::1; 12ACCEPT_FROM6 = ::1;
13 13
14# PREFIX = valgrind
15
14# Do we introduce artificial delays? (may improve anonymity) 16# Do we introduce artificial delays? (may improve anonymity)
15DELAY = YES 17DELAY = YES
16 18
diff --git a/src/fs/fs_dirmetascan.c b/src/fs/fs_dirmetascan.c
index 4a86a717f..115f99391 100644
--- a/src/fs/fs_dirmetascan.c
+++ b/src/fs/fs_dirmetascan.c
@@ -11,7 +11,7 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
@@ -332,10 +332,7 @@ process_helper_msgs (void *cls,
332 break; 332 break;
333 } 333 }
334 if (NULL == ds->toplevel) 334 if (NULL == ds->toplevel)
335 {
336 GNUNET_break (0);
337 break; 335 break;
338 }
339 ds->progress_callback (ds->progress_callback_cls, 336 ds->progress_callback (ds->progress_callback_cls,
340 NULL, GNUNET_SYSERR, 337 NULL, GNUNET_SYSERR,
341 GNUNET_FS_DIRSCANNER_ALL_COUNTED); 338 GNUNET_FS_DIRSCANNER_ALL_COUNTED);
@@ -408,10 +405,7 @@ process_helper_msgs (void *cls,
408 break; 405 break;
409 } 406 }
410 if (NULL == ds->toplevel) 407 if (NULL == ds->toplevel)
411 {
412 GNUNET_break (0);
413 break; 408 break;
414 }
415 ds->stop_task = GNUNET_SCHEDULER_add_now (&finish_scan, 409 ds->stop_task = GNUNET_SCHEDULER_add_now (&finish_scan,
416 ds); 410 ds);
417 return GNUNET_OK; 411 return GNUNET_OK;
diff --git a/src/fs/fs_publish.c b/src/fs/fs_publish.c
index c7f3c4152..71ab1122c 100644
--- a/src/fs/fs_publish.c
+++ b/src/fs/fs_publish.c
@@ -11,7 +11,7 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
@@ -716,17 +716,21 @@ handle_index_start_failed (void *cls,
716 struct GNUNET_FS_PublishContext *pc = cls; 716 struct GNUNET_FS_PublishContext *pc = cls;
717 struct GNUNET_FS_FileInformation *p; 717 struct GNUNET_FS_FileInformation *p;
718 const char *emsg = (const char *) &msg[1]; 718 const char *emsg = (const char *) &msg[1];
719 char *msgtxt;
719 720
720 GNUNET_MQ_destroy (pc->mq); 721 GNUNET_MQ_destroy (pc->mq);
721 pc->mq = NULL; 722 pc->mq = NULL;
722 p = pc->fi_pos; 723 p = pc->fi_pos;
723 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 724 GNUNET_asprintf (&msgtxt,
724 _("Can not index file `%s': %s. Will try to insert instead.\n"), 725 _("Can not index file `%s': %s.\n"),
725 p->filename, 726 p->filename,
726 gettext (emsg)); 727 gettext (emsg));
727 p->data.file.do_index = GNUNET_NO; 728 signal_publish_error (p,
729 pc,
730 msgtxt);
731 GNUNET_free (msgtxt);
728 GNUNET_FS_file_information_sync_ (p); 732 GNUNET_FS_file_information_sync_ (p);
729 publish_content (pc); 733 GNUNET_FS_publish_sync_ (pc);
730} 734}
731 735
732 736
diff --git a/src/fs/gnunet-publish.c b/src/fs/gnunet-publish.c
index a825795cb..eb8a7ed19 100644
--- a/src/fs/gnunet-publish.c
+++ b/src/fs/gnunet-publish.c
@@ -11,7 +11,7 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
@@ -684,7 +684,7 @@ directory_scan_cb (void *cls,
684 case GNUNET_FS_DIRSCANNER_INTERNAL_ERROR: 684 case GNUNET_FS_DIRSCANNER_INTERNAL_ERROR:
685 FPRINTF (stdout, 685 FPRINTF (stdout,
686 "%s", 686 "%s",
687 _("Internal error scanning directory.\n")); 687 _("Error scanning directory.\n"));
688 ret = 1; 688 ret = 1;
689 GNUNET_SCHEDULER_shutdown (); 689 GNUNET_SCHEDULER_shutdown ();
690 break; 690 break;
diff --git a/src/fs/gnunet-service-fs_cadet_client.c b/src/fs/gnunet-service-fs_cadet_client.c
index 61f73a50a..9ba250dfa 100644
--- a/src/fs/gnunet-service-fs_cadet_client.c
+++ b/src/fs/gnunet-service-fs_cadet_client.c
@@ -11,7 +11,7 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
@@ -469,8 +469,11 @@ reset_cadet (struct CadetHandle *mh)
469 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 469 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
470 "Resetting cadet channel to %s\n", 470 "Resetting cadet channel to %s\n",
471 GNUNET_i2s (&mh->target)); 471 GNUNET_i2s (&mh->target));
472 GNUNET_CADET_channel_destroy (mh->channel); 472 if (NULL != mh->channel)
473 mh->channel = NULL; 473 {
474 GNUNET_CADET_channel_destroy (mh->channel);
475 mh->channel = NULL;
476 }
474 GNUNET_CONTAINER_multihashmap_iterate (mh->waiting_map, 477 GNUNET_CONTAINER_multihashmap_iterate (mh->waiting_map,
475 &move_to_pending, 478 &move_to_pending,
476 mh); 479 mh);
@@ -741,7 +744,17 @@ GSF_cadet_release_clients (void *cls,
741 "Timeout on cadet channel to %s\n", 744 "Timeout on cadet channel to %s\n",
742 GNUNET_i2s (&mh->target)); 745 GNUNET_i2s (&mh->target));
743 if (NULL != mh->channel) 746 if (NULL != mh->channel)
744 GNUNET_CADET_channel_destroy (mh->channel); 747 {
748 struct GNUNET_CADET_Channel *channel = mh->channel;
749
750 mh->channel = NULL;
751 GNUNET_CADET_channel_destroy (channel);
752 }
753 if (NULL != mh->reset_task)
754 {
755 GNUNET_SCHEDULER_cancel (mh->reset_task);
756 mh->reset_task = NULL;
757 }
745 return GNUNET_YES; 758 return GNUNET_YES;
746} 759}
747 760
diff --git a/src/gns/.gitignore b/src/gns/.gitignore
index afd062cb3..3bbb2eb3d 100644
--- a/src/gns/.gitignore
+++ b/src/gns/.gitignore
@@ -9,3 +9,4 @@ local.crt
9local.der 9local.der
10local.key 10local.key
11server.csr 11server.csr
12gnunet-gns-proxy-setup-ca
diff --git a/src/gns/Makefile.am b/src/gns/Makefile.am
index 13f6a6e52..434d50f34 100644
--- a/src/gns/Makefile.am
+++ b/src/gns/Makefile.am
@@ -14,7 +14,8 @@ EXTRA_DIST = \
14 test_gns_simple_lookup.conf \ 14 test_gns_simple_lookup.conf \
15 gns-helper-service-w32.conf \ 15 gns-helper-service-w32.conf \
16 w32nsp.def \ 16 w32nsp.def \
17 gnunet-gns-proxy-setup-ca \ 17 openssl.cnf \
18 gnunet-gns-proxy-setup-ca.in \
18 zonefiles/J7POEUT41A8PBFS7KVVDRF88GBOU4HK8PSU5QKVLVE3R9T91E99G.zkey \ 19 zonefiles/J7POEUT41A8PBFS7KVVDRF88GBOU4HK8PSU5QKVLVE3R9T91E99G.zkey \
19 zonefiles/OEFL7A4VEF1B40QLEMTG5D8G1CN6EN16QUSG5R2DT71GRJN34LSG.zkey \ 20 zonefiles/OEFL7A4VEF1B40QLEMTG5D8G1CN6EN16QUSG5R2DT71GRJN34LSG.zkey \
20 zonefiles/test_zonekey \ 21 zonefiles/test_zonekey \
@@ -80,7 +81,7 @@ noinst_PROGRAMS = \
80 gnunet-gns-benchmark 81 gnunet-gns-benchmark
81 82
82pkgdata_DATA = \ 83pkgdata_DATA = \
83 openssl.cnf 84 openssl.cnf
84 85
85if HAVE_MHD 86if HAVE_MHD
86if LINUX 87if LINUX
@@ -88,21 +89,20 @@ bin_PROGRAMS += gnunet-bcd
88endif 89endif
89endif 90endif
90 91
91bin_SCRIPTS = gnunet-gns-proxy-setup-ca
92
93plugin_LTLIBRARIES = \ 92plugin_LTLIBRARIES = \
94 libgnunet_plugin_block_gns.la \ 93 libgnunet_plugin_block_gns.la \
95 libgnunet_plugin_gnsrecord_gns.la 94 libgnunet_plugin_gnsrecord_gns.la
96 95
97xPFX=$(pkgdatadir)/openssl.cnf
98
99do_subst = $(SED) -e 's,[@]PREFIX[@],${xPFX},g'
100 96
101gnunet-gns-proxy-setup-ca: gnunet-gns-proxy-setup-ca.in 97bin_SCRIPTS = \
102 $(do_subst) < $(top_srcdir)/src/gns/gnunet-gns-proxy-setup-ca.in > gnunet-gns-proxy-setup-ca 98 gnunet-gns-proxy-setup-ca
103 chmod +x gnunet-gns-proxy-setup-ca
104 99
100# See: https://www.gnu.org/software/automake/manual/html_node/Scripts.html#Scripts
101do_subst = sed -e 's,[@]pkgdatadir[@],$(pkgdatadir),g'
105 102
103gnunet-gns-proxy-setup-ca: gnunet-gns-proxy-setup-ca.in Makefile
104 $(do_subst) < $(srcdir)/gnunet-gns-proxy-setup-ca.in > gnunet-gns-proxy-setup-ca
105 chmod +x gnunet-gns-proxy-setup-ca
106 106
107libgnunet_plugin_gnsrecord_gns_la_SOURCES = \ 107libgnunet_plugin_gnsrecord_gns_la_SOURCES = \
108 plugin_gnsrecord_gns.c 108 plugin_gnsrecord_gns.c
diff --git a/src/gns/gnunet-gns-proxy-setup-ca.in b/src/gns/gnunet-gns-proxy-setup-ca.in
index d3753b074..0a6fab18a 100644
--- a/src/gns/gnunet-gns-proxy-setup-ca.in
+++ b/src/gns/gnunet-gns-proxy-setup-ca.in
@@ -3,15 +3,13 @@
3# and install it (for both GNUnet and your browser). 3# and install it (for both GNUnet and your browser).
4# 4#
5 5
6# TODO: We should sed the real paths to the binaries involved here. 6OPENSSLCFG=@pkgdatadir@/openssl.cnf
7OPENSSLCFG=@PREFIX@
8if ! which openssl > /dev/null 7if ! which openssl > /dev/null
9then 8then
10 echo "'openssl' command not found. Please install it." 9 echo "'openssl' command not found. Please install it."
11 exit 1 10 exit 1
12fi 11fi
13 12
14
15echo "Generating CA" 13echo "Generating CA"
16options='' 14options=''
17while getopts "c:" opt; do 15while getopts "c:" opt; do
@@ -46,7 +44,8 @@ cat $GNSCERT $GNSCANO > $GNS_CA_CERT_PEM
46 44
47if ! which certutil > /dev/null 45if ! which certutil > /dev/null
48then 46then
49 echo "'certutil' command not found. Not importing into browsers." 47 echo "The 'certutil' command was not found. Not importing into browsers."
48 echo "For 'certutil' install nss."
50else 49else
51 echo "Importing CA into browsers" 50 echo "Importing CA into browsers"
52 for f in ~/.mozilla/firefox/*.*/ 51 for f in ~/.mozilla/firefox/*.*/
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h
index 29db8372f..46620b829 100644
--- a/src/include/gnunet_protocols.h
+++ b/src/include/gnunet_protocols.h
@@ -2633,7 +2633,7 @@ extern "C"
2633 */ 2633 */
2634#define GNUNET_MESSAGE_TYPE_RPS_CS_SEED 954 2634#define GNUNET_MESSAGE_TYPE_RPS_CS_SEED 954
2635 2635
2636#ifdef ENABLE_MALICIOUS 2636#if ENABLE_MALICIOUS
2637/** 2637/**
2638 * Turn RPS service malicious 2638 * Turn RPS service malicious
2639 */ 2639 */
diff --git a/src/include/gnunet_rps_service.h b/src/include/gnunet_rps_service.h
index 8ae9f1e93..b1dd1b5af 100644
--- a/src/include/gnunet_rps_service.h
+++ b/src/include/gnunet_rps_service.h
@@ -137,7 +137,7 @@ GNUNET_RPS_seed_ids (struct GNUNET_RPS_Handle *h, uint32_t n,
137GNUNET_RPS_request_cancel (struct GNUNET_RPS_Request_Handle *rh); 137GNUNET_RPS_request_cancel (struct GNUNET_RPS_Request_Handle *rh);
138 138
139 139
140#ifdef ENABLE_MALICIOUS 140#if ENABLE_MALICIOUS
141/** 141/**
142 * Turn RPS service to act malicious. 142 * Turn RPS service to act malicious.
143 * 143 *
diff --git a/src/integration-tests/gnunet_testing.py.in b/src/integration-tests/gnunet_testing.py.in
index dcfc99e8d..c9342ecf0 100644
--- a/src/integration-tests/gnunet_testing.py.in
+++ b/src/integration-tests/gnunet_testing.py.in
@@ -68,7 +68,6 @@ class Check(object):
68 execs += 1 68 execs += 1
69 if ((False == res) and (execs >= timeout)): 69 if ((False == res) and (execs >= timeout)):
70 logger.debug('Check had timeout after %s seconds', str(timeout)) 70 logger.debug('Check had timeout after %s seconds', str(timeout))
71 # print(('Check had timeout after ' + str(timeout) + ' seconds'))
72 neg_cont(self) 71 neg_cont(self)
73 elif ((False == res) and (execs < timeout)): 72 elif ((False == res) and (execs < timeout)):
74 if (None != neg_cont): 73 if (None != neg_cont):
@@ -96,7 +95,6 @@ class Check(object):
96 neg += 1 95 neg += 1
97 else: 96 else:
98 pos += 1 97 pos += 1
99 # print((str(pos) + ' out of ' + str(pos+neg) + ' conditions fulfilled'))
100 logger.debug('%s out of %s conditions fulfilled', str(pos), str(pos+neg)) 98 logger.debug('%s out of %s conditions fulfilled', str(pos), str(pos+neg))
101 return self.fulfilled 99 return self.fulfilled
102 100
@@ -120,10 +118,8 @@ class Condition(object):
120 118
121 def evaluate(self, failed_only): 119 def evaluate(self, failed_only):
122 if ((self.fulfilled == False) and (failed_only == True)): 120 if ((self.fulfilled == False) and (failed_only == True)):
123 # print(str(self.type) + 'condition for was ' + str(self.fulfilled))
124 logger.debug('%s condition for was %s', str(self.type), str(self.fulfilled)) 121 logger.debug('%s condition for was %s', str(self.type), str(self.fulfilled))
125 elif (failed_only == False): 122 elif (failed_only == False):
126 # print(str(self.type) + 'condition for was ' + str(self.fulfilled))
127 logger.debug('%s condition for was %s', str(self.type), str(self.fulfilled)) 123 logger.debug('%s condition for was %s', str(self.type), str(self.fulfilled))
128 return self.fulfilled 124 return self.fulfilled
129 125
@@ -147,18 +143,8 @@ class FileExistCondition(Condition):
147 143
148 def evaluate(self, failed_only): 144 def evaluate(self, failed_only):
149 if ((self.fulfilled == False) and (failed_only == True)): 145 if ((self.fulfilled == False) and (failed_only == True)):
150 # print(str(self.type) +
151 # 'condition for file ' +
152 # self.file +
153 # ' was ' +
154 # str(self.fulfilled))
155 logger.debug('%s confition for file %s was %s', str(self.type), self.file, str(self.fulfilled)) 146 logger.debug('%s confition for file %s was %s', str(self.type), self.file, str(self.fulfilled))
156 elif (failed_only == False): 147 elif (failed_only == False):
157 # print(str(self.type) +
158 # 'condition for file ' +
159 # self.file +
160 # ' was ' +
161 # str(self.fulfilled))
162 logger.debug('%s confition for file %s was %s', str(self.type), self.file, str(self.fulfilled)) 148 logger.debug('%s confition for file %s was %s', str(self.type), self.file, str(self.fulfilled))
163 return self.fulfilled 149 return self.fulfilled
164 150
@@ -170,13 +156,13 @@ class StatisticsCondition(Condition):
170 self.peer = peer 156 self.peer = peer
171 self.subsystem = subsystem 157 self.subsystem = subsystem
172 self.name = name 158 self.name = name
173 self.value = value 159 self.value = str(value)
174 self.result = -1 160 self.result = -1
175 161
176 def check(self): 162 def check(self):
177 if (self.fulfilled == False): 163 if (self.fulfilled == False):
178 self.result = self.peer.get_statistics_value(self.subsystem, self.name) 164 self.result = self.peer.get_statistics_value(self.subsystem, self.name)
179 if (str(self.result) == str(self.value)): 165 if (self.result == self.value):
180 self.fulfilled = True 166 self.fulfilled = True
181 return True 167 return True
182 else: 168 else:
@@ -185,32 +171,14 @@ class StatisticsCondition(Condition):
185 return True 171 return True
186 172
187 def evaluate(self, failed_only): 173 def evaluate(self, failed_only):
188 if (self.result == -1):
189 res = b'NaN'
190 else:
191 res = str(self.result).encode('utf-8')
192 if (self.fulfilled == False): 174 if (self.fulfilled == False):
193 fail = b" FAIL!" 175 fail = " FAIL!"
194 op = b" != " 176 op = " != "
195 else: 177 else:
196 fail = b"" 178 fail = ""
197 op = b" == " 179 op = " == "
198 if (((self.fulfilled == False) and (failed_only == True)) or (failed_only == False)): 180 if (((self.fulfilled == False) and (failed_only == True)) or (failed_only == False)):
199 # print(self.peer.id[:4] + 181 logger.debug('%s %s condition in subsystem %s: %s: (expected/real value) %s %s %s %s', self.peer.id[:4].decode("utf-8"), self.peer.cfg, self.subsystem.ljust(12), self.name.ljust(30), self.value, op, self.result, fail)
200 # b" " +
201 # self.peer.cfg.encode('utf-8') +
202 # b" " +
203 # str(self.type).encode('utf-8') +
204 # b' condition in subsystem "' +
205 # self.subsystem.encode('utf-8').ljust(12) +
206 # b'" : "' +
207 # self.name.encode('utf-8').ljust(30) +
208 # b'" : (expected/real value) ' +
209 # str(self.value).encode('utf-8') +
210 # op +
211 # res +
212 # fail)
213 logger.debug('%s %s %s condition in subsystem %s : %s : (expected/real value) %s %s %s %s', self.peer.id[:4], self.peer.cfg.encode('utf-8'), str(self.type).encode('utf-8'), self.subsystem.encode('utf-8').ljust(12), self.name.encode('utf-8').ljust(30), str(self.value).encode('utf-8'), op, res, fail)
214 return self.fulfilled 182 return self.fulfilled
215 183
216 184
@@ -232,7 +200,7 @@ class EqualStatisticsCondition(Condition):
232 if (self.fulfilled == False): 200 if (self.fulfilled == False):
233 self.result = self.peer.get_statistics_value(self.subsystem, self.name) 201 self.result = self.peer.get_statistics_value(self.subsystem, self.name)
234 self.result2 = self.peer2.get_statistics_value(self.subsystem2, self.name2) 202 self.result2 = self.peer2.get_statistics_value(self.subsystem2, self.name2)
235 if (str(self.result) == str(self.result2)): 203 if (self.result == self.result2):
236 self.fulfilled = True 204 self.fulfilled = True
237 return True 205 return True
238 else: 206 else:
@@ -241,37 +209,8 @@ class EqualStatisticsCondition(Condition):
241 return True 209 return True
242 210
243 def evaluate(self, failed_only): 211 def evaluate(self, failed_only):
244 if (self.result == -1):
245 res = b'NaN'
246 else:
247 res = str(self.result).encode('utf-8')
248 if (self.result2 == -1):
249 res2 = b'NaN'
250 else:
251 res2 = str(self.result2).encode('utf-8')
252 if (self.fulfilled == False):
253 fail = b" FAIL!"
254 op = b" != "
255 else:
256 fail = b""
257 op = b" == "
258 if (((self.fulfilled == False) and (failed_only == True)) or (failed_only == False)): 212 if (((self.fulfilled == False) and (failed_only == True)) or (failed_only == False)):
259 # print(self.peer.id[:4] + 213 logger.debug('%s %s %s == %s %s %s %s %s', self.peer.id[:4], self.subsystem.ljust(12), self.name.ljust(30), self.result, self.peer2.id[:4], self.subsystem2.ljust(12), self.name2.ljust(30), self.result2)
260 # b' "' +
261 # self.subsystem.encode('utf-8').ljust(12) +
262 # b'" "' +
263 # self.name.encode('utf-8').ljust(30) +
264 # b'" == ' +
265 # str(self.result).encode('utf-8') +
266 # b" " +
267 # self.peer2.id[:4] +
268 # b' "' +
269 # self.subsystem2.encode('utf-8').ljust(12) +
270 # b'" ' +
271 # self.name2.encode('utf-8').ljust(30) +
272 # b'" ' +
273 # str(self.result2).encode('utf-8'))
274 logger.debug('%s %s %s == %s %s %s %s %s', self.peer.id[:4], self.subsystem.encode('utf-8').ljust(12), self.name.encode('utf-8').ljust(30), str(self.result).encode('utf-8'), self.peer2.id[:4], self.subsystem2.encode('uft-8').ljust(12), self.name2.encode('utf-8').ljust(30), str(self.result2).encode('utf-8'))
275 return self.fulfilled 214 return self.fulfilled
276 215
277 216
@@ -333,6 +272,9 @@ class Peer(object):
333 return False 272 return False
334 273
335 def start(self): 274 def start(self):
275 os.unsetenv ("XDG_CONFIG_HOME")
276 os.unsetenv ("XDG_DATA_HOME")
277 os.unsetenv ("XDG_CACHE_HOME")
336 self.test.p("Starting peer using cfg " + self.cfg) 278 self.test.p("Starting peer using cfg " + self.cfg)
337 try: 279 try:
338 server = subprocess.Popen([self.test.gnunetarm, '-sq', '-c', self.cfg]) 280 server = subprocess.Popen([self.test.gnunetarm, '-sq', '-c', self.cfg])
@@ -379,11 +321,10 @@ class Peer(object):
379 if os.name == 'nt' and tests[1] == b'\n' and tests[0][-1] == b'\r': 321 if os.name == 'nt' and tests[1] == b'\n' and tests[0][-1] == b'\r':
380 tests = (tests[0][:-1], tests[1], tests[2]) 322 tests = (tests[0][:-1], tests[1], tests[2])
381 tests = tests[0] 323 tests = tests[0]
382 # print("running gnunet-statistics " + self.cfg + " for " + name + "/" + subsystem + " yields " + tests.decode("utf-8")) 324 result = tests.decode("utf-8").strip()
383 logger.debug('running gnunet-statistics %s for %s "/" %s yields %s', self.cfg, name, subsystem, test.decode("utf-8")) 325 logger.debug('running gnunet-statistics %s for %s "/" %s yields %s', self.cfg, name, subsystem, result)
384 if (tests.isdigit() == True): 326 if (result.isdigit() == True):
385 return tests 327 return result
386 else: 328 else:
387 # print("Invalid statistics value: " + str(tests) + " is not a number!") 329 logger.debug('Invalid statistics value: %s is not a number!', result)
388 logger.debug('Invalid statistics value: %s is not a number!', str(tests))
389 return -1 330 return -1
diff --git a/src/integration-tests/test_integration_bootstrap_and_connect.py.in b/src/integration-tests/test_integration_bootstrap_and_connect.py.in
index 560a429fd..f0de1c0cd 100755
--- a/src/integration-tests/test_integration_bootstrap_and_connect.py.in
+++ b/src/integration-tests/test_integration_bootstrap_and_connect.py.in
@@ -11,7 +11,7 @@
11# WITHOUT ANY WARRANTY; without even the implied warranty of 11# WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13# Affero General Public License for more details. 13# Affero General Public License for more details.
14# 14#
15# You should have received a copy of the GNU Affero General Public License 15# You should have received a copy of the GNU Affero General Public License
16# along with this program. If not, see <http://www.gnu.org/licenses/>. 16# along with this program. If not, see <http://www.gnu.org/licenses/>.
17# 17#
diff --git a/src/integration-tests/test_integration_disconnect.py.in b/src/integration-tests/test_integration_disconnect.py.in
index e1e431a0a..a81c78540 100755
--- a/src/integration-tests/test_integration_disconnect.py.in
+++ b/src/integration-tests/test_integration_disconnect.py.in
@@ -108,17 +108,17 @@ def fail_connect_cont (check):
108 108
109def check_connect (): 109def check_connect ():
110 check = Check (test) 110 check = Check (test)
111 check.add (StatisticsCondition (client, 'transport', '# peers connected',2)) 111 check.add (StatisticsCondition (server, 'transport', '# peers connected',1))
112 check.add (StatisticsCondition (client, 'core', '# peers connected',2)) 112 check.add (StatisticsCondition (server, 'core', '# peers connected',1))
113 check.add (StatisticsCondition (client, 'topology', '# peers connected',2)) 113 check.add (StatisticsCondition (server, 'topology', '# peers connected',1))
114 check.add (StatisticsCondition (client, 'dht', '# peers connected',2)) 114 check.add (StatisticsCondition (server, 'dht', '# peers connected',1))
115 check.add (StatisticsCondition (client, 'fs', '# peers connected',2)) 115 check.add (StatisticsCondition (server, 'fs', '# peers connected',1))
116 116
117 check.add (StatisticsCondition (server, 'transport', '# peers connected',2)) 117 check.add (StatisticsCondition (client, 'transport', '# peers connected',1))
118 check.add (StatisticsCondition (server, 'core', '# peers connected',2)) 118 check.add (StatisticsCondition (client, 'core', '# peers connected',1))
119 check.add (StatisticsCondition (server, 'topology', '# peers connected',2)) 119 check.add (StatisticsCondition (client, 'topology', '# peers connected',1))
120 check.add (StatisticsCondition (server, 'dht', '# peers connected',2)) 120 check.add (StatisticsCondition (client, 'dht', '# peers connected',1))
121 check.add (StatisticsCondition (server, 'fs', '# peers connected',2)) 121 check.add (StatisticsCondition (client, 'fs', '# peers connected',1))
122 122
123 check.run_blocking (check_timeout, success_connect_cont, fail_connect_cont) 123 check.run_blocking (check_timeout, success_connect_cont, fail_connect_cont)
124 124
diff --git a/src/integration-tests/test_integration_disconnect_nat.py.in b/src/integration-tests/test_integration_disconnect_nat.py.in
index 825c1cfa1..601586f47 100755
--- a/src/integration-tests/test_integration_disconnect_nat.py.in
+++ b/src/integration-tests/test_integration_disconnect_nat.py.in
@@ -11,7 +11,7 @@
11# WITHOUT ANY WARRANTY; without even the implied warranty of 11# WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13# Affero General Public License for more details. 13# Affero General Public License for more details.
14# 14#
15# You should have received a copy of the GNU Affero General Public License 15# You should have received a copy of the GNU Affero General Public License
16# along with this program. If not, see <http://www.gnu.org/licenses/>. 16# along with this program. If not, see <http://www.gnu.org/licenses/>.
17# 17#
diff --git a/src/integration-tests/test_integration_reconnect.py.in b/src/integration-tests/test_integration_reconnect.py.in
index 573ae221a..e8abacd48 100755
--- a/src/integration-tests/test_integration_reconnect.py.in
+++ b/src/integration-tests/test_integration_reconnect.py.in
@@ -11,13 +11,13 @@
11# WITHOUT ANY WARRANTY; without even the implied warranty of 11# WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13# Affero General Public License for more details. 13# Affero General Public License for more details.
14# 14#
15# You should have received a copy of the GNU Affero General Public License 15# You should have received a copy of the GNU Affero General Public License
16# along with this program. If not, see <http://www.gnu.org/licenses/>. 16# along with this program. If not, see <http://www.gnu.org/licenses/>.
17# 17#
18# SPDX-License-Identifier: AGPL3.0-or-later 18# SPDX-License-Identifier: AGPL3.0-or-later
19# 19#
20# 20#
21from __future__ import print_function 21from __future__ import print_function
22import sys 22import sys
23import os 23import os
@@ -30,13 +30,13 @@ from gnunet_testing import Peer
30from gnunet_testing import Test 30from gnunet_testing import Test
31from gnunet_testing import Check 31from gnunet_testing import Check
32from gnunet_testing import Condition 32from gnunet_testing import Condition
33from gnunet_testing import * 33from gnunet_testing import *
34 34
35 35
36# 36#
37# This test tests if a fresh peer bootstraps from a hostlist server and then 37# This test tests if a fresh peer bootstraps from a hostlist server and then
38# successfully connects to the server. When both peers are connected 38# successfully connects to the server. When both peers are connected
39# in transport, core, topology, fs, botth peers are shutdown and restarted 39# in transport, core, topology, fs, botth peers are shutdown and restarted
40# 40#
41# Conditions for successful exit: 41# Conditions for successful exit:
42# Both peers have 1 connected peer in transport, core, topology, fs after restart 42# Both peers have 1 connected peer in transport, core, topology, fs after restart
@@ -68,68 +68,68 @@ def cleanup_onerror (function, path, excinfo):
68 68
69def cleanup (): 69def cleanup ():
70 retries = 10 70 retries = 10
71 path = os.path.join (tmp, "c_bootstrap_server") 71 path = os.path.join (tmp, "c_bootstrap_server")
72 test.p ("Removing " + path) 72 test.p ("Removing " + path)
73 while ((os.path.exists(path)) and (retries > 0)): 73 while ((os.path.exists(path)) and (retries > 0)):
74 shutil.rmtree ((path), False, cleanup_onerror) 74 shutil.rmtree ((path), False, cleanup_onerror)
75 time.sleep (1) 75 time.sleep (1)
76 retries -= 1 76 retries -= 1
77 if (os.path.exists(path)): 77 if (os.path.exists(path)):
78 test.p ("Failed to remove " + path) 78 test.p ("Failed to remove " + path)
79 79
80 80
81 retries = 10 81 retries = 10
82 path = os.path.join (tmp, "c_no_nat_client") 82 path = os.path.join (tmp, "c_no_nat_client")
83 test.p ("Removing " + path) 83 test.p ("Removing " + path)
84 while ((os.path.exists(path)) and (retries > 0)): 84 while ((os.path.exists(path)) and (retries > 0)):
85 shutil.rmtree ((path), False, cleanup_onerror) 85 shutil.rmtree ((path), False, cleanup_onerror)
86 time.sleep (1) 86 time.sleep (1)
87 retries -= 1 87 retries -= 1
88 if (os.path.exists(path)): 88 if (os.path.exists(path)):
89 test.p ("Failed to remove " + path) 89 test.p ("Failed to remove " + path)
90 90
91def success_restart_cont (check): 91def success_restart_cont (check):
92 global success 92 global success
93 print('Peers connected successfully after restart') 93 print('Peers connected successfully after restart')
94 server.stop () 94 server.stop ()
95 client.stop () 95 client.stop ()
96 success = True; 96 success = True;
97 97
98 98
99def fail_restart_cont (check): 99def fail_restart_cont (check):
100 global success 100 global success
101 success = False; 101 success = False;
102 print('Peers failed to connect after restart') 102 print('Peers failed to connect after restart')
103 check.evaluate(True) 103 check.evaluate(True)
104 104
105 105
106def success_connect_cont (check): 106def success_connect_cont (check):
107 print('Peers connected successfully') 107 print('Peers connected successfully')
108 server.stop () 108 server.stop ()
109 client.stop () 109 client.stop ()
110 110
111 time.sleep(5) 111 time.sleep(5)
112 112
113 test.p ('Restarting client & server') 113 test.p ('Restarting client & server')
114 server.start () 114 server.start ()
115 client.start () 115 client.start ()
116 116
117 check = Check (test) 117 check = Check (test)
118 check.add (StatisticsCondition (client, 'transport', '# peers connected',1)) 118 check.add (StatisticsCondition (client, 'transport', '# peers connected',1))
119 check.add (StatisticsCondition (client, 'core', '# peers connected',1)) 119 check.add (StatisticsCondition (client, 'core', '# peers connected',1))
120 check.add (StatisticsCondition (client, 'topology', '# peers connected',1)) 120 check.add (StatisticsCondition (client, 'topology', '# peers connected',1))
121 check.add (StatisticsCondition (client, 'fs', '# peers connected',1)) 121 check.add (StatisticsCondition (client, 'fs', '# peers connected',1))
122 122
123 check.add (StatisticsCondition (server, 'transport', '# peers connected',1)) 123 check.add (StatisticsCondition (server, 'transport', '# peers connected',1))
124 check.add (StatisticsCondition (server, 'core', '# peers connected',1)) 124 check.add (StatisticsCondition (server, 'core', '# peers connected',1))
125 check.add (StatisticsCondition (server, 'topology', '# peers connected',1)) 125 check.add (StatisticsCondition (server, 'topology', '# peers connected',1))
126 check.add (StatisticsCondition (server, 'fs', '# peers connected',1)) 126 check.add (StatisticsCondition (server, 'fs', '# peers connected',1))
127 127
128 check.run_blocking (check_timeout, success_restart_cont, fail_restart_cont) 128 check.run_blocking (check_timeout, success_restart_cont, fail_restart_cont)
129 129
130 130
131def fail_connect_cont (check): 131def fail_connect_cont (check):
132 global success 132 global success
133 success= False; 133 success= False;
134 print('Peers failed to connect') 134 print('Peers failed to connect')
135 check.evaluate(True) 135 check.evaluate(True)
@@ -141,28 +141,28 @@ def check_connect ():
141 check.add (StatisticsCondition (client, 'core', '# peers connected',1)) 141 check.add (StatisticsCondition (client, 'core', '# peers connected',1))
142 check.add (StatisticsCondition (client, 'topology', '# peers connected',1)) 142 check.add (StatisticsCondition (client, 'topology', '# peers connected',1))
143 check.add (StatisticsCondition (client, 'fs', '# peers connected',1)) 143 check.add (StatisticsCondition (client, 'fs', '# peers connected',1))
144 144
145 check.add (StatisticsCondition (server, 'transport', '# peers connected',1)) 145 check.add (StatisticsCondition (server, 'transport', '# peers connected',1))
146 check.add (StatisticsCondition (server, 'core', '# peers connected',1)) 146 check.add (StatisticsCondition (server, 'core', '# peers connected',1))
147 check.add (StatisticsCondition (server, 'topology', '# peers connected',1)) 147 check.add (StatisticsCondition (server, 'topology', '# peers connected',1))
148 check.add (StatisticsCondition (server, 'fs', '# peers connected',1)) 148 check.add (StatisticsCondition (server, 'fs', '# peers connected',1))
149 149
150 check.run_blocking (check_timeout, success_connect_cont, fail_connect_cont) 150 check.run_blocking (check_timeout, success_connect_cont, fail_connect_cont)
151 151
152# 152#
153# Test execution 153# Test execution
154# 154#
155 155
156 156
157def SigHandler(signum = None, frame = None): 157def SigHandler(signum = None, frame = None):
158 global success 158 global success
159 global server 159 global server
160 global client 160 global client
161 161
162 print('Test was aborted!') 162 print('Test was aborted!')
163 if (None != server): 163 if (None != server):
164 server.stop () 164 server.stop ()
165 if (None != client): 165 if (None != client):
166 client.stop () 166 client.stop ()
167 cleanup () 167 cleanup ()
168 sys.exit(success) 168 sys.exit(success)
@@ -172,68 +172,66 @@ def run ():
172 global test 172 global test
173 global server 173 global server
174 global client 174 global client
175 175
176 success = False 176 success = False
177 server = None 177 server = None
178 client = None 178 client = None
179 179
180 for sig in signals: 180 for sig in signals:
181 signal.signal(sig, SigHandler) 181 signal.signal(sig, SigHandler)
182 182
183 183
184 test = Test ('test_integration_disconnect', verbose) 184 test = Test ('test_integration_disconnect', verbose)
185 cleanup () 185 cleanup ()
186 server = Peer(test, './confs/c_bootstrap_server.conf'); 186 server = Peer(test, './confs/c_bootstrap_server.conf');
187 server.start(); 187 server.start();
188 188
189 client = Peer(test, './confs/c_no_nat_client.conf'); 189 client = Peer(test, './confs/c_no_nat_client.conf');
190 client.start(); 190 client.start();
191 191
192 192
193 if (True != server.start()): 193 if (True != server.start()):
194 print('Failed to start server') 194 print('Failed to start server')
195 if (None != server): 195 if (None != server):
196 server.stop () 196 server.stop ()
197 if (None != server): 197 if (None != server):
198 client.stop () 198 client.stop ()
199 cleanup () 199 cleanup ()
200 sys.exit(success) 200 sys.exit(success)
201 201
202 # Give the server time to start 202 # Give the server time to start
203 time.sleep(5) 203 time.sleep(5)
204 204
205 if (True != client.start()): 205 if (True != client.start()):
206 print('Failed to start client') 206 print('Failed to start client')
207 if (None != server): 207 if (None != server):
208 server.stop () 208 server.stop ()
209 if (None != server): 209 if (None != server):
210 client.stop () 210 client.stop ()
211 cleanup () 211 cleanup ()
212 sys.exit(success) 212 sys.exit(success)
213 213
214 check_connect () 214 check_connect ()
215 215
216 server.stop () 216 server.stop ()
217 client.stop () 217 client.stop ()
218 cleanup () 218 cleanup ()
219 219
220 if (success == False): 220 if (success == False):
221 print ('Test failed') 221 print ('Test failed')
222 return True 222 return True
223 else: 223 else:
224 return False 224 return False
225 225
226 226
227try: 227try:
228 run () 228 run ()
229except (KeyboardInterrupt, SystemExit): 229except (KeyboardInterrupt, SystemExit):
230 print('Test interrupted') 230 print('Test interrupted')
231 server.stop () 231 server.stop ()
232 client.stop () 232 client.stop ()
233 cleanup () 233 cleanup ()
234if (success == False): 234if (success == False):
235 sys.exit(1) 235 sys.exit(1)
236else: 236else:
237 sys.exit(0) 237 sys.exit(0)
238
239
diff --git a/src/integration-tests/test_integration_reconnect_nat.py.in b/src/integration-tests/test_integration_reconnect_nat.py.in
index 5b3f34d02..61d2ea966 100755
--- a/src/integration-tests/test_integration_reconnect_nat.py.in
+++ b/src/integration-tests/test_integration_reconnect_nat.py.in
@@ -11,7 +11,7 @@
11# WITHOUT ANY WARRANTY; without even the implied warranty of 11# WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13# Affero General Public License for more details. 13# Affero General Public License for more details.
14# 14#
15# You should have received a copy of the GNU Affero General Public License 15# You should have received a copy of the GNU Affero General Public License
16# along with this program. If not, see <http://www.gnu.org/licenses/>. 16# along with this program. If not, see <http://www.gnu.org/licenses/>.
17# 17#
diff --git a/src/namestore/test_plugin_namestore.c b/src/namestore/test_plugin_namestore.c
index 30778ed69..9c978749f 100644
--- a/src/namestore/test_plugin_namestore.c
+++ b/src/namestore/test_plugin_namestore.c
@@ -107,7 +107,8 @@ test_record (void *cls,
107 GNUNET_snprintf (tname, 107 GNUNET_snprintf (tname,
108 sizeof (tname), 108 sizeof (tname),
109 "a%u", 109 "a%u",
110 (unsigned int ) id); 110 (unsigned int) id);
111 GNUNET_assert (trd_count == rd_count);
111 for (unsigned int i=0;i<trd_count;i++) 112 for (unsigned int i=0;i<trd_count;i++)
112 { 113 {
113 GNUNET_assert (rd[i].data_size == id % 10); 114 GNUNET_assert (rd[i].data_size == id % 10);
diff --git a/src/peerinfo/peerinfo_api.c b/src/peerinfo/peerinfo_api.c
index f2af27c0b..4b56b34c7 100644
--- a/src/peerinfo/peerinfo_api.c
+++ b/src/peerinfo/peerinfo_api.c
@@ -11,7 +11,7 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
@@ -565,10 +565,7 @@ GNUNET_PEERINFO_add_peer (struct GNUNET_PEERINFO_Handle *h,
565 struct GNUNET_PeerIdentity peer; 565 struct GNUNET_PeerIdentity peer;
566 566
567 if (NULL == h->mq) 567 if (NULL == h->mq)
568 {
569 GNUNET_break (0);
570 return NULL; 568 return NULL;
571 }
572 GNUNET_assert (GNUNET_OK == 569 GNUNET_assert (GNUNET_OK ==
573 GNUNET_HELLO_get_id (hello, 570 GNUNET_HELLO_get_id (hello,
574 &peer)); 571 &peer));
diff --git a/src/peerstore/peerstore_api.c b/src/peerstore/peerstore_api.c
index 6abdef43a..243e26c8b 100644
--- a/src/peerstore/peerstore_api.c
+++ b/src/peerstore/peerstore_api.c
@@ -11,7 +11,7 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
@@ -76,6 +76,16 @@ struct GNUNET_PEERSTORE_Handle
76 struct GNUNET_CONTAINER_MultiHashMap *watches; 76 struct GNUNET_CONTAINER_MultiHashMap *watches;
77 77
78 /** 78 /**
79 * ID of the task trying to reconnect to the service.
80 */
81 struct GNUNET_SCHEDULER_Task *reconnect_task;
82
83 /**
84 * Delay until we try to reconnect.
85 */
86 struct GNUNET_TIME_Relative reconnect_delay;
87
88 /**
79 * Are we in the process of disconnecting but need to sync first? 89 * Are we in the process of disconnecting but need to sync first?
80 */ 90 */
81 int disconnecting; 91 int disconnecting;
@@ -245,10 +255,72 @@ struct GNUNET_PEERSTORE_WatchContext
245/** 255/**
246 * Close the existing connection to PEERSTORE and reconnect. 256 * Close the existing connection to PEERSTORE and reconnect.
247 * 257 *
248 * @param h handle to the service 258 * @param cls a `struct GNUNET_PEERSTORE_Handle *h`
259 */
260static void
261reconnect (void *cls);
262
263
264/**
265 * Disconnect from the peerstore service.
266 *
267 * @param h peerstore handle to disconnect
268 */
269static void
270disconnect (struct GNUNET_PEERSTORE_Handle *h)
271{
272 struct GNUNET_PEERSTORE_IterateContext *next;
273
274 for (struct GNUNET_PEERSTORE_IterateContext *ic = h->iterate_head;
275 NULL != ic;
276 ic = next)
277 {
278 next = ic->next;
279 if (GNUNET_YES == ic->iterating)
280 {
281 GNUNET_PEERSTORE_Processor icb;
282 void *icb_cls;
283
284 icb = ic->callback;
285 icb_cls = ic->callback_cls;
286 GNUNET_PEERSTORE_iterate_cancel (ic);
287 if (NULL != icb)
288 icb (icb_cls,
289 NULL,
290 "Iteration canceled due to reconnection");
291 }
292 }
293
294 if (NULL != h->mq)
295 {
296 GNUNET_MQ_destroy (h->mq);
297 h->mq = NULL;
298 }
299}
300
301
302/**
303 * Function that will schedule the job that will try
304 * to connect us again to the client.
305 *
306 * @param h peerstore to reconnect
249 */ 307 */
250static void 308static void
251reconnect (struct GNUNET_PEERSTORE_Handle *h); 309disconnect_and_schedule_reconnect (struct GNUNET_PEERSTORE_Handle *h)
310{
311 GNUNET_assert (NULL == h->reconnect_task);
312 disconnect (h);
313 LOG (GNUNET_ERROR_TYPE_DEBUG,
314 "Scheduling task to reconnect to PEERSTORE service in %s.\n",
315 GNUNET_STRINGS_relative_time_to_string (h->reconnect_delay,
316 GNUNET_YES));
317 h->reconnect_task =
318 GNUNET_SCHEDULER_add_delayed (h->reconnect_delay,
319 &reconnect,
320 h);
321 h->reconnect_delay = GNUNET_TIME_STD_BACKOFF (h->reconnect_delay);
322}
323
252 324
253 325
254/** 326/**
@@ -288,7 +360,7 @@ handle_client_error (void *cls,
288 LOG (GNUNET_ERROR_TYPE_ERROR, 360 LOG (GNUNET_ERROR_TYPE_ERROR,
289 "Received an error notification from MQ of type: %d\n", 361 "Received an error notification from MQ of type: %d\n",
290 error); 362 error);
291 reconnect (h); 363 disconnect_and_schedule_reconnect (h);
292} 364}
293 365
294 366
@@ -345,7 +417,7 @@ destroy_watch (void *cls,
345 * @param h Handle to the service. 417 * @param h Handle to the service.
346 */ 418 */
347static void 419static void
348do_disconnect (struct GNUNET_PEERSTORE_Handle *h) 420final_disconnect (struct GNUNET_PEERSTORE_Handle *h)
349{ 421{
350 if (NULL != h->mq) 422 if (NULL != h->mq)
351 { 423 {
@@ -419,7 +491,7 @@ GNUNET_PEERSTORE_disconnect (struct GNUNET_PEERSTORE_Handle *h,
419 while (NULL != (sc = h->store_head)) 491 while (NULL != (sc = h->store_head))
420 GNUNET_PEERSTORE_store_cancel (sc); 492 GNUNET_PEERSTORE_store_cancel (sc);
421 } 493 }
422 do_disconnect (h); 494 final_disconnect (h);
423} 495}
424 496
425 497
@@ -443,8 +515,9 @@ GNUNET_PEERSTORE_store_cancel (struct GNUNET_PEERSTORE_StoreContext *sc)
443 GNUNET_free (sc->value); 515 GNUNET_free (sc->value);
444 GNUNET_free (sc->key); 516 GNUNET_free (sc->key);
445 GNUNET_free (sc); 517 GNUNET_free (sc);
446 if ((GNUNET_YES == h->disconnecting) && (NULL == h->store_head)) 518 if ( (GNUNET_YES == h->disconnecting) &&
447 do_disconnect (h); 519 (NULL == h->store_head) )
520 final_disconnect (h);
448} 521}
449 522
450 523
@@ -530,7 +603,7 @@ handle_iterate_end (void *cls,
530 { 603 {
531 LOG (GNUNET_ERROR_TYPE_ERROR, 604 LOG (GNUNET_ERROR_TYPE_ERROR,
532 _("Unexpected iteration response, this should not happen.\n")); 605 _("Unexpected iteration response, this should not happen.\n"));
533 reconnect (h); 606 disconnect_and_schedule_reconnect (h);
534 return; 607 return;
535 } 608 }
536 callback = ic->callback; 609 callback = ic->callback;
@@ -538,7 +611,10 @@ handle_iterate_end (void *cls,
538 ic->iterating = GNUNET_NO; 611 ic->iterating = GNUNET_NO;
539 GNUNET_PEERSTORE_iterate_cancel (ic); 612 GNUNET_PEERSTORE_iterate_cancel (ic);
540 if (NULL != callback) 613 if (NULL != callback)
541 callback (callback_cls, NULL, NULL); 614 callback (callback_cls,
615 NULL,
616 NULL);
617 h->reconnect_delay = GNUNET_TIME_UNIT_ZERO;
542} 618}
543 619
544 620
@@ -579,7 +655,7 @@ handle_iterate_result (void *cls,
579 { 655 {
580 LOG (GNUNET_ERROR_TYPE_ERROR, 656 LOG (GNUNET_ERROR_TYPE_ERROR,
581 _("Unexpected iteration response, this should not happen.\n")); 657 _("Unexpected iteration response, this should not happen.\n"));
582 reconnect (h); 658 disconnect_and_schedule_reconnect (h);
583 return; 659 return;
584 } 660 }
585 ic->iterating = GNUNET_YES; 661 ic->iterating = GNUNET_YES;
@@ -715,7 +791,7 @@ handle_watch_record (void *cls,
715 record = PEERSTORE_parse_record_message (msg); 791 record = PEERSTORE_parse_record_message (msg);
716 if (NULL == record) 792 if (NULL == record)
717 { 793 {
718 reconnect (h); 794 disconnect_and_schedule_reconnect (h);
719 return; 795 return;
720 } 796 }
721 PEERSTORE_hash_key (record->sub_system, 797 PEERSTORE_hash_key (record->sub_system,
@@ -730,13 +806,14 @@ handle_watch_record (void *cls,
730 LOG (GNUNET_ERROR_TYPE_ERROR, 806 LOG (GNUNET_ERROR_TYPE_ERROR,
731 _("Received a watch result for a non existing watch.\n")); 807 _("Received a watch result for a non existing watch.\n"));
732 PEERSTORE_destroy_record (record); 808 PEERSTORE_destroy_record (record);
733 reconnect (h); 809 disconnect_and_schedule_reconnect (h);
734 return; 810 return;
735 } 811 }
736 if (NULL != wc->callback) 812 if (NULL != wc->callback)
737 wc->callback (wc->callback_cls, 813 wc->callback (wc->callback_cls,
738 record, 814 record,
739 NULL); 815 NULL);
816 h->reconnect_delay = GNUNET_TIME_UNIT_ZERO;
740 PEERSTORE_destroy_record (record); 817 PEERSTORE_destroy_record (record);
741} 818}
742 819
@@ -744,11 +821,12 @@ handle_watch_record (void *cls,
744/** 821/**
745 * Close the existing connection to PEERSTORE and reconnect. 822 * Close the existing connection to PEERSTORE and reconnect.
746 * 823 *
747 * @param h handle to the service 824 * @param cls a `struct GNUNET_PEERSTORE_Handle *`
748 */ 825 */
749static void 826static void
750reconnect (struct GNUNET_PEERSTORE_Handle *h) 827reconnect (void *cls)
751{ 828{
829 struct GNUNET_PEERSTORE_Handle *h = cls;
752 struct GNUNET_MQ_MessageHandler mq_handlers[] = { 830 struct GNUNET_MQ_MessageHandler mq_handlers[] = {
753 GNUNET_MQ_hd_fixed_size (iterate_end, 831 GNUNET_MQ_hd_fixed_size (iterate_end,
754 GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE_END, 832 GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE_END,
@@ -764,34 +842,10 @@ reconnect (struct GNUNET_PEERSTORE_Handle *h)
764 h), 842 h),
765 GNUNET_MQ_handler_end () 843 GNUNET_MQ_handler_end ()
766 }; 844 };
767 struct GNUNET_PEERSTORE_IterateContext *ic;
768 struct GNUNET_PEERSTORE_IterateContext *next;
769 GNUNET_PEERSTORE_Processor icb;
770 void *icb_cls;
771 struct GNUNET_PEERSTORE_StoreContext *sc;
772 struct GNUNET_MQ_Envelope *ev; 845 struct GNUNET_MQ_Envelope *ev;
773 846
774 LOG (GNUNET_ERROR_TYPE_DEBUG, 847 LOG (GNUNET_ERROR_TYPE_DEBUG,
775 "Reconnecting...\n"); 848 "Reconnecting...\n");
776 for (ic = h->iterate_head; NULL != ic; ic = next)
777 {
778 next = ic->next;
779 if (GNUNET_YES == ic->iterating)
780 {
781 icb = ic->callback;
782 icb_cls = ic->callback_cls;
783 GNUNET_PEERSTORE_iterate_cancel (ic);
784 if (NULL != icb)
785 icb (icb_cls,
786 NULL,
787 "Iteration canceled due to reconnection");
788 }
789 }
790 if (NULL != h->mq)
791 {
792 GNUNET_MQ_destroy (h->mq);
793 h->mq = NULL;
794 }
795 h->mq = GNUNET_CLIENT_connect (h->cfg, 849 h->mq = GNUNET_CLIENT_connect (h->cfg,
796 "peerstore", 850 "peerstore",
797 mq_handlers, 851 mq_handlers,
@@ -805,7 +859,9 @@ reconnect (struct GNUNET_PEERSTORE_Handle *h)
805 GNUNET_CONTAINER_multihashmap_iterate (h->watches, 859 GNUNET_CONTAINER_multihashmap_iterate (h->watches,
806 &rewatch_it, 860 &rewatch_it,
807 h); 861 h);
808 for (ic = h->iterate_head; NULL != ic; ic = ic->next) 862 for (struct GNUNET_PEERSTORE_IterateContext *ic = h->iterate_head;
863 NULL != ic;
864 ic = ic->next)
809 { 865 {
810 ev = PEERSTORE_create_record_mq_envelope (ic->sub_system, 866 ev = PEERSTORE_create_record_mq_envelope (ic->sub_system,
811 &ic->peer, 867 &ic->peer,
@@ -816,7 +872,9 @@ reconnect (struct GNUNET_PEERSTORE_Handle *h)
816 GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE); 872 GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE);
817 GNUNET_MQ_send (h->mq, ev); 873 GNUNET_MQ_send (h->mq, ev);
818 } 874 }
819 for (sc = h->store_head; NULL != sc; sc = sc->next) 875 for (struct GNUNET_PEERSTORE_StoreContext *sc = h->store_head;
876 NULL != sc;
877 sc = sc->next)
820 { 878 {
821 ev = PEERSTORE_create_record_mq_envelope (sc->sub_system, 879 ev = PEERSTORE_create_record_mq_envelope (sc->sub_system,
822 &sc->peer, 880 &sc->peer,
diff --git a/src/pq/pq_result_helper.c b/src/pq/pq_result_helper.c
index b0f0a8a6b..336ca8c42 100644
--- a/src/pq/pq_result_helper.c
+++ b/src/pq/pq_result_helper.c
@@ -11,7 +11,7 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
diff --git a/src/rps/gnunet-rps-profiler.c b/src/rps/gnunet-rps-profiler.c
index 36a167203..937a4363b 100644
--- a/src/rps/gnunet-rps-profiler.c
+++ b/src/rps/gnunet-rps-profiler.c
@@ -1574,7 +1574,7 @@ static void mal_init_peer (struct RPSPeer *rps_peer)
1574static void 1574static void
1575mal_pre (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h) 1575mal_pre (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h)
1576{ 1576{
1577 #ifdef ENABLE_MALICIOUS 1577 #if ENABLE_MALICIOUS
1578 uint32_t num_mal_peers; 1578 uint32_t num_mal_peers;
1579 1579
1580 GNUNET_assert ( (1 >= portion) && 1580 GNUNET_assert ( (1 >= portion) &&
@@ -1605,7 +1605,7 @@ mal_cb (struct RPSPeer *rps_peer)
1605 return; 1605 return;
1606 } 1606 }
1607 1607
1608 #ifdef ENABLE_MALICIOUS 1608 #if ENABLE_MALICIOUS
1609 GNUNET_assert ( (1 >= portion) && 1609 GNUNET_assert ( (1 >= portion) &&
1610 (0 < portion) ); 1610 (0 < portion) );
1611 num_mal_peers = round (portion * num_peers); 1611 num_mal_peers = round (portion * num_peers);
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index 08f2450f5..e3e25342e 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -11,7 +11,7 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
@@ -261,7 +261,7 @@ struct ChannelCtx
261}; 261};
262 262
263 263
264#ifdef ENABLE_MALICIOUS 264#if ENABLE_MALICIOUS
265 265
266/** 266/**
267 * If type is 2 This struct is used to store the attacked peers in a DLL 267 * If type is 2 This struct is used to store the attacked peers in a DLL
@@ -492,7 +492,7 @@ static struct GNUNET_PEERINFO_Handle *peerinfo_handle;
492static struct GNUNET_PEERINFO_NotifyContext *peerinfo_notify_handle; 492static struct GNUNET_PEERINFO_NotifyContext *peerinfo_notify_handle;
493 493
494 494
495#ifdef ENABLE_MALICIOUS 495#if ENABLE_MALICIOUS
496/** 496/**
497 * Type of malicious peer 497 * Type of malicious peer
498 * 498 *
@@ -2576,7 +2576,7 @@ insert_in_sampler (void *cls,
2576 * messages to it */ 2576 * messages to it */
2577 //indicate_sending_intention (peer); 2577 //indicate_sending_intention (peer);
2578 } 2578 }
2579 #ifdef TO_FILE 2579#ifdef TO_FILE
2580 sub->num_observed_peers++; 2580 sub->num_observed_peers++;
2581 GNUNET_CONTAINER_multipeermap_put 2581 GNUNET_CONTAINER_multipeermap_put
2582 (sub->observed_unique_peers, 2582 (sub->observed_unique_peers,
@@ -2590,7 +2590,7 @@ insert_in_sampler (void *cls,
2590 sub->num_observed_peers, 2590 sub->num_observed_peers,
2591 num_observed_unique_peers, 2591 num_observed_unique_peers,
2592 1.0*num_observed_unique_peers/sub->num_observed_peers) 2592 1.0*num_observed_unique_peers/sub->num_observed_peers)
2593 #endif /* TO_FILE */ 2593#endif /* TO_FILE */
2594} 2594}
2595 2595
2596 2596
@@ -2701,7 +2701,7 @@ clean_peer (struct Sub *sub,
2701 LOG (GNUNET_ERROR_TYPE_DEBUG, 2701 LOG (GNUNET_ERROR_TYPE_DEBUG,
2702 "Going to remove send channel to peer %s\n", 2702 "Going to remove send channel to peer %s\n",
2703 GNUNET_i2s (peer)); 2703 GNUNET_i2s (peer));
2704 #ifdef ENABLE_MALICIOUS 2704 #if ENABLE_MALICIOUS
2705 if (0 != GNUNET_CRYPTO_cmp_peer_identity (&attacked_peer, peer)) 2705 if (0 != GNUNET_CRYPTO_cmp_peer_identity (&attacked_peer, peer))
2706 (void) destroy_sending_channel (get_peer_ctx (sub->peer_map, peer)); 2706 (void) destroy_sending_channel (get_peer_ctx (sub->peer_map, peer));
2707 #else /* ENABLE_MALICIOUS */ 2707 #else /* ENABLE_MALICIOUS */
@@ -2874,7 +2874,7 @@ new_sub (const struct GNUNET_HashCode *hash,
2874 2874
2875 /* Logging of internals */ 2875 /* Logging of internals */
2876 sub->file_name_view_log = store_prefix_file_name (&own_identity, "view"); 2876 sub->file_name_view_log = store_prefix_file_name (&own_identity, "view");
2877 #ifdef TO_FILE 2877#ifdef TO_FILE
2878 sub->file_name_observed_log = store_prefix_file_name (&own_identity, 2878 sub->file_name_observed_log = store_prefix_file_name (&own_identity,
2879 "observed"); 2879 "observed");
2880 sub->file_name_push_recv = store_prefix_file_name (&own_identity, 2880 sub->file_name_push_recv = store_prefix_file_name (&own_identity,
@@ -2884,7 +2884,7 @@ new_sub (const struct GNUNET_HashCode *hash,
2884 sub->num_observed_peers = 0; 2884 sub->num_observed_peers = 0;
2885 sub->observed_unique_peers = GNUNET_CONTAINER_multipeermap_create (1, 2885 sub->observed_unique_peers = GNUNET_CONTAINER_multipeermap_create (1,
2886 GNUNET_NO); 2886 GNUNET_NO);
2887 #endif /* TO_FILE */ 2887#endif /* TO_FILE */
2888 2888
2889 /* Set up data structures for gossip */ 2889 /* Set up data structures for gossip */
2890 sub->push_map = CustomPeerMap_create (4); 2890 sub->push_map = CustomPeerMap_create (4);
@@ -3436,7 +3436,7 @@ handle_peer_push (void *cls,
3436 GNUNET_STATISTICS_update(stats, "# push message received", 1, GNUNET_NO); 3436 GNUNET_STATISTICS_update(stats, "# push message received", 1, GNUNET_NO);
3437 } 3437 }
3438 3438
3439 #ifdef ENABLE_MALICIOUS 3439 #if ENABLE_MALICIOUS
3440 struct AttackedPeer *tmp_att_peer; 3440 struct AttackedPeer *tmp_att_peer;
3441 3441
3442 if ( (1 == mal_type) || 3442 if ( (1 == mal_type) ||
@@ -3512,7 +3512,7 @@ handle_peer_pull_request (void *cls,
3512 } 3512 }
3513 } 3513 }
3514 3514
3515 #ifdef ENABLE_MALICIOUS 3515 #if ENABLE_MALICIOUS
3516 if (1 == mal_type 3516 if (1 == mal_type
3517 || 3 == mal_type) 3517 || 3 == mal_type)
3518 { /* Try to maximise representation */ 3518 { /* Try to maximise representation */
@@ -3606,7 +3606,7 @@ handle_peer_pull_reply (void *cls,
3606 const struct GNUNET_PeerIdentity *peers; 3606 const struct GNUNET_PeerIdentity *peers;
3607 struct Sub *sub = channel_ctx->peer_ctx->sub; 3607 struct Sub *sub = channel_ctx->peer_ctx->sub;
3608 uint32_t i; 3608 uint32_t i;
3609#ifdef ENABLE_MALICIOUS 3609#if ENABLE_MALICIOUS
3610 struct AttackedPeer *tmp_att_peer; 3610 struct AttackedPeer *tmp_att_peer;
3611#endif /* ENABLE_MALICIOUS */ 3611#endif /* ENABLE_MALICIOUS */
3612 3612
@@ -3628,7 +3628,7 @@ handle_peer_pull_reply (void *cls,
3628 } 3628 }
3629 } 3629 }
3630 3630
3631 #ifdef ENABLE_MALICIOUS 3631 #if ENABLE_MALICIOUS
3632 // We shouldn't even receive pull replies as we're not sending 3632 // We shouldn't even receive pull replies as we're not sending
3633 if (2 == mal_type) 3633 if (2 == mal_type)
3634 { 3634 {
@@ -3649,7 +3649,7 @@ handle_peer_pull_reply (void *cls,
3649 i, 3649 i,
3650 GNUNET_i2s (&peers[i])); 3650 GNUNET_i2s (&peers[i]));
3651 3651
3652 #ifdef ENABLE_MALICIOUS 3652 #if ENABLE_MALICIOUS
3653 if ((NULL != att_peer_set) && 3653 if ((NULL != att_peer_set) &&
3654 (1 == mal_type || 3 == mal_type)) 3654 (1 == mal_type || 3 == mal_type))
3655 { /* Add attacked peer to local list */ 3655 { /* Add attacked peer to local list */
@@ -3812,7 +3812,7 @@ send_push (struct PeerContext *peer_ctx)
3812} 3812}
3813 3813
3814 3814
3815#ifdef ENABLE_MALICIOUS 3815#if ENABLE_MALICIOUS
3816 3816
3817 3817
3818/** 3818/**
@@ -4534,7 +4534,7 @@ shutdown_task (void *cls)
4534 } 4534 }
4535 GNUNET_CADET_disconnect (cadet_handle); 4535 GNUNET_CADET_disconnect (cadet_handle);
4536 cadet_handle = NULL; 4536 cadet_handle = NULL;
4537#ifdef ENABLE_MALICIOUS 4537#if ENABLE_MALICIOUS
4538 struct AttackedPeer *tmp_att_peer; 4538 struct AttackedPeer *tmp_att_peer;
4539 GNUNET_array_grow (mal_peers, 4539 GNUNET_array_grow (mal_peers,
4540 num_mal_peers, 4540 num_mal_peers,
@@ -4647,7 +4647,7 @@ run (void *cls,
4647 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 4647 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
4648 "STARTING SERVICE (rps) for peer [%s]\n", 4648 "STARTING SERVICE (rps) for peer [%s]\n",
4649 GNUNET_i2s (&own_identity)); 4649 GNUNET_i2s (&own_identity));
4650#ifdef ENABLE_MALICIOUS 4650#if ENABLE_MALICIOUS
4651 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 4651 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
4652 "Malicious execution compiled in.\n"); 4652 "Malicious execution compiled in.\n");
4653#endif /* ENABLE_MALICIOUS */ 4653#endif /* ENABLE_MALICIOUS */
@@ -4740,7 +4740,7 @@ GNUNET_SERVICE_MAIN
4740 GNUNET_MESSAGE_TYPE_RPS_CS_SEED, 4740 GNUNET_MESSAGE_TYPE_RPS_CS_SEED,
4741 struct GNUNET_RPS_CS_SeedMessage, 4741 struct GNUNET_RPS_CS_SeedMessage,
4742 NULL), 4742 NULL),
4743#ifdef ENABLE_MALICIOUS 4743#if ENABLE_MALICIOUS
4744 GNUNET_MQ_hd_var_size (client_act_malicious, 4744 GNUNET_MQ_hd_var_size (client_act_malicious,
4745 GNUNET_MESSAGE_TYPE_RPS_ACT_MALICIOUS, 4745 GNUNET_MESSAGE_TYPE_RPS_ACT_MALICIOUS,
4746 struct GNUNET_RPS_CS_ActMaliciousMessage, 4746 struct GNUNET_RPS_CS_ActMaliciousMessage,
diff --git a/src/rps/rps-test_util.h b/src/rps/rps-test_util.h
index cf15a9909..484d0f7da 100644
--- a/src/rps/rps-test_util.h
+++ b/src/rps/rps-test_util.h
@@ -11,7 +11,7 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
@@ -28,7 +28,7 @@
28#ifndef RPS_TEST_UTIL_H 28#ifndef RPS_TEST_UTIL_H
29#define RPS_TEST_UTIL_H 29#define RPS_TEST_UTIL_H
30 30
31#define TO_FILE 1 31#define TO_FILE 0
32 32
33 33
34char * 34char *
diff --git a/src/rps/rps.h b/src/rps/rps.h
index ef968ffbb..5bfef93b0 100644
--- a/src/rps/rps.h
+++ b/src/rps/rps.h
@@ -79,7 +79,7 @@ struct GNUNET_RPS_CS_SeedMessage
79 /* Followed by num_peers * GNUNET_PeerIdentity */ 79 /* Followed by num_peers * GNUNET_PeerIdentity */
80}; 80};
81 81
82#ifdef ENABLE_MALICIOUS 82#if ENABLE_MALICIOUS
83/** 83/**
84 * Message from client to service to turn service malicious. 84 * Message from client to service to turn service malicious.
85 */ 85 */
diff --git a/src/rps/rps_api.c b/src/rps/rps_api.c
index 6fac4cf6f..d0b241a2b 100644
--- a/src/rps/rps_api.c
+++ b/src/rps/rps_api.c
@@ -806,7 +806,7 @@ GNUNET_RPS_seed_ids (struct GNUNET_RPS_Handle *h,
806} 806}
807 807
808 808
809#ifdef ENABLE_MALICIOUS 809#if ENABLE_MALICIOUS
810/** 810/**
811 * Turn RPS service to act malicious. 811 * Turn RPS service to act malicious.
812 * 812 *
diff --git a/src/rps/test_rps.c b/src/rps/test_rps.c
index 126cc5dec..26066bf10 100644
--- a/src/rps/test_rps.c
+++ b/src/rps/test_rps.c
@@ -1357,7 +1357,7 @@ static void mal_init_peer (struct RPSPeer *rps_peer)
1357static void 1357static void
1358mal_pre (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h) 1358mal_pre (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h)
1359{ 1359{
1360 #ifdef ENABLE_MALICIOUS 1360 #if ENABLE_MALICIOUS
1361 uint32_t num_mal_peers; 1361 uint32_t num_mal_peers;
1362 1362
1363 GNUNET_assert ( (1 >= portion) && 1363 GNUNET_assert ( (1 >= portion) &&
@@ -1388,7 +1388,7 @@ mal_cb (struct RPSPeer *rps_peer)
1388 return; 1388 return;
1389 } 1389 }
1390 1390
1391 #ifdef ENABLE_MALICIOUS 1391 #if ENABLE_MALICIOUS
1392 GNUNET_assert ( (1 >= portion) && 1392 GNUNET_assert ( (1 >= portion) &&
1393 (0 < portion) ); 1393 (0 < portion) );
1394 num_mal_peers = round (portion * num_peers); 1394 num_mal_peers = round (portion * num_peers);
diff --git a/src/secretsharing/test_secretsharing.conf b/src/secretsharing/test_secretsharing.conf
index 3391c88db..7c8e45480 100644
--- a/src/secretsharing/test_secretsharing.conf
+++ b/src/secretsharing/test_secretsharing.conf
@@ -34,3 +34,7 @@ RETURN_LOCAL_ADDRESSES = YES
34[nse] 34[nse]
35START_ON_DEMAND = NO 35START_ON_DEMAND = NO
36 36
37
38[rps]
39START_ON_DEMAND = NO
40IMMEDIATE_START = NO
diff --git a/src/sq/sq.c b/src/sq/sq.c
index 36200aa26..e74071b81 100644
--- a/src/sq/sq.c
+++ b/src/sq/sq.c
@@ -11,7 +11,7 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
diff --git a/src/testbed/test_testbed_api_template.conf b/src/testbed/test_testbed_api_template.conf
index 381c1bd85..43ae06f81 100644
--- a/src/testbed/test_testbed_api_template.conf
+++ b/src/testbed/test_testbed_api_template.conf
@@ -43,3 +43,7 @@ RETURN_LOCAL_ADDRESSES = YES
43 43
44[peerinfo] 44[peerinfo]
45NO_IO = YES 45NO_IO = YES
46
47[rps]
48START_ON_DEMAND = NO
49IMMEDIATE_START = NO
diff --git a/src/testing/test_testing_defaults.conf b/src/testing/test_testing_defaults.conf
index e6a18bc86..2e7c39113 100644
--- a/src/testing/test_testing_defaults.conf
+++ b/src/testing/test_testing_defaults.conf
@@ -19,3 +19,7 @@ INTERNAL_ADDRESS = 127.0.0.1
19EXTERNAL_ADDRESS = 127.0.0.1 19EXTERNAL_ADDRESS = 127.0.0.1
20USE_LOCALADDR = NO 20USE_LOCALADDR = NO
21 21
22
23[rps]
24START_ON_DEMAND = NO
25IMMEDIATE_START = NO
diff --git a/src/testing/test_testing_sharedservices.conf b/src/testing/test_testing_sharedservices.conf
index 24ce1b358..92eac7e71 100644
--- a/src/testing/test_testing_sharedservices.conf
+++ b/src/testing/test_testing_sharedservices.conf
@@ -24,3 +24,7 @@ INTERNAL_ADDRESS = 127.0.0.1
24EXTERNAL_ADDRESS = 127.0.0.1 24EXTERNAL_ADDRESS = 127.0.0.1
25USE_LOCALADDR = NO 25USE_LOCALADDR = NO
26 26
27
28[rps]
29START_ON_DEMAND = NO
30IMMEDIATE_START = NO
diff --git a/src/topology/test_gnunet_daemon_topology_data.conf b/src/topology/test_gnunet_daemon_topology_data.conf
index 43d3da375..8d8636bff 100644
--- a/src/topology/test_gnunet_daemon_topology_data.conf
+++ b/src/topology/test_gnunet_daemon_topology_data.conf
@@ -24,3 +24,7 @@ USE_HOSTNAME = NO
24 24
25[nse] 25[nse]
26WORKBITS = 0 26WORKBITS = 0
27
28[rps]
29START_ON_DEMAND = NO
30IMMEDIATE_START = NO
diff --git a/src/transport/transport_api2_address.c b/src/transport/transport_api2_address.c
index 1ae1e5b1e..1ff599efb 100644
--- a/src/transport/transport_api2_address.c
+++ b/src/transport/transport_api2_address.c
@@ -123,7 +123,7 @@ reconnect (void *cls)
123/** 123/**
124 * Disconnect from the transport service. 124 * Disconnect from the transport service.
125 * 125 *
126 * @param h transport service to reconnect 126 * @param h transport service to disconnect
127 */ 127 */
128static void 128static void
129disconnect (struct GNUNET_TRANSPORT_AddressHandle *h) 129disconnect (struct GNUNET_TRANSPORT_AddressHandle *h)
diff --git a/src/transport/transport_api_core.c b/src/transport/transport_api_core.c
index b144ef6b6..75287b5e7 100644
--- a/src/transport/transport_api_core.c
+++ b/src/transport/transport_api_core.c
@@ -558,7 +558,7 @@ handle_connect (void *cls,
558 &cim->id); 558 &cim->id);
559 if (NULL != n) 559 if (NULL != n)
560 { 560 {
561 GNUNET_break (0); 561 GNUNET_break (0); /* FIXME: this assertion seems to fail sometimes!? */
562 disconnect_and_schedule_reconnect (h); 562 disconnect_and_schedule_reconnect (h);
563 return; 563 return;
564 } 564 }
diff --git a/src/util/container_multihashmap.c b/src/util/container_multihashmap.c
index cf5c2a334..7605ea151 100644
--- a/src/util/container_multihashmap.c
+++ b/src/util/container_multihashmap.c
@@ -11,7 +11,7 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
@@ -417,7 +417,7 @@ GNUNET_CONTAINER_multihashmap_iterate (struct GNUNET_CONTAINER_MultiHashMap *map
417 } 417 }
418 } 418 }
419 } 419 }
420 GNUNET_assert (--map->next_cache_off < NEXT_CACHE_SIZE); 420 GNUNET_assert (--map->next_cache_off < NEXT_CACHE_SIZE);
421 return count; 421 return count;
422} 422}
423 423
@@ -764,18 +764,19 @@ grow (struct GNUNET_CONTAINER_MultiHashMap *map)
764 unsigned int new_len; 764 unsigned int new_len;
765 unsigned int idx; 765 unsigned int idx;
766 766
767 map->modification_counter++;
768
769 old_map = map->map; 767 old_map = map->map;
770 old_len = map->map_length; 768 old_len = map->map_length;
769 GNUNET_assert (0 != old_len);
771 new_len = old_len * 2; 770 new_len = old_len * 2;
772 /* if we would exceed heap size limit for the _first_ time, 771 if (0 == new_len) /* 2^31 * 2 == 0 */
773 try staying just below the limit */ 772 new_len = old_len; /* never use 0 */
774 if ( (new_len * sizeof (union MapEntry) > GNUNET_MAX_MALLOC_CHECKED) && 773 if (new_len == old_len)
775 ((old_len+1) * sizeof (union MapEntry) < GNUNET_MAX_MALLOC_CHECKED) ) 774 return; /* nothing changed */
776 new_len = GNUNET_MAX_MALLOC_CHECKED / sizeof (union MapEntry); 775 new_map = GNUNET_malloc_large (new_len *
777 new_map = GNUNET_new_array (new_len, 776 sizeof (union MapEntry));
778 union MapEntry); 777 if (NULL == new_map)
778 return; /* grow not possible */
779 map->modification_counter++;
779 map->map_length = new_len; 780 map->map_length = new_len;
780 map->map = new_map; 781 map->map = new_map;
781 for (unsigned int i = 0; i < old_len; i++) 782 for (unsigned int i = 0; i < old_len; i++)
diff --git a/src/util/container_multihashmap32.c b/src/util/container_multihashmap32.c
index 4b19c7c10..a614c04ae 100644
--- a/src/util/container_multihashmap32.c
+++ b/src/util/container_multihashmap32.c
@@ -11,7 +11,7 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
@@ -146,8 +146,13 @@ GNUNET_CONTAINER_multihashmap32_create (unsigned int len)
146 146
147 GNUNET_assert (len > 0); 147 GNUNET_assert (len > 0);
148 ret = GNUNET_new (struct GNUNET_CONTAINER_MultiHashMap32); 148 ret = GNUNET_new (struct GNUNET_CONTAINER_MultiHashMap32);
149 ret->map = GNUNET_new_array (len, 149 ret->map = GNUNET_malloc_large (len *
150 struct MapEntry *); 150 sizeof (struct MapEntry *));
151 if (NULL == ret->map)
152 {
153 GNUNET_free (ret);
154 return NULL;
155 }
151 ret->map_length = len; 156 ret->map_length = len;
152 return ret; 157 return ret;
153} 158}
@@ -268,7 +273,7 @@ GNUNET_CONTAINER_multihashmap32_iterate (struct GNUNET_CONTAINER_MultiHashMap32
268 e->key, 273 e->key,
269 e->value)) 274 e->value))
270 { 275 {
271 GNUNET_assert (--map->next_cache_off < NEXT_CACHE_SIZE); 276 GNUNET_assert (--map->next_cache_off < NEXT_CACHE_SIZE);
272 return GNUNET_SYSERR; 277 return GNUNET_SYSERR;
273 } 278 }
274 } 279 }
@@ -463,13 +468,18 @@ grow (struct GNUNET_CONTAINER_MultiHashMap32 *map)
463 unsigned int new_len; 468 unsigned int new_len;
464 unsigned int idx; 469 unsigned int idx;
465 470
466 map->modification_counter++;
467
468 old_map = map->map; 471 old_map = map->map;
469 old_len = map->map_length; 472 old_len = map->map_length;
470 new_len = old_len * 2; 473 new_len = old_len * 2;
471 new_map = GNUNET_new_array (new_len, 474 if (0 == new_len) /* 2^31 * 2 == 0 */
472 struct MapEntry *); 475 new_len = old_len; /* never use 0 */
476 if (new_len == old_len)
477 return; /* nothing changed */
478 new_map = GNUNET_malloc_large (new_len *
479 sizeof (struct MapEntry *));
480 if (NULL == new_map)
481 return; /* grow not possible */
482 map->modification_counter++;
473 map->map_length = new_len; 483 map->map_length = new_len;
474 map->map = new_map; 484 map->map = new_map;
475 for (unsigned int i = 0; i < old_len; i++) 485 for (unsigned int i = 0; i < old_len; i++)
diff --git a/src/util/container_multipeermap.c b/src/util/container_multipeermap.c
index 8fa23df72..613efc0a9 100644
--- a/src/util/container_multipeermap.c
+++ b/src/util/container_multipeermap.c
@@ -11,7 +11,7 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
@@ -200,8 +200,13 @@ GNUNET_CONTAINER_multipeermap_create (unsigned int len,
200 200
201 GNUNET_assert (len > 0); 201 GNUNET_assert (len > 0);
202 map = GNUNET_new (struct GNUNET_CONTAINER_MultiPeerMap); 202 map = GNUNET_new (struct GNUNET_CONTAINER_MultiPeerMap);
203 map->map = GNUNET_new_array (len, 203 map->map = GNUNET_malloc_large (len *
204 union MapEntry); 204 sizeof (union MapEntry));
205 if (NULL == map->map)
206 {
207 GNUNET_free (map);
208 return NULL;
209 }
205 map->map_length = len; 210 map->map_length = len;
206 map->use_small_entries = do_not_copy_keys; 211 map->use_small_entries = do_not_copy_keys;
207 return map; 212 return map;
@@ -493,7 +498,7 @@ GNUNET_CONTAINER_multipeermap_remove (struct GNUNET_CONTAINER_MultiPeerMap *map,
493 if (NULL == p) 498 if (NULL == p)
494 map->map[i].bme = bme->next; 499 map->map[i].bme = bme->next;
495 else 500 else
496 p->next = bme->next; 501 p->next = bme->next;
497 update_next_cache_bme (map, 502 update_next_cache_bme (map,
498 bme); 503 bme);
499 GNUNET_free (bme); 504 GNUNET_free (bme);
@@ -685,18 +690,23 @@ grow (struct GNUNET_CONTAINER_MultiPeerMap *map)
685 unsigned int old_len; 690 unsigned int old_len;
686 unsigned int new_len; 691 unsigned int new_len;
687 unsigned int idx; 692 unsigned int idx;
688 unsigned int i;
689
690 map->modification_counter++;
691 693
692 old_map = map->map; 694 old_map = map->map;
693 old_len = map->map_length; 695 old_len = map->map_length;
696 GNUNET_assert (0 != old_len);
694 new_len = old_len * 2; 697 new_len = old_len * 2;
695 new_map = GNUNET_new_array (new_len, 698 if (0 == new_len) /* 2^31 * 2 == 0 */
696 union MapEntry); 699 new_len = old_len; /* never use 0 */
700 if (new_len == old_len)
701 return; /* nothing changed */
702 new_map = GNUNET_malloc_large (new_len *
703 sizeof (union MapEntry));
704 if (NULL == new_map)
705 return; /* grow not possible */
706 map->modification_counter++;
697 map->map_length = new_len; 707 map->map_length = new_len;
698 map->map = new_map; 708 map->map = new_map;
699 for (i = 0; i < old_len; i++) 709 for (unsigned int i = 0; i < old_len; i++)
700 { 710 {
701 if (map->use_small_entries) 711 if (map->use_small_entries)
702 { 712 {
@@ -829,7 +839,7 @@ GNUNET_CONTAINER_multipeermap_get_multiple (struct GNUNET_CONTAINER_MultiPeerMap
829 int count; 839 int count;
830 union MapEntry me; 840 union MapEntry me;
831 union MapEntry *ce; 841 union MapEntry *ce;
832 842
833 ce = &map->next_cache[map->next_cache_off]; 843 ce = &map->next_cache[map->next_cache_off];
834 GNUNET_assert (++map->next_cache_off < NEXT_CACHE_SIZE); 844 GNUNET_assert (++map->next_cache_off < NEXT_CACHE_SIZE);
835 count = 0; 845 count = 0;
@@ -903,7 +913,7 @@ GNUNET_CONTAINER_multipeermap_get_random (const struct GNUNET_CONTAINER_MultiPee
903{ 913{
904 unsigned int off; 914 unsigned int off;
905 union MapEntry me; 915 union MapEntry me;
906 916
907 if (0 == map->size) 917 if (0 == map->size)
908 return 0; 918 return 0;
909 if (NULL == it) 919 if (NULL == it)
diff --git a/src/util/container_multishortmap.c b/src/util/container_multishortmap.c
index a48581b6a..966e23d35 100644
--- a/src/util/container_multishortmap.c
+++ b/src/util/container_multishortmap.c
@@ -11,7 +11,7 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
@@ -183,8 +183,8 @@ struct GNUNET_CONTAINER_MultiShortmapIterator
183 * Create a multi hash map. 183 * Create a multi hash map.
184 * 184 *
185 * @param len initial size (map will grow as needed) 185 * @param len initial size (map will grow as needed)
186 * @param do_not_copy_keys GNUNET_NO is always safe and should be used by default; 186 * @param do_not_copy_keys #GNUNET_NO is always safe and should be used by default;
187 * GNUNET_YES means that on 'put', the 'key' does not have 187 * #GNUNET_YES means that on 'put', the 'key' does not have
188 * to be copied as the destination of the pointer is 188 * to be copied as the destination of the pointer is
189 * guaranteed to be life as long as the value is stored in 189 * guaranteed to be life as long as the value is stored in
190 * the hashmap. This can significantly reduce memory 190 * the hashmap. This can significantly reduce memory
@@ -202,8 +202,13 @@ GNUNET_CONTAINER_multishortmap_create (unsigned int len,
202 202
203 GNUNET_assert (len > 0); 203 GNUNET_assert (len > 0);
204 map = GNUNET_new (struct GNUNET_CONTAINER_MultiShortmap); 204 map = GNUNET_new (struct GNUNET_CONTAINER_MultiShortmap);
205 map->map = GNUNET_new_array (len, 205 map->map = GNUNET_malloc_large (len *
206 union MapEntry); 206 sizeof (union MapEntry));
207 if (NULL == map->map)
208 {
209 GNUNET_free (map);
210 return NULL;
211 }
207 map->map_length = len; 212 map->map_length = len;
208 map->use_small_entries = do_not_copy_keys; 213 map->use_small_entries = do_not_copy_keys;
209 return map; 214 return map;
@@ -355,7 +360,7 @@ GNUNET_CONTAINER_multishortmap_iterate (struct GNUNET_CONTAINER_MultiShortmap *m
355 if (map->use_small_entries) 360 if (map->use_small_entries)
356 { 361 {
357 struct SmallMapEntry *sme; 362 struct SmallMapEntry *sme;
358 363
359 ce->sme = me.sme; 364 ce->sme = me.sme;
360 while (NULL != (sme = ce->sme)) 365 while (NULL != (sme = ce->sme))
361 { 366 {
@@ -366,7 +371,7 @@ GNUNET_CONTAINER_multishortmap_iterate (struct GNUNET_CONTAINER_MultiShortmap *m
366 sme->value)) ) 371 sme->value)) )
367 { 372 {
368 GNUNET_assert (--map->next_cache_off < NEXT_CACHE_SIZE); 373 GNUNET_assert (--map->next_cache_off < NEXT_CACHE_SIZE);
369 return GNUNET_SYSERR; 374 return GNUNET_SYSERR;
370 } 375 }
371 count++; 376 count++;
372 } 377 }
@@ -458,7 +463,7 @@ GNUNET_CONTAINER_multishortmap_remove (struct GNUNET_CONTAINER_MultiShortmap *ma
458 if (map->use_small_entries) 463 if (map->use_small_entries)
459 { 464 {
460 struct SmallMapEntry *p = NULL; 465 struct SmallMapEntry *p = NULL;
461 466
462 for (struct SmallMapEntry *sme = me.sme; NULL != sme; sme = sme->next) 467 for (struct SmallMapEntry *sme = me.sme; NULL != sme; sme = sme->next)
463 { 468 {
464 if ((0 == memcmp (key, 469 if ((0 == memcmp (key,
@@ -482,7 +487,7 @@ GNUNET_CONTAINER_multishortmap_remove (struct GNUNET_CONTAINER_MultiShortmap *ma
482 else 487 else
483 { 488 {
484 struct BigMapEntry *p = NULL; 489 struct BigMapEntry *p = NULL;
485 490
486 for (struct BigMapEntry *bme = me.bme; NULL != bme; bme = bme->next) 491 for (struct BigMapEntry *bme = me.bme; NULL != bme; bme = bme->next)
487 { 492 {
488 if ((0 == memcmp (key, 493 if ((0 == memcmp (key,
@@ -686,13 +691,18 @@ grow (struct GNUNET_CONTAINER_MultiShortmap *map)
686 unsigned int new_len; 691 unsigned int new_len;
687 unsigned int idx; 692 unsigned int idx;
688 693
689 map->modification_counter++;
690
691 old_map = map->map; 694 old_map = map->map;
692 old_len = map->map_length; 695 old_len = map->map_length;
693 new_len = old_len * 2; 696 new_len = old_len * 2;
694 new_map = GNUNET_new_array (new_len, 697 if (0 == new_len) /* 2^31 * 2 == 0 */
695 union MapEntry); 698 new_len = old_len; /* never use 0 */
699 if (new_len == old_len)
700 return; /* nothing changed */
701 new_map = GNUNET_malloc_large (new_len *
702 sizeof (union MapEntry));
703 if (NULL == new_map)
704 return; /* grow not possible */
705 map->modification_counter++;
696 map->map_length = new_len; 706 map->map_length = new_len;
697 map->map = new_map; 707 map->map = new_map;
698 for (unsigned int i = 0; i < old_len; i++) 708 for (unsigned int i = 0; i < old_len; i++)
diff --git a/src/util/mq.c b/src/util/mq.c
index d2f5add19..72ab8b72d 100644
--- a/src/util/mq.c
+++ b/src/util/mq.c
@@ -964,6 +964,7 @@ GNUNET_MQ_send_cancel (struct GNUNET_MQ_Envelope *ev)
964 { 964 {
965 /* complex case, we already started with transmitting 965 /* complex case, we already started with transmitting
966 the message using the callbacks. */ 966 the message using the callbacks. */
967 GNUNET_assert (GNUNET_NO == mq->in_flight);
967 GNUNET_assert (0 < mq->queue_length); 968 GNUNET_assert (0 < mq->queue_length);
968 mq->queue_length--; 969 mq->queue_length--;
969 mq->cancel_impl (mq, 970 mq->cancel_impl (mq,