summaryrefslogtreecommitdiff
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)
- 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
/**
* Length of ipv4 address.
*/
- socklen_t *addr_len_ipv4;
+ socklen_t addr_len_ipv4;
/**
* Ipv6 address we like to bind to.
@@ -675,7 +675,7 @@ struct PortOnlyIpv4Ipv6
/**
* Length of ipv6 address.
*/
- socklen_t *addr_len_ipv6;
+ socklen_t addr_len_ipv6;
};
@@ -1700,7 +1700,7 @@ tcp_address_to_sockaddr_port_only (const char *bindto, unsigned int *port)
i4 = GNUNET_malloc (sizeof(struct sockaddr_in));
po->addr_ipv4 = tcp_address_to_sockaddr_numeric_v4 (&sock_len_ipv4, *i4,
*port);
- po->addr_len_ipv4 = &sock_len_ipv4;
+ po->addr_len_ipv4 = sock_len_ipv4;
}
else
{
@@ -1708,14 +1708,19 @@ tcp_address_to_sockaddr_port_only (const char *bindto, unsigned int *port)
i4 = GNUNET_malloc (sizeof(struct sockaddr_in));
po->addr_ipv4 = tcp_address_to_sockaddr_numeric_v4 (&sock_len_ipv4, *i4,
*port);
- po->addr_len_ipv4 = &sock_len_ipv4;
+ po->addr_len_ipv4 = sock_len_ipv4;
i6 = GNUNET_malloc (sizeof(struct sockaddr_in6));
po->addr_ipv6 = tcp_address_to_sockaddr_numeric_v6 (&sock_len_ipv6, *i6,
*port);
- po->addr_len_ipv6 = &sock_len_ipv6;
+ po->addr_len_ipv6 = sock_len_ipv6;
+
+ GNUNET_free (i6);
}
+
+ GNUNET_free (i4);
+
return po;
}
@@ -1758,7 +1763,7 @@ extract_address (const char *bindto)
}
}
- // GNUNET_free(cp);
+ GNUNET_free (cp);
return start;
}
@@ -2991,7 +2996,8 @@ init_socket (const struct sockaddr *addr,
GNUNET_ERROR_TYPE_ERROR,
_ (
"Transport service is lacking key configuration settings. Exiting.\n"));
- GNUNET_RESOLVER_request_cancel (resolve_request_handle);
+ if (NULL != resolve_request_handle)
+ GNUNET_RESOLVER_request_cancel (resolve_request_handle);
GNUNET_SCHEDULER_shutdown ();
return GNUNET_SYSERR;
}
@@ -3022,7 +3028,8 @@ init_socket (const struct sockaddr *addr,
if (NULL == ch)
{
GNUNET_break (0);
- GNUNET_RESOLVER_request_cancel (resolve_request_handle);
+ if (NULL != resolve_request_handle)
+ GNUNET_RESOLVER_request_cancel (resolve_request_handle);
GNUNET_SCHEDULER_shutdown ();
return GNUNET_SYSERR;
}
@@ -3069,10 +3076,18 @@ nat_register ()
NULL /* FIXME: support reversal: #5529 */,
NULL /* closure */);
+ i = 0;
+
+ /*for (i = addrs_lens - 1; i >= 0; i--)
+ GNUNET_free (saddrs[i]);*/
+ GNUNET_free_non_null (saddrs);
+ GNUNET_free_non_null (saddr_lens);
+
if (NULL == nat)
{
GNUNET_break (0);
- GNUNET_RESOLVER_request_cancel (resolve_request_handle);
+ if (NULL != resolve_request_handle)
+ GNUNET_RESOLVER_request_cancel (resolve_request_handle);
GNUNET_SCHEDULER_shutdown ();
}
}
@@ -3169,6 +3184,8 @@ run (void *cls,
char dummy[2];
char *rest = NULL;
struct PortOnlyIpv4Ipv6 *po;
+ socklen_t addr_len_ipv4;
+ socklen_t addr_len_ipv6;
(void) cls;
cfg = c;
@@ -3211,17 +3228,25 @@ run (void *cls,
{
po = tcp_address_to_sockaddr_port_only (bindto, &port);
- if (NULL != &po->addr_ipv4)
+ addr_len_ipv4 = po->addr_len_ipv4;
+
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "address po %s\n",
+ GNUNET_a2s (po->addr_ipv4, addr_len_ipv4));
+
+ if (NULL != po->addr_ipv4)
{
- init_socket (po->addr_ipv4, *po->addr_len_ipv4);
- add_addr (po->addr_ipv4, *po->addr_len_ipv4);
+ init_socket (po->addr_ipv4, addr_len_ipv4);
+ add_addr (po->addr_ipv4, addr_len_ipv4);
}
- /*if (NULL != &po->addr_ipv6)
+ if (NULL != po->addr_ipv6)
{
- init_socket (po->addr_ipv6, *po->addr_len_ipv6);
- add_addr (po->addr_ipv6, *po->addr_len_ipv6);
- }*/
+ addr_len_ipv6 = po->addr_len_ipv6;
+ init_socket (po->addr_ipv6, addr_len_ipv6);
+ add_addr (po->addr_ipv6, addr_len_ipv6);
+ }
nat_register ();
}
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)
}
LOG (GNUNET_ERROR_TYPE_ERROR,
- "Latency too high. Test failed. (Phase: %d. Sent: %lu, Received: %lu)\n",
- phase, num_sent, num_received);
+ "Latency too high. Test failed. (Phase: %d. Sent: %lu, Received: %lu)\n",
+ phase, num_sent, num_received);
ret = 2;
GNUNET_SCHEDULER_shutdown ();
}
@@ -403,7 +403,7 @@ incoming_message_cb (void *cls,
if (0 != strcmp ((char*) cls, cfg_peers_name[NUM_PEERS - 1]))
{
LOG (GNUNET_ERROR_TYPE_WARNING,
- "unexpected receiver...\n");
+ "unexpected receiver...\n");
return;
}
/* Reset timeout */
@@ -422,18 +422,18 @@ incoming_message_cb (void *cls,
if (num_received == BURST_PACKETS)
{
LOG (GNUNET_ERROR_TYPE_MESSAGE,
- "Short size packet test done.\n");
+ "Short size packet test done.\n");
char *goodput = GNUNET_STRINGS_byte_size_fancy ((SHORT_MESSAGE_SIZE
* num_received * 1000
* 1000)
/ duration.rel_value_us);
LOG (GNUNET_ERROR_TYPE_MESSAGE,
- "%lu/%lu packets in %llu us (%s/s) -- avg latency: %llu us\n",
- (unsigned long) num_received,
- (unsigned long) num_sent,
- (unsigned long long) duration.rel_value_us,
- goodput,
- (unsigned long long) avg_latency);
+ "%lu/%lu packets in %llu us (%s/s) -- avg latency: %llu us\n",
+ (unsigned long) num_received,
+ (unsigned long) num_sent,
+ (unsigned long long) duration.rel_value_us,
+ goodput,
+ (unsigned long long) avg_latency);
GNUNET_free (goodput);
start_long = GNUNET_TIME_absolute_get ();
phase = TP_BURST_LONG;
@@ -449,7 +449,7 @@ incoming_message_cb (void *cls,
if (long_message_size != payload_len)
{
LOG (GNUNET_ERROR_TYPE_WARNING,
- "Ignoring packet with wrong length\n");
+ "Ignoring packet with wrong length\n");
return; // Ignore
}
num_received++;
@@ -458,19 +458,19 @@ incoming_message_cb (void *cls,
if (num_received == BURST_PACKETS)
{
LOG (GNUNET_ERROR_TYPE_MESSAGE,
- "Long size packet test done.\n");
+ "Long size packet test done.\n");
char *goodput = GNUNET_STRINGS_byte_size_fancy ((long_message_size
* num_received * 1000
* 1000)
/ duration.rel_value_us);
LOG (GNUNET_ERROR_TYPE_MESSAGE,
- "%lu/%lu packets in %llu us (%s/s) -- avg latency: %llu us\n",
- (unsigned long) num_received,
- (unsigned long) num_sent,
- (unsigned long long) duration.rel_value_us,
- goodput,
- (unsigned long long) avg_latency);
+ "%lu/%lu packets in %llu us (%s/s) -- avg latency: %llu us\n",
+ (unsigned long) num_received,
+ (unsigned long) num_sent,
+ (unsigned long long) duration.rel_value_us,
+ goodput,
+ (unsigned long long) avg_latency);
GNUNET_free (goodput);
ack = 0;
phase = TP_SIZE_CHECK;
@@ -493,12 +493,12 @@ incoming_message_cb (void *cls,
if (num_received >= (max_size) / 10)
{
LOG (GNUNET_ERROR_TYPE_MESSAGE,
- "Size packet test done.\n");
+ "Size packet test done.\n");
LOG (GNUNET_ERROR_TYPE_MESSAGE,
- "%lu/%lu packets -- avg latency: %llu us\n",
- (unsigned long) num_received,
- (unsigned long) num_sent,
- (unsigned long long) avg_latency);
+ "%lu/%lu packets -- avg latency: %llu us\n",
+ (unsigned long) num_received,
+ (unsigned long) num_sent,
+ (unsigned long long) avg_latency);
num_received = 0;
num_sent = 0;
avg_latency = 0;
@@ -511,7 +511,7 @@ incoming_message_cb (void *cls,
break;
}
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Finished\n");
+ "Finished\n");
GNUNET_SCHEDULER_shutdown ();
}
break;
@@ -587,6 +587,7 @@ main (int argc,
GNUNET_asprintf (&communicator_binary,
"gnunet-communicator-%s",
communicator_name);
+
if (GNUNET_OK !=
GNUNET_log_setup ("test_communicator_basic",
"DEBUG",
@@ -640,11 +641,26 @@ main (int argc,
&peer_id[i].public_key);
GNUNET_free (private_key);
LOG (GNUNET_ERROR_TYPE_INFO,
- "Identity of peer %u is %s\n",
- i,
- GNUNET_i2s_full (&peer_id[i]));
+ "Identity of peer %u is %s\n",
+ i,
+ GNUNET_i2s_full (&peer_id[i]));
}
LOG (GNUNET_ERROR_TYPE_MESSAGE, "Starting test...\n");
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "argv[0]: %s\n",
+ argv[0]);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "test_name: %s\n",
+ test_name);
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "communicator_name: %s\n",
+ communicator_name);
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "communicator_binary: %s\n",
+ communicator_binary);
+
GNUNET_SCHEDULER_run (&run,
NULL);
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
UNIXPATH = $GNUNET_RUNTIME_DIR/test_gnunet-communicator-unix_1.sock
[communicator-tcp]
+#PREFIX = xterm -geometry 100x85 -T peer1 -e gdb --args
+#PREFIX = valgrind --leak-check=full --track-origins=yes
BINDTO = 60002
DISABLE_V6 = NO
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
UNIXPATH = $GNUNET_RUNTIME_DIR/test_gnunet-communicator-unix_2.sock
[communicator-tcp]
+#PREFIX = xterm -geometry 100x85 -T peer2 -e gdb --args
+#PREFIX = valgrind --leak-check=full --track-origins=yes
BINDTO = 60003
DISABLE_V6 = NO
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
UNIXPATH = $GNUNET_RUNTIME_DIR/test_gnunet-communicator-unix_1.sock
[communicator-tcp]
+#PREFIX = xterm -geometry 100x85 -T peer1 -e gdb --args
+#PREFIX = valgrind --leak-check=full --track-origins=yes
BINDTO = 60002
DISABLE_V6 = YES
REKEY_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
UNIXPATH = $GNUNET_RUNTIME_DIR/test_gnunet-communicator-unix_2.sock
[communicator-tcp]
+#PREFIX = xterm -geometry 100x85 -T peer1 -e gdb --args
+#PREFIX = valgrind --leak-check=full --track-origins=yes
BINDTO = 60003
DISABLE_V6 = YES
REKEY_INTERVAL = 100ms