summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2021-02-26 15:14:03 +0100
committerMartin Schanzenbach <mschanzenbach@posteo.de>2021-02-26 15:14:03 +0100
commitb2ef30b3eb815fbb34a519581e1afc8bac393269 (patch)
treea47374db9d377a98eb3e5863ec532f550ebf8a16
parent6edac715d38f2126ea7316373cfd27c3d76b05cf (diff)
-First message through TNG test done
-rw-r--r--src/peerstore/gnunet-service-peerstore.c15
-rw-r--r--src/transport/gnunet-service-tng.c124
-rw-r--r--src/transport/test_transport_api2_tcp_peer1.conf1
-rw-r--r--src/transport/test_transport_api2_tcp_peer2.conf2
-rw-r--r--src/transport/transport-testing2.c67
5 files changed, 112 insertions, 97 deletions
diff --git a/src/peerstore/gnunet-service-peerstore.c b/src/peerstore/gnunet-service-peerstore.c
index c92e4d3f0..959d088f9 100644
--- a/src/peerstore/gnunet-service-peerstore.c
+++ b/src/peerstore/gnunet-service-peerstore.c
@@ -77,6 +77,8 @@ static unsigned int num_clients;
static void
do_shutdown ()
{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Shutting down peerstore, bye.\n");
if (NULL != db_lib_name)
{
GNUNET_break (NULL == GNUNET_PLUGIN_unload (db_lib_name, db));
@@ -105,6 +107,8 @@ do_shutdown ()
static void
shutdown_task (void *cls)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Priming PEERSTORE for shutdown.\n");
in_shutdown = GNUNET_YES;
if (0 == num_clients) /* Only when no connected clients. */
do_shutdown ();
@@ -176,6 +180,8 @@ client_connect_cb (void *cls,
struct GNUNET_MQ_Handle *mq)
{
num_clients++;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "A client connected (now %u)\n", num_clients);
return client;
}
@@ -195,7 +201,7 @@ client_disconnect_it (void *cls, const struct GNUNET_HashCode *key, void *value)
{
GNUNET_assert (GNUNET_YES ==
GNUNET_CONTAINER_multihashmap_remove (watchers, key, value));
- num_clients++;
+ num_clients++; /* Watchers do not count */
}
return GNUNET_OK;
}
@@ -212,12 +218,14 @@ client_disconnect_cb (void *cls,
struct GNUNET_SERVICE_Client *client,
void *app_cls)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "A client disconnected, cleaning up.\n");
+ num_clients--;
if (NULL != watchers)
GNUNET_CONTAINER_multihashmap_iterate (watchers,
&client_disconnect_it,
client);
- num_clients--;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "A client disconnected (%u remaining).\n",
+ num_clients);
if ((0 == num_clients) && in_shutdown)
do_shutdown ();
}
@@ -540,6 +548,7 @@ run (void *cls,
char *database;
in_shutdown = GNUNET_NO;
+ num_clients = 0;
cfg = c;
if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg,
"peerstore",
diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c
index 64cb53ad8..aaa9f129b 100644
--- a/src/transport/gnunet-service-tng.c
+++ b/src/transport/gnunet-service-tng.c
@@ -2772,6 +2772,11 @@ static unsigned int pa_count;
*/
static struct GNUNET_TIME_Absolute hello_mono_time;
+/**
+ * Indication if we have received a shutdown signal
+ * and are in the process of cleaning up.
+ */
+static int in_shutdown;
/**
* Get an offset into the transmission history buffer for `struct
@@ -2805,6 +2810,7 @@ free_incoming_request (struct IncomingRequest *ir)
GNUNET_assert (ir_total > 0);
ir_total--;
GNUNET_PEERSTORE_watch_cancel (ir->wc);
+ ir->wc = NULL;
GNUNET_free (ir);
}
@@ -3333,6 +3339,8 @@ free_neighbour (struct Neighbour *neighbour)
GNUNET_CONTAINER_multipeermap_remove (neighbours,
&neighbour->pid,
neighbour));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Freeing neighbour\n");
if (NULL != neighbour->reassembly_map)
{
GNUNET_CONTAINER_multihashmap32_iterate (neighbour->reassembly_map,
@@ -3499,6 +3507,8 @@ check_link_down (void *cls)
struct GNUNET_TIME_Absolute dvh_timeout;
struct GNUNET_TIME_Absolute q_timeout;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Checking if link is down\n");
vl->visibility_task = NULL;
dvh_timeout = GNUNET_TIME_UNIT_ZERO_ABS;
if (NULL != dv)
@@ -3660,6 +3670,7 @@ stop_peer_request (void *cls,
struct PeerRequest *pr = value;
GNUNET_PEERSTORE_watch_cancel (pr->wc);
+ pr->wc = NULL;
GNUNET_assert (
GNUNET_YES ==
GNUNET_CONTAINER_multipeermap_remove (tc->details.application.requests,
@@ -3670,6 +3681,8 @@ stop_peer_request (void *cls,
return GNUNET_OK;
}
+static void
+do_shutdown (void *cls);
/**
* Called whenever a client is disconnected. Frees our
@@ -3688,16 +3701,20 @@ client_disconnect_cb (void *cls,
(void) cls;
(void) client;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Client %p disconnected, cleaning up.\n",
- tc);
GNUNET_CONTAINER_DLL_remove (clients_head, clients_tail, tc);
switch (tc->type)
{
case CT_NONE:
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Unknown Client %p disconnected, cleaning up.\n",
+ tc);
break;
case CT_CORE: {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "CORE Client %p disconnected, cleaning up.\n",
+ tc);
+
struct PendingMessage *pm;
while (NULL != (pm = tc->details.core.pending_msg_head))
@@ -3712,9 +3729,17 @@ client_disconnect_cb (void *cls,
break;
case CT_MONITOR:
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "MONITOR Client %p disconnected, cleaning up.\n",
+ tc);
+
break;
case CT_COMMUNICATOR: {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "COMMUNICATOR Client %p disconnected, cleaning up.\n",
+ tc);
+
struct Queue *q;
struct AddressListEntry *ale;
@@ -3727,6 +3752,10 @@ client_disconnect_cb (void *cls,
break;
case CT_APPLICATION:
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "APPLICATION Client %p disconnected, cleaning up.\n",
+ tc);
+
GNUNET_CONTAINER_multipeermap_iterate (tc->details.application.requests,
&stop_peer_request,
tc);
@@ -3734,6 +3763,12 @@ client_disconnect_cb (void *cls,
break;
}
GNUNET_free (tc);
+ if ((GNUNET_YES == in_shutdown) && (NULL == clients_head))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Our last client disconnected\n");
+ do_shutdown (cls);
+ }
}
@@ -5166,7 +5201,9 @@ handle_del_address (void *cls,
GNUNET_SERVICE_client_continue (tc->client);
return;
}
- GNUNET_break (0);
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Communicator removed address we did not even have.\n");
+ GNUNET_SERVICE_client_continue (tc->client);
//GNUNET_SERVICE_client_drop (tc->client);
}
@@ -10046,52 +10083,6 @@ free_ack_cummulator_cb (void *cls,
return GNUNET_OK;
}
-void
-cleanup_client (struct TransportClient *tc)
-{
- switch (tc->type)
- {
- case CT_NONE:
- break;
-
- case CT_CORE: {
- struct PendingMessage *pm;
-
- while (NULL != (pm = tc->details.core.pending_msg_head))
- {
- GNUNET_CONTAINER_MDLL_remove (client,
- tc->details.core.pending_msg_head,
- tc->details.core.pending_msg_tail,
- pm);
- pm->client = NULL;
- }
- }
- break;
-
- case CT_MONITOR:
- break;
-
- case CT_COMMUNICATOR: {
- struct Queue *q;
- struct AddressListEntry *ale;
-
- while (NULL != (q = tc->details.communicator.queue_head))
- free_queue (q);
- while (NULL != (ale = tc->details.communicator.addr_head))
- free_address_list_entry (ale);
- GNUNET_free (tc->details.communicator.address_prefix);
- }
- break;
-
- case CT_APPLICATION:
- GNUNET_CONTAINER_multipeermap_iterate (tc->details.application.requests,
- &stop_peer_request,
- tc);
- GNUNET_CONTAINER_multipeermap_destroy (tc->details.application.requests);
- break;
- }
-
-}
/**
* Function called when the service shuts down. Unloads our plugins
@@ -10103,20 +10094,10 @@ static void
do_shutdown (void *cls)
{
struct LearnLaunchEntry *lle;
- struct TransportClient *client;
(void) cls;
- for (client = clients_head; NULL != client; client = client->next)
- {
- cleanup_client (client);
- }
- //GNUNET_CONTAINER_multipeermap_iterate (neighbours,
- //&free_neighbour_cb, NULL);
- if (NULL != peerstore)
- {
- GNUNET_PEERSTORE_disconnect (peerstore, GNUNET_NO);
- peerstore = NULL;
- }
+ GNUNET_CONTAINER_multipeermap_iterate (neighbours,
+ &free_neighbour_cb, NULL);
if (NULL != validation_task)
{
GNUNET_SCHEDULER_cancel (validation_task);
@@ -10171,6 +10152,13 @@ do_shutdown (void *cls)
GNUNET_CONTAINER_DLL_remove (lle_head, lle_tail, lle);
GNUNET_free (lle);
}
+ if (NULL != peerstore)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Disconnecting from PEERSTORE service\n");
+ GNUNET_PEERSTORE_disconnect (peerstore, GNUNET_NO);
+ peerstore = NULL;
+ }
GNUNET_CONTAINER_multishortmap_destroy (dvlearn_map);
dvlearn_map = NULL;
GNUNET_CONTAINER_heap_destroy (validation_heap);
@@ -10178,6 +10166,15 @@ do_shutdown (void *cls)
GNUNET_CONTAINER_multipeermap_iterate (dv_routes, &free_dv_routes_cb, NULL);
GNUNET_CONTAINER_multipeermap_destroy (dv_routes);
dv_routes = NULL;
+ GNUNET_SCHEDULER_shutdown ();
+}
+
+static void
+shutdown_task (void *cls)
+{
+ in_shutdown = GNUNET_YES;
+ if (NULL == clients_head)
+ do_shutdown (cls);
}
@@ -10197,6 +10194,7 @@ run (void *cls,
(void) service;
/* setup globals */
hello_mono_time = GNUNET_TIME_absolute_get_monotonic (c);
+ in_shutdown = GNUNET_NO;
GST_cfg = c;
backtalkers = GNUNET_CONTAINER_multipeermap_create (16, GNUNET_YES);
pending_acks = GNUNET_CONTAINER_multiuuidmap_create (32768, GNUNET_YES);
@@ -10226,7 +10224,7 @@ run (void *cls,
"My identity is `%s'\n",
GNUNET_i2s_full (&GST_my_identity));
GST_stats = GNUNET_STATISTICS_create ("transport", GST_cfg);
- GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL);
+ GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL);
peerstore = GNUNET_PEERSTORE_connect (GST_cfg);
if (NULL == peerstore)
{
diff --git a/src/transport/test_transport_api2_tcp_peer1.conf b/src/transport/test_transport_api2_tcp_peer1.conf
index bc3434069..745ed6887 100644
--- a/src/transport/test_transport_api2_tcp_peer1.conf
+++ b/src/transport/test_transport_api2_tcp_peer1.conf
@@ -14,6 +14,7 @@ BINDTO = 60002
DISABLE_V6 = YES
IMMEDIATE_START = YES
UNIXPATH = $GNUNET_RUNTIME_DIR/tcp-comm-p1.sock
+#PREFIX = valgrind --log-file=/tmp/vg_cpeer1-%p
[peerstore]
IMMEDIATE_START = YES
diff --git a/src/transport/test_transport_api2_tcp_peer2.conf b/src/transport/test_transport_api2_tcp_peer2.conf
index 437fac65d..022468bcd 100644
--- a/src/transport/test_transport_api2_tcp_peer2.conf
+++ b/src/transport/test_transport_api2_tcp_peer2.conf
@@ -12,7 +12,7 @@ BINARY = gnunet-communicator-tcp
BINDTO = 60003
DISABLE_V6 = YES
IMMEDIATE_START = YES
-PREFIX = valgrind --log-file=/tmp/vg_comm2-%p
+#PREFIX = valgrind --log-file=/tmp/vg_comm2-%p
UNIXPATH = $GNUNET_RUNTIME_DIR/tcp-comm-p2.sock
[peerstore]
diff --git a/src/transport/transport-testing2.c b/src/transport/transport-testing2.c
index 1461915f0..789181d1f 100644
--- a/src/transport/transport-testing2.c
+++ b/src/transport/transport-testing2.c
@@ -328,6 +328,8 @@ notify_disconnect (void *cls,
}
}
+static void
+retrieve_hello (void *cls);
static void
hello_iter_cb (void *cb_cls,
@@ -339,6 +341,12 @@ hello_iter_cb (void *cb_cls,
{
p->pic = NULL;
LOG (GNUNET_ERROR_TYPE_DEBUG, "Iteration End\n");
+ if (NULL != p->start_cb)
+ {
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Did not yet get my hello. Retrying...\n");
+ p->rh_task = GNUNET_SCHEDULER_add_now (retrieve_hello, p);
+ }
return;
}
// Check record type et al?
@@ -536,12 +544,8 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct
// FIXME Error handling
p->ah = GNUNET_TRANSPORT_application_init (p->cfg);
GNUNET_assert (NULL != p->ah);
- // FIXME Error handleing
- p->rh_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (
- GNUNET_TIME_UNIT_SECONDS, 10),
- retrieve_hello,
- p);
- // GNUNET_assert (NULL != p->pic);
+ // FIXME Error handling
+ p->rh_task = GNUNET_SCHEDULER_add_now (retrieve_hello, p);
return p;
}
@@ -667,7 +671,7 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct
}
if (NULL != p->pic)
{
- // GNUNET_PEERSTORE_iterate_cancel (p->pic);
+ GNUNET_PEERSTORE_iterate_cancel (p->pic);
p->pic = NULL;
}
if (NULL != p->th)
@@ -675,19 +679,6 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct
GNUNET_TRANSPORT_core_disconnect (p->th);
p->th = NULL;
}
- if (NULL != p->peer)
- {
- if (GNUNET_OK !=
- GNUNET_TESTING_peer_stop (p->peer))
- {
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Testing lib failed to stop peer %u (`%s')\n",
- p->no,
- GNUNET_i2s (&p->id));
- }
- GNUNET_TESTING_peer_destroy (p->peer);
- p->peer = NULL;
- }
if (NULL != p->ats)
{
GNUNET_ATS_connectivity_done (p->ats);
@@ -700,9 +691,25 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct
}
if (NULL != p->ph)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Disconnecting from PEERSTORE service\n");
GNUNET_PEERSTORE_disconnect (p->ph, GNUNET_NO);
p->ph = NULL;
}
+
+ if (NULL != p->peer)
+ {
+ if (GNUNET_OK !=
+ GNUNET_TESTING_peer_stop (p->peer))
+ {
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Testing lib failed to stop peer %u (`%s')\n",
+ p->no,
+ GNUNET_i2s (&p->id));
+ }
+ GNUNET_TESTING_peer_destroy (p->peer);
+ p->peer = NULL;
+ }
if (NULL != p->hello)
{
GNUNET_free (p->hello);
@@ -738,16 +745,16 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct
* FIXME maybe schedule the application_validate somehow
*/
/*
-static void
-hello_offered (void *cls)
-{
- struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc = cls;
-
- cc->oh = NULL;
- cc->tct = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
- &offer_hello,
- cc);
-}*/
+ static void
+ hello_offered (void *cls)
+ {
+ struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc = cls;
+
+ cc->oh = NULL;
+ cc->tct = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
+ &offer_hello,
+ cc);
+ }*/
/**