diff options
Diffstat (limited to 'src/util/connection.c')
-rw-r--r-- | src/util/connection.c | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/src/util/connection.c b/src/util/connection.c index ea35b04e1..bdfcd1add 100644 --- a/src/util/connection.c +++ b/src/util/connection.c | |||
@@ -1,10 +1,10 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | (C) 2009, 2012 Christian Grothoff (and other contributing authors) | 3 | (C) 2009-2013 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
7 | by the Free Software Foundation; either version 2, or (at your | 7 | by the Free Software Foundation; either version 3, or (at your |
8 | option) any later version. | 8 | option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
@@ -33,11 +33,8 @@ | |||
33 | 33 | ||
34 | #include "platform.h" | 34 | #include "platform.h" |
35 | #include "gnunet_common.h" | 35 | #include "gnunet_common.h" |
36 | #include "gnunet_connection_lib.h" | 36 | #include "gnunet_util_lib.h" |
37 | #include "gnunet_container_lib.h" | ||
38 | #include "gnunet_resolver_service.h" | 37 | #include "gnunet_resolver_service.h" |
39 | #include "gnunet_scheduler_lib.h" | ||
40 | #include "gnunet_server_lib.h" | ||
41 | 38 | ||
42 | 39 | ||
43 | #define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__) | 40 | #define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__) |
@@ -304,7 +301,7 @@ GNUNET_CONNECTION_create_from_existing (struct GNUNET_NETWORK_Handle *osSocket) | |||
304 | { | 301 | { |
305 | struct GNUNET_CONNECTION_Handle *connection; | 302 | struct GNUNET_CONNECTION_Handle *connection; |
306 | 303 | ||
307 | connection = GNUNET_malloc (sizeof (struct GNUNET_CONNECTION_Handle)); | 304 | connection = GNUNET_new (struct GNUNET_CONNECTION_Handle); |
308 | connection->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE; | 305 | connection->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE; |
309 | connection->write_buffer = GNUNET_malloc (connection->write_buffer_size); | 306 | connection->write_buffer = GNUNET_malloc (connection->write_buffer_size); |
310 | connection->sock = osSocket; | 307 | connection->sock = osSocket; |
@@ -362,7 +359,7 @@ GNUNET_CONNECTION_create_from_accept (GNUNET_CONNECTION_AccessCheck access, | |||
362 | if ((AF_INET6 == sa->sa_family) && (IN6_IS_ADDR_V4MAPPED (&v6->sin6_addr))) | 359 | if ((AF_INET6 == sa->sa_family) && (IN6_IS_ADDR_V4MAPPED (&v6->sin6_addr))) |
363 | { | 360 | { |
364 | /* convert to V4 address */ | 361 | /* convert to V4 address */ |
365 | v4 = GNUNET_malloc (sizeof (struct sockaddr_in)); | 362 | v4 = GNUNET_new (struct sockaddr_in); |
366 | memset (v4, 0, sizeof (struct sockaddr_in)); | 363 | memset (v4, 0, sizeof (struct sockaddr_in)); |
367 | v4->sin_family = AF_INET; | 364 | v4->sin_family = AF_INET; |
368 | #if HAVE_SOCKADDR_IN_SIN_LEN | 365 | #if HAVE_SOCKADDR_IN_SIN_LEN |
@@ -432,7 +429,7 @@ GNUNET_CONNECTION_create_from_accept (GNUNET_CONNECTION_AccessCheck access, | |||
432 | GNUNET_free (uaddr); | 429 | GNUNET_free (uaddr); |
433 | return NULL; | 430 | return NULL; |
434 | } | 431 | } |
435 | connection = GNUNET_malloc (sizeof (struct GNUNET_CONNECTION_Handle)); | 432 | connection = GNUNET_new (struct GNUNET_CONNECTION_Handle); |
436 | connection->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE; | 433 | connection->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE; |
437 | connection->write_buffer = GNUNET_malloc (connection->write_buffer_size); | 434 | connection->write_buffer = GNUNET_malloc (connection->write_buffer_size); |
438 | connection->addr = uaddr; | 435 | connection->addr = uaddr; |
@@ -800,7 +797,7 @@ GNUNET_CONNECTION_create_from_connect (const struct GNUNET_CONFIGURATION_Handle | |||
800 | struct GNUNET_CONNECTION_Handle *connection; | 797 | struct GNUNET_CONNECTION_Handle *connection; |
801 | 798 | ||
802 | GNUNET_assert (0 < strlen (hostname)); /* sanity check */ | 799 | GNUNET_assert (0 < strlen (hostname)); /* sanity check */ |
803 | connection = GNUNET_malloc (sizeof (struct GNUNET_CONNECTION_Handle)); | 800 | connection = GNUNET_new (struct GNUNET_CONNECTION_Handle); |
804 | connection->cfg = cfg; | 801 | connection->cfg = cfg; |
805 | connection->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE; | 802 | connection->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE; |
806 | connection->write_buffer = GNUNET_malloc (connection->write_buffer_size); | 803 | connection->write_buffer = GNUNET_malloc (connection->write_buffer_size); |
@@ -834,7 +831,7 @@ GNUNET_CONNECTION_create_from_connect_to_unixpath (const struct | |||
834 | size_t slen; | 831 | size_t slen; |
835 | 832 | ||
836 | GNUNET_assert (0 < strlen (unixpath)); /* sanity check */ | 833 | GNUNET_assert (0 < strlen (unixpath)); /* sanity check */ |
837 | un = GNUNET_malloc (sizeof (struct sockaddr_un)); | 834 | un = GNUNET_new (struct sockaddr_un); |
838 | un->sun_family = AF_UNIX; | 835 | un->sun_family = AF_UNIX; |
839 | slen = strlen (unixpath); | 836 | slen = strlen (unixpath); |
840 | if (slen >= sizeof (un->sun_path)) | 837 | if (slen >= sizeof (un->sun_path)) |
@@ -848,7 +845,7 @@ GNUNET_CONNECTION_create_from_connect_to_unixpath (const struct | |||
848 | #if LINUX | 845 | #if LINUX |
849 | un->sun_path[0] = '\0'; | 846 | un->sun_path[0] = '\0'; |
850 | #endif | 847 | #endif |
851 | connection = GNUNET_malloc (sizeof (struct GNUNET_CONNECTION_Handle)); | 848 | connection = GNUNET_new (struct GNUNET_CONNECTION_Handle); |
852 | connection->cfg = cfg; | 849 | connection->cfg = cfg; |
853 | connection->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE; | 850 | connection->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE; |
854 | connection->write_buffer = GNUNET_malloc (connection->write_buffer_size); | 851 | connection->write_buffer = GNUNET_malloc (connection->write_buffer_size); |
@@ -1042,9 +1039,9 @@ receive_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1042 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT)) | 1039 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT)) |
1043 | { | 1040 | { |
1044 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1041 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1045 | "Receive from `%s' encounters error: timeout (%p)\n", | 1042 | "Receive from `%s' encounters error: timeout (%s, %p)\n", |
1046 | GNUNET_a2s (connection->addr, connection->addrlen), | 1043 | GNUNET_a2s (connection->addr, connection->addrlen), |
1047 | GNUNET_TIME_absolute_get_duration (connection->receive_timeout).rel_value, | 1044 | GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (connection->receive_timeout), GNUNET_YES), |
1048 | connection); | 1045 | connection); |
1049 | signal_receive_timeout (connection); | 1046 | signal_receive_timeout (connection); |
1050 | return; | 1047 | return; |