From afce6383a8010aa7ba8fd5255e953c7fd2f1872d Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Tue, 9 Jun 2009 23:40:27 +0000 Subject: [PATCH] keep addr --- src/util/common_logging.c | 3 +++ src/util/network.c | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/util/common_logging.c b/src/util/common_logging.c index 8ea099122..c77464eb5 100644 --- a/src/util/common_logging.c +++ b/src/util/common_logging.c @@ -417,6 +417,9 @@ const char *GNUNET_a2s (const struct sockaddr *addr, static char b2[6]; const struct sockaddr_in * v4; const struct sockaddr_in6 *v6; + + if (addr == NULL) + return _("unknown address"); switch (addr->sa_family) { case AF_INET: diff --git a/src/util/network.c b/src/util/network.c index 0bd46b2ec..740be2de2 100644 --- a/src/util/network.c +++ b/src/util/network.c @@ -40,7 +40,7 @@ #include "gnunet_network_lib.h" #include "gnunet_scheduler_lib.h" -#define DEBUG_NETWORK GNUNET_YES +#define DEBUG_NETWORK GNUNET_NO struct GNUNET_NETWORK_TransmitHandle { @@ -606,6 +606,7 @@ GNUNET_NETWORK_socket_create_from_sockaddr (struct GNUNET_SCHEDULER_Handle socklen_t addrlen, size_t maxbuf) { int s; + struct GNUNET_NETWORK_SocketHandle *ret; s = SOCKET (af_family, SOCK_STREAM, 0); if (s == -1) @@ -633,7 +634,11 @@ GNUNET_NETWORK_socket_create_from_sockaddr (struct GNUNET_SCHEDULER_Handle GNUNET_break (0 == CLOSE (s)); return NULL; } - return GNUNET_NETWORK_socket_create_from_existing (sched, s, maxbuf); + ret = GNUNET_NETWORK_socket_create_from_existing (sched, s, maxbuf); + ret->addr = GNUNET_malloc (addrlen); + memcpy (ret->addr, serv_addr, addrlen); + ret->addrlen = addrlen; + return ret; } -- 2.25.1