aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authort3sserakt <t3ss@posteo.de>2020-07-21 12:26:55 +0200
committert3sserakt <t3ss@posteo.de>2020-07-21 12:26:55 +0200
commit17d84245fdfeeb1a6da4ffb97898903cb55f702c (patch)
tree6e448372a1fb87e21a25e8ea0542fa7f2f327967 /src/transport
parentd63986fa2002fcee65dff17746b2b8154289a543 (diff)
downloadgnunet-17d84245fdfeeb1a6da4ffb97898903cb55f702c.tar.gz
gnunet-17d84245fdfeeb1a6da4ffb97898903cb55f702c.zip
- fixed mem leaks.
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/gnunet-communicator-tcp.c57
-rw-r--r--src/transport/test_communicator_basic.c70
-rw-r--r--src/transport/test_communicator_tcp_basic_peer1.conf2
-rw-r--r--src/transport/test_communicator_tcp_basic_peer2.conf2
-rw-r--r--src/transport/test_communicator_tcp_rekey_peer1.conf2
-rw-r--r--src/transport/test_communicator_tcp_rekey_peer2.conf2
6 files changed, 92 insertions, 43 deletions
diff --git a/src/transport/gnunet-communicator-tcp.c b/src/transport/gnunet-communicator-tcp.c
index fff699415..9da14dcb0 100644
--- a/src/transport/gnunet-communicator-tcp.c
+++ b/src/transport/gnunet-communicator-tcp.c
@@ -665,7 +665,7 @@ struct PortOnlyIpv4Ipv6
665 /** 665 /**
666 * Length of ipv4 address. 666 * Length of ipv4 address.
667 */ 667 */
668 socklen_t *addr_len_ipv4; 668 socklen_t addr_len_ipv4;
669 669
670 /** 670 /**
671 * Ipv6 address we like to bind to. 671 * Ipv6 address we like to bind to.
@@ -675,7 +675,7 @@ struct PortOnlyIpv4Ipv6
675 /** 675 /**
676 * Length of ipv6 address. 676 * Length of ipv6 address.
677 */ 677 */
678 socklen_t *addr_len_ipv6; 678 socklen_t addr_len_ipv6;
679 679
680}; 680};
681 681
@@ -1700,7 +1700,7 @@ tcp_address_to_sockaddr_port_only (const char *bindto, unsigned int *port)
1700 i4 = GNUNET_malloc (sizeof(struct sockaddr_in)); 1700 i4 = GNUNET_malloc (sizeof(struct sockaddr_in));
1701 po->addr_ipv4 = tcp_address_to_sockaddr_numeric_v4 (&sock_len_ipv4, *i4, 1701 po->addr_ipv4 = tcp_address_to_sockaddr_numeric_v4 (&sock_len_ipv4, *i4,
1702 *port); 1702 *port);
1703 po->addr_len_ipv4 = &sock_len_ipv4; 1703 po->addr_len_ipv4 = sock_len_ipv4;
1704 } 1704 }
1705 else 1705 else
1706 { 1706 {
@@ -1708,14 +1708,19 @@ tcp_address_to_sockaddr_port_only (const char *bindto, unsigned int *port)
1708 i4 = GNUNET_malloc (sizeof(struct sockaddr_in)); 1708 i4 = GNUNET_malloc (sizeof(struct sockaddr_in));
1709 po->addr_ipv4 = tcp_address_to_sockaddr_numeric_v4 (&sock_len_ipv4, *i4, 1709 po->addr_ipv4 = tcp_address_to_sockaddr_numeric_v4 (&sock_len_ipv4, *i4,
1710 *port); 1710 *port);
1711 po->addr_len_ipv4 = &sock_len_ipv4; 1711 po->addr_len_ipv4 = sock_len_ipv4;
1712 1712
1713 i6 = GNUNET_malloc (sizeof(struct sockaddr_in6)); 1713 i6 = GNUNET_malloc (sizeof(struct sockaddr_in6));
1714 po->addr_ipv6 = tcp_address_to_sockaddr_numeric_v6 (&sock_len_ipv6, *i6, 1714 po->addr_ipv6 = tcp_address_to_sockaddr_numeric_v6 (&sock_len_ipv6, *i6,
1715 *port); 1715 *port);
1716 1716
1717 po->addr_len_ipv6 = &sock_len_ipv6; 1717 po->addr_len_ipv6 = sock_len_ipv6;
1718
1719 GNUNET_free (i6);
1718 } 1720 }
1721
1722 GNUNET_free (i4);
1723
1719 return po; 1724 return po;
1720} 1725}
1721 1726
@@ -1758,7 +1763,7 @@ extract_address (const char *bindto)
1758 } 1763 }
1759 } 1764 }
1760 1765
1761 // GNUNET_free(cp); 1766 GNUNET_free (cp);
1762 1767
1763 return start; 1768 return start;
1764} 1769}
@@ -2991,7 +2996,8 @@ init_socket (const struct sockaddr *addr,
2991 GNUNET_ERROR_TYPE_ERROR, 2996 GNUNET_ERROR_TYPE_ERROR,
2992 _ ( 2997 _ (
2993 "Transport service is lacking key configuration settings. Exiting.\n")); 2998 "Transport service is lacking key configuration settings. Exiting.\n"));
2994 GNUNET_RESOLVER_request_cancel (resolve_request_handle); 2999 if (NULL != resolve_request_handle)
3000 GNUNET_RESOLVER_request_cancel (resolve_request_handle);
2995 GNUNET_SCHEDULER_shutdown (); 3001 GNUNET_SCHEDULER_shutdown ();
2996 return GNUNET_SYSERR; 3002 return GNUNET_SYSERR;
2997 } 3003 }
@@ -3022,7 +3028,8 @@ init_socket (const struct sockaddr *addr,
3022 if (NULL == ch) 3028 if (NULL == ch)
3023 { 3029 {
3024 GNUNET_break (0); 3030 GNUNET_break (0);
3025 GNUNET_RESOLVER_request_cancel (resolve_request_handle); 3031 if (NULL != resolve_request_handle)
3032 GNUNET_RESOLVER_request_cancel (resolve_request_handle);
3026 GNUNET_SCHEDULER_shutdown (); 3033 GNUNET_SCHEDULER_shutdown ();
3027 return GNUNET_SYSERR; 3034 return GNUNET_SYSERR;
3028 } 3035 }
@@ -3069,10 +3076,18 @@ nat_register ()
3069 NULL /* FIXME: support reversal: #5529 */, 3076 NULL /* FIXME: support reversal: #5529 */,
3070 NULL /* closure */); 3077 NULL /* closure */);
3071 3078
3079 i = 0;
3080
3081 /*for (i = addrs_lens - 1; i >= 0; i--)
3082 GNUNET_free (saddrs[i]);*/
3083 GNUNET_free_non_null (saddrs);
3084 GNUNET_free_non_null (saddr_lens);
3085
3072 if (NULL == nat) 3086 if (NULL == nat)
3073 { 3087 {
3074 GNUNET_break (0); 3088 GNUNET_break (0);
3075 GNUNET_RESOLVER_request_cancel (resolve_request_handle); 3089 if (NULL != resolve_request_handle)
3090 GNUNET_RESOLVER_request_cancel (resolve_request_handle);
3076 GNUNET_SCHEDULER_shutdown (); 3091 GNUNET_SCHEDULER_shutdown ();
3077 } 3092 }
3078} 3093}
@@ -3169,6 +3184,8 @@ run (void *cls,
3169 char dummy[2]; 3184 char dummy[2];
3170 char *rest = NULL; 3185 char *rest = NULL;
3171 struct PortOnlyIpv4Ipv6 *po; 3186 struct PortOnlyIpv4Ipv6 *po;
3187 socklen_t addr_len_ipv4;
3188 socklen_t addr_len_ipv6;
3172 3189
3173 (void) cls; 3190 (void) cls;
3174 cfg = c; 3191 cfg = c;
@@ -3211,17 +3228,25 @@ run (void *cls,
3211 { 3228 {
3212 po = tcp_address_to_sockaddr_port_only (bindto, &port); 3229 po = tcp_address_to_sockaddr_port_only (bindto, &port);
3213 3230
3214 if (NULL != &po->addr_ipv4) 3231 addr_len_ipv4 = po->addr_len_ipv4;
3232
3233
3234 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3235 "address po %s\n",
3236 GNUNET_a2s (po->addr_ipv4, addr_len_ipv4));
3237
3238 if (NULL != po->addr_ipv4)
3215 { 3239 {
3216 init_socket (po->addr_ipv4, *po->addr_len_ipv4); 3240 init_socket (po->addr_ipv4, addr_len_ipv4);
3217 add_addr (po->addr_ipv4, *po->addr_len_ipv4); 3241 add_addr (po->addr_ipv4, addr_len_ipv4);
3218 } 3242 }
3219 3243
3220 /*if (NULL != &po->addr_ipv6) 3244 if (NULL != po->addr_ipv6)
3221 { 3245 {
3222 init_socket (po->addr_ipv6, *po->addr_len_ipv6); 3246 addr_len_ipv6 = po->addr_len_ipv6;
3223 add_addr (po->addr_ipv6, *po->addr_len_ipv6); 3247 init_socket (po->addr_ipv6, addr_len_ipv6);
3224 }*/ 3248 add_addr (po->addr_ipv6, addr_len_ipv6);
3249 }
3225 3250
3226 nat_register (); 3251 nat_register ();
3227 } 3252 }
diff --git a/src/transport/test_communicator_basic.c b/src/transport/test_communicator_basic.c
index 290167960..e2d2eb73c 100644
--- a/src/transport/test_communicator_basic.c
+++ b/src/transport/test_communicator_basic.c
@@ -224,8 +224,8 @@ latency_timeout (void *cls)
224 } 224 }
225 225
226 LOG (GNUNET_ERROR_TYPE_ERROR, 226 LOG (GNUNET_ERROR_TYPE_ERROR,
227 "Latency too high. Test failed. (Phase: %d. Sent: %lu, Received: %lu)\n", 227 "Latency too high. Test failed. (Phase: %d. Sent: %lu, Received: %lu)\n",
228 phase, num_sent, num_received); 228 phase, num_sent, num_received);
229 ret = 2; 229 ret = 2;
230 GNUNET_SCHEDULER_shutdown (); 230 GNUNET_SCHEDULER_shutdown ();
231} 231}
@@ -403,7 +403,7 @@ incoming_message_cb (void *cls,
403 if (0 != strcmp ((char*) cls, cfg_peers_name[NUM_PEERS - 1])) 403 if (0 != strcmp ((char*) cls, cfg_peers_name[NUM_PEERS - 1]))
404 { 404 {
405 LOG (GNUNET_ERROR_TYPE_WARNING, 405 LOG (GNUNET_ERROR_TYPE_WARNING,
406 "unexpected receiver...\n"); 406 "unexpected receiver...\n");
407 return; 407 return;
408 } 408 }
409 /* Reset timeout */ 409 /* Reset timeout */
@@ -422,18 +422,18 @@ incoming_message_cb (void *cls,
422 if (num_received == BURST_PACKETS) 422 if (num_received == BURST_PACKETS)
423 { 423 {
424 LOG (GNUNET_ERROR_TYPE_MESSAGE, 424 LOG (GNUNET_ERROR_TYPE_MESSAGE,
425 "Short size packet test done.\n"); 425 "Short size packet test done.\n");
426 char *goodput = GNUNET_STRINGS_byte_size_fancy ((SHORT_MESSAGE_SIZE 426 char *goodput = GNUNET_STRINGS_byte_size_fancy ((SHORT_MESSAGE_SIZE
427 * num_received * 1000 427 * num_received * 1000
428 * 1000) 428 * 1000)
429 / duration.rel_value_us); 429 / duration.rel_value_us);
430 LOG (GNUNET_ERROR_TYPE_MESSAGE, 430 LOG (GNUNET_ERROR_TYPE_MESSAGE,
431 "%lu/%lu packets in %llu us (%s/s) -- avg latency: %llu us\n", 431 "%lu/%lu packets in %llu us (%s/s) -- avg latency: %llu us\n",
432 (unsigned long) num_received, 432 (unsigned long) num_received,
433 (unsigned long) num_sent, 433 (unsigned long) num_sent,
434 (unsigned long long) duration.rel_value_us, 434 (unsigned long long) duration.rel_value_us,
435 goodput, 435 goodput,
436 (unsigned long long) avg_latency); 436 (unsigned long long) avg_latency);
437 GNUNET_free (goodput); 437 GNUNET_free (goodput);
438 start_long = GNUNET_TIME_absolute_get (); 438 start_long = GNUNET_TIME_absolute_get ();
439 phase = TP_BURST_LONG; 439 phase = TP_BURST_LONG;
@@ -449,7 +449,7 @@ incoming_message_cb (void *cls,
449 if (long_message_size != payload_len) 449 if (long_message_size != payload_len)
450 { 450 {
451 LOG (GNUNET_ERROR_TYPE_WARNING, 451 LOG (GNUNET_ERROR_TYPE_WARNING,
452 "Ignoring packet with wrong length\n"); 452 "Ignoring packet with wrong length\n");
453 return; // Ignore 453 return; // Ignore
454 } 454 }
455 num_received++; 455 num_received++;
@@ -458,19 +458,19 @@ incoming_message_cb (void *cls,
458 if (num_received == BURST_PACKETS) 458 if (num_received == BURST_PACKETS)
459 { 459 {
460 LOG (GNUNET_ERROR_TYPE_MESSAGE, 460 LOG (GNUNET_ERROR_TYPE_MESSAGE,
461 "Long size packet test done.\n"); 461 "Long size packet test done.\n");
462 char *goodput = GNUNET_STRINGS_byte_size_fancy ((long_message_size 462 char *goodput = GNUNET_STRINGS_byte_size_fancy ((long_message_size
463 * num_received * 1000 463 * num_received * 1000
464 * 1000) 464 * 1000)
465 / duration.rel_value_us); 465 / duration.rel_value_us);
466 466
467 LOG (GNUNET_ERROR_TYPE_MESSAGE, 467 LOG (GNUNET_ERROR_TYPE_MESSAGE,
468 "%lu/%lu packets in %llu us (%s/s) -- avg latency: %llu us\n", 468 "%lu/%lu packets in %llu us (%s/s) -- avg latency: %llu us\n",
469 (unsigned long) num_received, 469 (unsigned long) num_received,
470 (unsigned long) num_sent, 470 (unsigned long) num_sent,
471 (unsigned long long) duration.rel_value_us, 471 (unsigned long long) duration.rel_value_us,
472 goodput, 472 goodput,
473 (unsigned long long) avg_latency); 473 (unsigned long long) avg_latency);
474 GNUNET_free (goodput); 474 GNUNET_free (goodput);
475 ack = 0; 475 ack = 0;
476 phase = TP_SIZE_CHECK; 476 phase = TP_SIZE_CHECK;
@@ -493,12 +493,12 @@ incoming_message_cb (void *cls,
493 if (num_received >= (max_size) / 10) 493 if (num_received >= (max_size) / 10)
494 { 494 {
495 LOG (GNUNET_ERROR_TYPE_MESSAGE, 495 LOG (GNUNET_ERROR_TYPE_MESSAGE,
496 "Size packet test done.\n"); 496 "Size packet test done.\n");
497 LOG (GNUNET_ERROR_TYPE_MESSAGE, 497 LOG (GNUNET_ERROR_TYPE_MESSAGE,
498 "%lu/%lu packets -- avg latency: %llu us\n", 498 "%lu/%lu packets -- avg latency: %llu us\n",
499 (unsigned long) num_received, 499 (unsigned long) num_received,
500 (unsigned long) num_sent, 500 (unsigned long) num_sent,
501 (unsigned long long) avg_latency); 501 (unsigned long long) avg_latency);
502 num_received = 0; 502 num_received = 0;
503 num_sent = 0; 503 num_sent = 0;
504 avg_latency = 0; 504 avg_latency = 0;
@@ -511,7 +511,7 @@ incoming_message_cb (void *cls,
511 break; 511 break;
512 } 512 }
513 LOG (GNUNET_ERROR_TYPE_DEBUG, 513 LOG (GNUNET_ERROR_TYPE_DEBUG,
514 "Finished\n"); 514 "Finished\n");
515 GNUNET_SCHEDULER_shutdown (); 515 GNUNET_SCHEDULER_shutdown ();
516 } 516 }
517 break; 517 break;
@@ -587,6 +587,7 @@ main (int argc,
587 GNUNET_asprintf (&communicator_binary, 587 GNUNET_asprintf (&communicator_binary,
588 "gnunet-communicator-%s", 588 "gnunet-communicator-%s",
589 communicator_name); 589 communicator_name);
590
590 if (GNUNET_OK != 591 if (GNUNET_OK !=
591 GNUNET_log_setup ("test_communicator_basic", 592 GNUNET_log_setup ("test_communicator_basic",
592 "DEBUG", 593 "DEBUG",
@@ -640,11 +641,26 @@ main (int argc,
640 &peer_id[i].public_key); 641 &peer_id[i].public_key);
641 GNUNET_free (private_key); 642 GNUNET_free (private_key);
642 LOG (GNUNET_ERROR_TYPE_INFO, 643 LOG (GNUNET_ERROR_TYPE_INFO,
643 "Identity of peer %u is %s\n", 644 "Identity of peer %u is %s\n",
644 i, 645 i,
645 GNUNET_i2s_full (&peer_id[i])); 646 GNUNET_i2s_full (&peer_id[i]));
646 } 647 }
647 LOG (GNUNET_ERROR_TYPE_MESSAGE, "Starting test...\n"); 648 LOG (GNUNET_ERROR_TYPE_MESSAGE, "Starting test...\n");
649 LOG (GNUNET_ERROR_TYPE_DEBUG,
650 "argv[0]: %s\n",
651 argv[0]);
652 LOG (GNUNET_ERROR_TYPE_DEBUG,
653 "test_name: %s\n",
654 test_name);
655
656 LOG (GNUNET_ERROR_TYPE_DEBUG,
657 "communicator_name: %s\n",
658 communicator_name);
659
660 LOG (GNUNET_ERROR_TYPE_DEBUG,
661 "communicator_binary: %s\n",
662 communicator_binary);
663
648 GNUNET_SCHEDULER_run (&run, 664 GNUNET_SCHEDULER_run (&run,
649 NULL); 665 NULL);
650 return ret; 666 return ret;
diff --git a/src/transport/test_communicator_tcp_basic_peer1.conf b/src/transport/test_communicator_tcp_basic_peer1.conf
index 31568fd0d..c08737b7b 100644
--- a/src/transport/test_communicator_tcp_basic_peer1.conf
+++ b/src/transport/test_communicator_tcp_basic_peer1.conf
@@ -26,6 +26,8 @@ UNIXPATH = $GNUNET_TMP/test-communicator-unix-1/peerstore.sock
26UNIXPATH = $GNUNET_RUNTIME_DIR/test_gnunet-communicator-unix_1.sock 26UNIXPATH = $GNUNET_RUNTIME_DIR/test_gnunet-communicator-unix_1.sock
27 27
28[communicator-tcp] 28[communicator-tcp]
29#PREFIX = xterm -geometry 100x85 -T peer1 -e gdb --args
30#PREFIX = valgrind --leak-check=full --track-origins=yes
29BINDTO = 60002 31BINDTO = 60002
30DISABLE_V6 = NO 32DISABLE_V6 = NO
31 33
diff --git a/src/transport/test_communicator_tcp_basic_peer2.conf b/src/transport/test_communicator_tcp_basic_peer2.conf
index 44037d47f..45b7e7844 100644
--- a/src/transport/test_communicator_tcp_basic_peer2.conf
+++ b/src/transport/test_communicator_tcp_basic_peer2.conf
@@ -27,6 +27,8 @@ UNIXPATH = $GNUNET_TMP/test-communicator-unix-2/peerstore.sock
27UNIXPATH = $GNUNET_RUNTIME_DIR/test_gnunet-communicator-unix_2.sock 27UNIXPATH = $GNUNET_RUNTIME_DIR/test_gnunet-communicator-unix_2.sock
28 28
29[communicator-tcp] 29[communicator-tcp]
30#PREFIX = xterm -geometry 100x85 -T peer2 -e gdb --args
31#PREFIX = valgrind --leak-check=full --track-origins=yes
30BINDTO = 60003 32BINDTO = 60003
31DISABLE_V6 = NO 33DISABLE_V6 = NO
32 34
diff --git a/src/transport/test_communicator_tcp_rekey_peer1.conf b/src/transport/test_communicator_tcp_rekey_peer1.conf
index e7161e488..901f415ef 100644
--- a/src/transport/test_communicator_tcp_rekey_peer1.conf
+++ b/src/transport/test_communicator_tcp_rekey_peer1.conf
@@ -31,6 +31,8 @@ UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-resolver_test_1.sock
31UNIXPATH = $GNUNET_RUNTIME_DIR/test_gnunet-communicator-unix_1.sock 31UNIXPATH = $GNUNET_RUNTIME_DIR/test_gnunet-communicator-unix_1.sock
32 32
33[communicator-tcp] 33[communicator-tcp]
34#PREFIX = xterm -geometry 100x85 -T peer1 -e gdb --args
35#PREFIX = valgrind --leak-check=full --track-origins=yes
34BINDTO = 60002 36BINDTO = 60002
35DISABLE_V6 = YES 37DISABLE_V6 = YES
36REKEY_INTERVAL = 100ms 38REKEY_INTERVAL = 100ms
diff --git a/src/transport/test_communicator_tcp_rekey_peer2.conf b/src/transport/test_communicator_tcp_rekey_peer2.conf
index 8f175a405..138650a3b 100644
--- a/src/transport/test_communicator_tcp_rekey_peer2.conf
+++ b/src/transport/test_communicator_tcp_rekey_peer2.conf
@@ -31,6 +31,8 @@ UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-resolver_test_2.sock
31UNIXPATH = $GNUNET_RUNTIME_DIR/test_gnunet-communicator-unix_2.sock 31UNIXPATH = $GNUNET_RUNTIME_DIR/test_gnunet-communicator-unix_2.sock
32 32
33[communicator-tcp] 33[communicator-tcp]
34#PREFIX = xterm -geometry 100x85 -T peer1 -e gdb --args
35#PREFIX = valgrind --leak-check=full --track-origins=yes
34BINDTO = 60003 36BINDTO = 60003
35DISABLE_V6 = YES 37DISABLE_V6 = YES
36REKEY_INTERVAL = 100ms 38REKEY_INTERVAL = 100ms