aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/gnunet-communicator-tcp.c42
-rw-r--r--src/transport/gnunet-service-tng.c65
-rw-r--r--src/transport/test_transport_api2_tcp_peer1.conf2
-rw-r--r--src/transport/test_transport_api2_tcp_peer2.conf3
-rw-r--r--src/transport/transport-testing2.c32
-rw-r--r--src/transport/transport-testing2.h5
6 files changed, 131 insertions, 18 deletions
diff --git a/src/transport/gnunet-communicator-tcp.c b/src/transport/gnunet-communicator-tcp.c
index 273dbac48..c8a4c0375 100644
--- a/src/transport/gnunet-communicator-tcp.c
+++ b/src/transport/gnunet-communicator-tcp.c
@@ -739,7 +739,6 @@ struct Addresses
739}; 739};
740 740
741 741
742
743/** 742/**
744 * Maximum queue length before we stop reading towards the transport service. 743 * Maximum queue length before we stop reading towards the transport service.
745 */ 744 */
@@ -953,6 +952,9 @@ queue_destroy (struct Queue *queue)
953 else 952 else
954 GNUNET_free (queue); 953 GNUNET_free (queue);
955 954
955 if (NULL == lt)
956 return;
957
956 if ((! shutdown_running) && (NULL == lt->listen_task)) 958 if ((! shutdown_running) && (NULL == lt->listen_task))
957 { 959 {
958 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 960 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1193,6 +1195,7 @@ setup_cipher (const struct GNUNET_HashCode *dh,
1193 0)); 1195 0));
1194} 1196}
1195 1197
1198
1196/** 1199/**
1197 * Callback called when peerstore store operation for rekey monotime value is finished. 1200 * Callback called when peerstore store operation for rekey monotime value is finished.
1198 * @param cls Queue context the store operation was executed. 1201 * @param cls Queue context the store operation was executed.
@@ -1210,6 +1213,7 @@ rekey_monotime_store_cb (void *cls, int success)
1210 queue->rekey_monotime_sc = NULL; 1213 queue->rekey_monotime_sc = NULL;
1211} 1214}
1212 1215
1216
1213/** 1217/**
1214 * Callback called by peerstore when records for GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_REKEY 1218 * Callback called by peerstore when records for GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_REKEY
1215 * where found. 1219 * where found.
@@ -1266,6 +1270,7 @@ rekey_monotime_cb (void *cls,
1266 queue); 1270 queue);
1267} 1271}
1268 1272
1273
1269/** 1274/**
1270 * Setup cipher of @a queue for decryption. 1275 * Setup cipher of @a queue for decryption.
1271 * 1276 *
@@ -1344,6 +1349,7 @@ do_rekey (struct Queue *queue, const struct TCPRekey *rekey)
1344 setup_in_cipher (&rekey->ephemeral, queue); 1349 setup_in_cipher (&rekey->ephemeral, queue);
1345} 1350}
1346 1351
1352
1347/** 1353/**
1348 * Callback called when peerstore store operation for handshake ack monotime value is finished. 1354 * Callback called when peerstore store operation for handshake ack monotime value is finished.
1349 * @param cls Queue context the store operation was executed. 1355 * @param cls Queue context the store operation was executed.
@@ -1362,6 +1368,7 @@ handshake_ack_monotime_store_cb (void *cls, int success)
1362 queue->handshake_ack_monotime_sc = NULL; 1368 queue->handshake_ack_monotime_sc = NULL;
1363} 1369}
1364 1370
1371
1365/** 1372/**
1366 * Callback called by peerstore when records for GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE_ACK 1373 * Callback called by peerstore when records for GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE_ACK
1367 * where found. 1374 * where found.
@@ -1420,6 +1427,7 @@ handshake_ack_monotime_cb (void *cls,
1420 queue); 1427 queue);
1421} 1428}
1422 1429
1430
1423/** 1431/**
1424 * Sending challenge with TcpConfirmationAck back to sender of ephemeral key. 1432 * Sending challenge with TcpConfirmationAck back to sender of ephemeral key.
1425 * 1433 *
@@ -1465,6 +1473,7 @@ send_challenge (struct ChallengeNonceP challenge, struct Queue *queue)
1465 "sending challenge done\n"); 1473 "sending challenge done\n");
1466} 1474}
1467 1475
1476
1468/** 1477/**
1469 * Setup cipher for outgoing data stream based on target and 1478 * Setup cipher for outgoing data stream based on target and
1470 * our ephemeral private key. 1479 * our ephemeral private key.
@@ -1545,6 +1554,7 @@ inject_rekey (struct Queue *queue)
1545 setup_out_cipher (queue); 1554 setup_out_cipher (queue);
1546} 1555}
1547 1556
1557
1548/** 1558/**
1549 * We have been notified that our socket is ready to write. 1559 * We have been notified that our socket is ready to write.
1550 * Then reschedule this function to be called again once more is available. 1560 * Then reschedule this function to be called again once more is available.
@@ -1634,6 +1644,7 @@ queue_write (void *cls)
1634 queue); 1644 queue);
1635} 1645}
1636 1646
1647
1637/** 1648/**
1638 * Test if we have received a full message in plaintext. 1649 * Test if we have received a full message in plaintext.
1639 * If so, handle it. 1650 * If so, handle it.
@@ -1975,6 +1986,7 @@ queue_read (void *cls)
1975 queue_finish (queue); 1986 queue_finish (queue);
1976} 1987}
1977 1988
1989
1978/** 1990/**
1979 * Convert a `struct sockaddr_in6 to a `struct sockaddr *` 1991 * Convert a `struct sockaddr_in6 to a `struct sockaddr *`
1980 * 1992 *
@@ -2001,6 +2013,7 @@ tcp_address_to_sockaddr_numeric_v6 (socklen_t *sock_len, struct sockaddr_in6 v6,
2001 return in; 2013 return in;
2002} 2014}
2003 2015
2016
2004/** 2017/**
2005 * Convert a `struct sockaddr_in4 to a `struct sockaddr *` 2018 * Convert a `struct sockaddr_in4 to a `struct sockaddr *`
2006 * 2019 *
@@ -2024,6 +2037,7 @@ tcp_address_to_sockaddr_numeric_v4 (socklen_t *sock_len, struct sockaddr_in v4,
2024 return in; 2037 return in;
2025} 2038}
2026 2039
2040
2027/** 2041/**
2028 * Convert TCP bind specification to a `struct PortOnlyIpv4Ipv6 *` 2042 * Convert TCP bind specification to a `struct PortOnlyIpv4Ipv6 *`
2029 * 2043 *
@@ -2083,6 +2097,7 @@ tcp_address_to_sockaddr_port_only (const char *bindto, unsigned int *port)
2083 return po; 2097 return po;
2084} 2098}
2085 2099
2100
2086/** 2101/**
2087 * This Method extracts the address part of the BINDTO string. 2102 * This Method extracts the address part of the BINDTO string.
2088 * 2103 *
@@ -2117,7 +2132,8 @@ extract_address (const char *bindto)
2117 start++; /* skip over '['*/ 2132 start++; /* skip over '['*/
2118 cp[strlen (cp) - 1] = '\0'; /* eat ']'*/ 2133 cp[strlen (cp) - 1] = '\0'; /* eat ']'*/
2119 } 2134 }
2120 else { 2135 else
2136 {
2121 token = strtok_r (cp, "]", &rest); 2137 token = strtok_r (cp, "]", &rest);
2122 if (strlen (bindto) == strlen (token)) 2138 if (strlen (bindto) == strlen (token))
2123 { 2139 {
@@ -2139,6 +2155,7 @@ extract_address (const char *bindto)
2139 return start; 2155 return start;
2140} 2156}
2141 2157
2158
2142/** 2159/**
2143 * This Method extracts the port part of the BINDTO string. 2160 * This Method extracts the port part of the BINDTO string.
2144 * 2161 *
@@ -2217,6 +2234,7 @@ extract_port (const char *addr_and_port)
2217 return port; 2234 return port;
2218} 2235}
2219 2236
2237
2220/** 2238/**
2221 * Convert TCP bind specification to a `struct sockaddr *` 2239 * Convert TCP bind specification to a `struct sockaddr *`
2222 * 2240 *
@@ -2245,7 +2263,6 @@ tcp_address_to_sockaddr (const char *bindto, socklen_t *sock_len)
2245 bindto); 2263 bindto);
2246 2264
2247 2265
2248
2249 if (1 == inet_pton (AF_INET, start, &v4.sin_addr)) 2266 if (1 == inet_pton (AF_INET, start, &v4.sin_addr))
2250 { 2267 {
2251 // colon = strrchr (cp, ':'); 2268 // colon = strrchr (cp, ':');
@@ -2263,7 +2280,8 @@ tcp_address_to_sockaddr (const char *bindto, socklen_t *sock_len)
2263 port = extract_port (bindto); 2280 port = extract_port (bindto);
2264 in = tcp_address_to_sockaddr_numeric_v6 (sock_len, v6, port); 2281 in = tcp_address_to_sockaddr_numeric_v6 (sock_len, v6, port);
2265 } 2282 }
2266 else{ 2283 else
2284 {
2267 GNUNET_assert (0); 2285 GNUNET_assert (0);
2268 } 2286 }
2269 2287
@@ -2272,6 +2290,7 @@ tcp_address_to_sockaddr (const char *bindto, socklen_t *sock_len)
2272 return in; 2290 return in;
2273} 2291}
2274 2292
2293
2275/** 2294/**
2276 * Signature of functions implementing the sending functionality of a 2295 * Signature of functions implementing the sending functionality of a
2277 * message queue. 2296 * message queue.
@@ -2510,6 +2529,7 @@ start_initial_kx_out (struct Queue *queue)
2510 transmit_kx (queue, &epub); 2529 transmit_kx (queue, &epub);
2511} 2530}
2512 2531
2532
2513/** 2533/**
2514 * Callback called when peerstore store operation for handshake monotime is finished. 2534 * Callback called when peerstore store operation for handshake monotime is finished.
2515 * @param cls Queue context the store operation was executed. 2535 * @param cls Queue context the store operation was executed.
@@ -2527,6 +2547,7 @@ handshake_monotime_store_cb (void *cls, int success)
2527 queue->handshake_monotime_sc = NULL; 2547 queue->handshake_monotime_sc = NULL;
2528} 2548}
2529 2549
2550
2530/** 2551/**
2531 * Callback called by peerstore when records for GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE 2552 * Callback called by peerstore when records for GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE
2532 * where found. 2553 * where found.
@@ -2585,6 +2606,7 @@ handshake_monotime_cb (void *cls,
2585 queue); 2606 queue);
2586} 2607}
2587 2608
2609
2588/** 2610/**
2589 * We have received the first bytes from the other side on a @a queue. 2611 * We have received the first bytes from the other side on a @a queue.
2590 * Decrypt the @a tc contained in @a ibuf and check the signature. 2612 * Decrypt the @a tc contained in @a ibuf and check the signature.
@@ -2651,6 +2673,7 @@ free_proto_queue (struct ProtoQueue *pq)
2651 GNUNET_free (pq); 2673 GNUNET_free (pq);
2652} 2674}
2653 2675
2676
2654/** 2677/**
2655 * Read from the socket of the proto queue until we have enough data 2678 * Read from the socket of the proto queue until we have enough data
2656 * to upgrade to full queue. 2679 * to upgrade to full queue.
@@ -2892,6 +2915,7 @@ queue_read_kx (void *cls)
2892 queue->read_task = GNUNET_SCHEDULER_add_now (&queue_read, queue); 2915 queue->read_task = GNUNET_SCHEDULER_add_now (&queue_read, queue);
2893} 2916}
2894 2917
2918
2895/** 2919/**
2896 * Function called by the transport service to initialize a 2920 * Function called by the transport service to initialize a
2897 * message queue given address information about another peer. 2921 * message queue given address information about another peer.
@@ -2991,6 +3015,7 @@ mq_init (void *cls, const struct GNUNET_PeerIdentity *peer, const char *address)
2991 return GNUNET_OK; 3015 return GNUNET_OK;
2992} 3016}
2993 3017
3018
2994/** 3019/**
2995 * Iterator over all ListenTasks to clean up. 3020 * Iterator over all ListenTasks to clean up.
2996 * 3021 *
@@ -3021,6 +3046,7 @@ get_lt_delete_it (void *cls,
3021 return GNUNET_OK; 3046 return GNUNET_OK;
3022} 3047}
3023 3048
3049
3024/** 3050/**
3025 * Iterator over all message queues to clean up. 3051 * Iterator over all message queues to clean up.
3026 * 3052 *
@@ -3042,6 +3068,7 @@ get_queue_delete_it (void *cls,
3042 return GNUNET_OK; 3068 return GNUNET_OK;
3043} 3069}
3044 3070
3071
3045/** 3072/**
3046 * Shutdown the UNIX communicator. 3073 * Shutdown the UNIX communicator.
3047 * 3074 *
@@ -3182,6 +3209,7 @@ nat_address_cb (void *cls,
3182 } 3209 }
3183} 3210}
3184 3211
3212
3185/** 3213/**
3186 * This method adds addresses to the DLL, that are later register at the NAT service. 3214 * This method adds addresses to the DLL, that are later register at the NAT service.
3187 */ 3215 */
@@ -3211,6 +3239,7 @@ add_addr (struct sockaddr *in, socklen_t in_len)
3211 addrs_lens++; 3239 addrs_lens++;
3212} 3240}
3213 3241
3242
3214/** 3243/**
3215 * This method launch network interactions for each address we like to bind to. 3244 * This method launch network interactions for each address we like to bind to.
3216 * 3245 *
@@ -3336,7 +3365,7 @@ init_socket (struct sockaddr *addr,
3336 if (NULL == queue_map) 3365 if (NULL == queue_map)
3337 queue_map = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO); 3366 queue_map = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO);
3338 3367
3339 if (NULL == ch ) 3368 if (NULL == ch)
3340 ch = GNUNET_TRANSPORT_communicator_connect (cfg, 3369 ch = GNUNET_TRANSPORT_communicator_connect (cfg,
3341 COMMUNICATOR_CONFIG_SECTION, 3370 COMMUNICATOR_CONFIG_SECTION,
3342 COMMUNICATOR_ADDRESS_PREFIX, 3371 COMMUNICATOR_ADDRESS_PREFIX,
@@ -3360,6 +3389,7 @@ init_socket (struct sockaddr *addr,
3360 3389
3361} 3390}
3362 3391
3392
3363/** 3393/**
3364 * This method reads from the DLL addrs_head to register them at the NAT service. 3394 * This method reads from the DLL addrs_head to register them at the NAT service.
3365 */ 3395 */
@@ -3421,6 +3451,7 @@ nat_register ()
3421 } 3451 }
3422} 3452}
3423 3453
3454
3424/** 3455/**
3425 * This method is the callback called by the resolver API, and wraps method init_socket. 3456 * This method is the callback called by the resolver API, and wraps method init_socket.
3426 * 3457 *
@@ -3476,6 +3507,7 @@ init_socket_resolv (void *cls,
3476 } 3507 }
3477} 3508}
3478 3509
3510
3479/** 3511/**
3480 * Setup communicator and launch network interactions. 3512 * Setup communicator and launch network interactions.
3481 * 3513 *
diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c
index f57d08395..64cb53ad8 100644
--- a/src/transport/gnunet-service-tng.c
+++ b/src/transport/gnunet-service-tng.c
@@ -5164,9 +5164,10 @@ handle_del_address (void *cls,
5164 ale->address); 5164 ale->address);
5165 free_address_list_entry (ale); 5165 free_address_list_entry (ale);
5166 GNUNET_SERVICE_client_continue (tc->client); 5166 GNUNET_SERVICE_client_continue (tc->client);
5167 return;
5167 } 5168 }
5168 GNUNET_break (0); 5169 GNUNET_break (0);
5169 GNUNET_SERVICE_client_drop (tc->client); 5170 //GNUNET_SERVICE_client_drop (tc->client);
5170} 5171}
5171 5172
5172 5173
@@ -10045,6 +10046,52 @@ free_ack_cummulator_cb (void *cls,
10045 return GNUNET_OK; 10046 return GNUNET_OK;
10046} 10047}
10047 10048
10049void
10050cleanup_client (struct TransportClient *tc)
10051{
10052 switch (tc->type)
10053 {
10054 case CT_NONE:
10055 break;
10056
10057 case CT_CORE: {
10058 struct PendingMessage *pm;
10059
10060 while (NULL != (pm = tc->details.core.pending_msg_head))
10061 {
10062 GNUNET_CONTAINER_MDLL_remove (client,
10063 tc->details.core.pending_msg_head,
10064 tc->details.core.pending_msg_tail,
10065 pm);
10066 pm->client = NULL;
10067 }
10068 }
10069 break;
10070
10071 case CT_MONITOR:
10072 break;
10073
10074 case CT_COMMUNICATOR: {
10075 struct Queue *q;
10076 struct AddressListEntry *ale;
10077
10078 while (NULL != (q = tc->details.communicator.queue_head))
10079 free_queue (q);
10080 while (NULL != (ale = tc->details.communicator.addr_head))
10081 free_address_list_entry (ale);
10082 GNUNET_free (tc->details.communicator.address_prefix);
10083 }
10084 break;
10085
10086 case CT_APPLICATION:
10087 GNUNET_CONTAINER_multipeermap_iterate (tc->details.application.requests,
10088 &stop_peer_request,
10089 tc);
10090 GNUNET_CONTAINER_multipeermap_destroy (tc->details.application.requests);
10091 break;
10092 }
10093
10094}
10048 10095
10049/** 10096/**
10050 * Function called when the service shuts down. Unloads our plugins 10097 * Function called when the service shuts down. Unloads our plugins
@@ -10056,9 +10103,13 @@ static void
10056do_shutdown (void *cls) 10103do_shutdown (void *cls)
10057{ 10104{
10058 struct LearnLaunchEntry *lle; 10105 struct LearnLaunchEntry *lle;
10106 struct TransportClient *client;
10059 10107
10060 (void) cls; 10108 (void) cls;
10061 10109 for (client = clients_head; NULL != client; client = client->next)
10110 {
10111 cleanup_client (client);
10112 }
10062 //GNUNET_CONTAINER_multipeermap_iterate (neighbours, 10113 //GNUNET_CONTAINER_multipeermap_iterate (neighbours,
10063 //&free_neighbour_cb, NULL); 10114 //&free_neighbour_cb, NULL);
10064 if (NULL != peerstore) 10115 if (NULL != peerstore)
@@ -10066,6 +10117,16 @@ do_shutdown (void *cls)
10066 GNUNET_PEERSTORE_disconnect (peerstore, GNUNET_NO); 10117 GNUNET_PEERSTORE_disconnect (peerstore, GNUNET_NO);
10067 peerstore = NULL; 10118 peerstore = NULL;
10068 } 10119 }
10120 if (NULL != validation_task)
10121 {
10122 GNUNET_SCHEDULER_cancel (validation_task);
10123 validation_task = NULL;
10124 }
10125 if (NULL != dvlearn_task)
10126 {
10127 GNUNET_SCHEDULER_cancel (dvlearn_task);
10128 dvlearn_task = NULL;
10129 }
10069 if (NULL != GST_stats) 10130 if (NULL != GST_stats)
10070 { 10131 {
10071 GNUNET_STATISTICS_destroy (GST_stats, GNUNET_NO); 10132 GNUNET_STATISTICS_destroy (GST_stats, GNUNET_NO);
diff --git a/src/transport/test_transport_api2_tcp_peer1.conf b/src/transport/test_transport_api2_tcp_peer1.conf
index 417a855ad..bc3434069 100644
--- a/src/transport/test_transport_api2_tcp_peer1.conf
+++ b/src/transport/test_transport_api2_tcp_peer1.conf
@@ -6,12 +6,14 @@ GNUNET_TEST_HOME = $GNUNET_TMP/test-transport/api-tcp-p1/
6BINARY = gnunet-service-tng 6BINARY = gnunet-service-tng
7PLUGINS = tcp 7PLUGINS = tcp
8#PREFIX = valgrind --log-file=/tmp/vg_peer1-%p 8#PREFIX = valgrind --log-file=/tmp/vg_peer1-%p
9UNIXPATH = $GNUNET_RUNTIME_DIR/tng-p1.sock
9 10
10[communicator-tcp] 11[communicator-tcp]
11BINARY = gnunet-communicator-tcp 12BINARY = gnunet-communicator-tcp
12BINDTO = 60002 13BINDTO = 60002
13DISABLE_V6 = YES 14DISABLE_V6 = YES
14IMMEDIATE_START = YES 15IMMEDIATE_START = YES
16UNIXPATH = $GNUNET_RUNTIME_DIR/tcp-comm-p1.sock
15 17
16[peerstore] 18[peerstore]
17IMMEDIATE_START = YES 19IMMEDIATE_START = YES
diff --git a/src/transport/test_transport_api2_tcp_peer2.conf b/src/transport/test_transport_api2_tcp_peer2.conf
index 949bd95f3..437fac65d 100644
--- a/src/transport/test_transport_api2_tcp_peer2.conf
+++ b/src/transport/test_transport_api2_tcp_peer2.conf
@@ -5,12 +5,15 @@ GNUNET_TEST_HOME = $GNUNET_TMP/test-transport/api-tcp-p2/
5[transport] 5[transport]
6BINARY = gnunet-service-tng 6BINARY = gnunet-service-tng
7#PREFIX = valgrind --log-file=/tmp/vg_peer2-%p 7#PREFIX = valgrind --log-file=/tmp/vg_peer2-%p
8UNIXPATH = $GNUNET_RUNTIME_DIR/tng-p2.sock
8 9
9[communicator-tcp] 10[communicator-tcp]
10BINARY = gnunet-communicator-tcp 11BINARY = gnunet-communicator-tcp
11BINDTO = 60003 12BINDTO = 60003
12DISABLE_V6 = YES 13DISABLE_V6 = YES
13IMMEDIATE_START = YES 14IMMEDIATE_START = YES
15PREFIX = valgrind --log-file=/tmp/vg_comm2-%p
16UNIXPATH = $GNUNET_RUNTIME_DIR/tcp-comm-p2.sock
14 17
15[peerstore] 18[peerstore]
16IMMEDIATE_START = YES 19IMMEDIATE_START = YES
diff --git a/src/transport/transport-testing2.c b/src/transport/transport-testing2.c
index d553a3961..1461915f0 100644
--- a/src/transport/transport-testing2.c
+++ b/src/transport/transport-testing2.c
@@ -341,11 +341,11 @@ hello_iter_cb (void *cb_cls,
341 LOG (GNUNET_ERROR_TYPE_DEBUG, "Iteration End\n"); 341 LOG (GNUNET_ERROR_TYPE_DEBUG, "Iteration End\n");
342 return; 342 return;
343 } 343 }
344 //Check record type et al? 344 // Check record type et al?
345 p->hello_size = record->value_size; 345 p->hello_size = record->value_size;
346 p->hello = GNUNET_malloc (p->hello_size); 346 p->hello = GNUNET_malloc (p->hello_size);
347 memcpy (p->hello, record->value, p->hello_size); 347 memcpy (p->hello, record->value, p->hello_size);
348 p->hello[p->hello_size-1] = '\0'; 348 p->hello[p->hello_size - 1] = '\0';
349 349
350 GNUNET_PEERSTORE_iterate_cancel (p->pic); 350 GNUNET_PEERSTORE_iterate_cancel (p->pic);
351 p->pic = NULL; 351 p->pic = NULL;
@@ -360,13 +360,15 @@ hello_iter_cb (void *cb_cls,
360 } 360 }
361} 361}
362 362
363
363static void 364static void
364retrieve_hello(void *cls) 365retrieve_hello (void *cls)
365{ 366{
366 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls; 367 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
367 LOG (GNUNET_ERROR_TYPE_DEBUG, 368 LOG (GNUNET_ERROR_TYPE_DEBUG,
368 "Getting hello...\n"); 369 "Getting hello...\n");
369 370
371 p->rh_task = NULL;
370 p->pic = GNUNET_PEERSTORE_iterate (p->ph, 372 p->pic = GNUNET_PEERSTORE_iterate (p->ph,
371 "transport", 373 "transport",
372 &p->id, 374 &p->id,
@@ -377,7 +379,6 @@ retrieve_hello(void *cls)
377} 379}
378 380
379 381
380
381/** 382/**
382 * Start a peer with the given configuration 383 * Start a peer with the given configuration
383 * @param tth the testing handle 384 * @param tth the testing handle
@@ -536,10 +537,11 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct
536 p->ah = GNUNET_TRANSPORT_application_init (p->cfg); 537 p->ah = GNUNET_TRANSPORT_application_init (p->cfg);
537 GNUNET_assert (NULL != p->ah); 538 GNUNET_assert (NULL != p->ah);
538 // FIXME Error handleing 539 // FIXME Error handleing
539 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10), 540 p->rh_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (
540 retrieve_hello, 541 GNUNET_TIME_UNIT_SECONDS, 10),
541 p); 542 retrieve_hello,
542 //GNUNET_assert (NULL != p->pic); 543 p);
544 // GNUNET_assert (NULL != p->pic);
543 545
544 return p; 546 return p;
545} 547}
@@ -650,6 +652,11 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct
650 struct GNUNET_TRANSPORT_TESTING_Handle *tth = p->tth; 652 struct GNUNET_TRANSPORT_TESTING_Handle *tth = p->tth;
651 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc; 653 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc;
652 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *ccn; 654 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *ccn;
655 /* shutdown */
656 LOG (GNUNET_ERROR_TYPE_DEBUG,
657 "Stopping peer %u (`%s')\n",
658 p->no,
659 GNUNET_i2s (&p->id));
653 660
654 for (cc = tth->cc_head; NULL != cc; cc = ccn) 661 for (cc = tth->cc_head; NULL != cc; cc = ccn)
655 { 662 {
@@ -660,7 +667,7 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct
660 } 667 }
661 if (NULL != p->pic) 668 if (NULL != p->pic)
662 { 669 {
663 //GNUNET_PEERSTORE_iterate_cancel (p->pic); 670 // GNUNET_PEERSTORE_iterate_cancel (p->pic);
664 p->pic = NULL; 671 p->pic = NULL;
665 } 672 }
666 if (NULL != p->th) 673 if (NULL != p->th)
@@ -718,6 +725,9 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct
718 "Peer %u (`%s') stopped\n", 725 "Peer %u (`%s') stopped\n",
719 p->no, 726 p->no,
720 GNUNET_i2s (&p->id)); 727 GNUNET_i2s (&p->id));
728 if (NULL != p->rh_task)
729 GNUNET_SCHEDULER_cancel (p->rh_task);
730 p->rh_task = NULL;
721 GNUNET_free (p); 731 GNUNET_free (p);
722} 732}
723 733
diff --git a/src/transport/transport-testing2.h b/src/transport/transport-testing2.h
index 8c0f03556..db8700df9 100644
--- a/src/transport/transport-testing2.h
+++ b/src/transport/transport-testing2.h
@@ -145,6 +145,11 @@ struct GNUNET_TRANSPORT_TESTING_PeerContext
145 GNUNET_SCHEDULER_TaskCallback start_cb; 145 GNUNET_SCHEDULER_TaskCallback start_cb;
146 146
147 /** 147 /**
148 * Hello get task
149 */
150 struct GNUNET_SCHEDULER_Task *rh_task;
151
152 /**
148 * Closure for the @a nc and @a nd callbacks 153 * Closure for the @a nc and @a nd callbacks
149 */ 154 */
150 void *cb_cls; 155 void *cb_cls;