aboutsummaryrefslogtreecommitdiff
path: root/src/transport/tcp_connection_legacy.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/tcp_connection_legacy.c')
-rw-r--r--src/transport/tcp_connection_legacy.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/transport/tcp_connection_legacy.c b/src/transport/tcp_connection_legacy.c
index f5253445d..5b219a467 100644
--- a/src/transport/tcp_connection_legacy.c
+++ b/src/transport/tcp_connection_legacy.c
@@ -35,6 +35,15 @@
35#include "gnunet_resolver_service.h" 35#include "gnunet_resolver_service.h"
36 36
37 37
38/**
39 * Timeout we use on TCP connect before trying another
40 * result from the DNS resolver. Actual value used
41 * is this value divided by the number of address families.
42 * Default is 5s.
43 */
44#define CONNECT_RETRY_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
45
46
38 47
39#define LOG_STRERROR(kind,syscall) GNUNET_log_from_strerror (kind, "util-connection", syscall) 48#define LOG_STRERROR(kind,syscall) GNUNET_log_from_strerror (kind, "util-connection", syscall)
40 49
@@ -304,7 +313,7 @@ GNUNET_CONNECTION_create_from_existing (struct GNUNET_NETWORK_Handle *osSocket)
304 struct GNUNET_CONNECTION_Handle *connection; 313 struct GNUNET_CONNECTION_Handle *connection;
305 314
306 connection = GNUNET_new (struct GNUNET_CONNECTION_Handle); 315 connection = GNUNET_new (struct GNUNET_CONNECTION_Handle);
307 connection->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE; 316 connection->write_buffer_size = GNUNET_MIN_MESSAGE_SIZE;
308 connection->write_buffer = GNUNET_malloc (connection->write_buffer_size); 317 connection->write_buffer = GNUNET_malloc (connection->write_buffer_size);
309 connection->sock = osSocket; 318 connection->sock = osSocket;
310 return connection; 319 return connection;
@@ -451,7 +460,7 @@ GNUNET_CONNECTION_create_from_accept (GNUNET_CONNECTION_AccessCheck access_cb,
451 return NULL; 460 return NULL;
452 } 461 }
453 connection = GNUNET_new (struct GNUNET_CONNECTION_Handle); 462 connection = GNUNET_new (struct GNUNET_CONNECTION_Handle);
454 connection->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE; 463 connection->write_buffer_size = GNUNET_MIN_MESSAGE_SIZE;
455 connection->write_buffer = GNUNET_malloc (connection->write_buffer_size); 464 connection->write_buffer = GNUNET_malloc (connection->write_buffer_size);
456 connection->addr = uaddr; 465 connection->addr = uaddr;
457 connection->addrlen = addrlen; 466 connection->addrlen = addrlen;
@@ -824,7 +833,7 @@ try_connect_using_address (void *cls,
824 return; 833 return;
825 } 834 }
826 GNUNET_CONTAINER_DLL_insert (connection->ap_head, connection->ap_tail, ap); 835 GNUNET_CONTAINER_DLL_insert (connection->ap_head, connection->ap_tail, ap);
827 delay = GNUNET_CONNECTION_CONNECT_RETRY_TIMEOUT; 836 delay = CONNECT_RETRY_TIMEOUT;
828 if (NULL != connection->nth.notify_ready) 837 if (NULL != connection->nth.notify_ready)
829 delay = GNUNET_TIME_relative_min (delay, 838 delay = GNUNET_TIME_relative_min (delay,
830 GNUNET_TIME_absolute_get_remaining (connection->nth.transmit_timeout)); 839 GNUNET_TIME_absolute_get_remaining (connection->nth.transmit_timeout));
@@ -858,14 +867,14 @@ GNUNET_CONNECTION_create_from_connect (const struct GNUNET_CONFIGURATION_Handle
858 GNUNET_assert (0 < strlen (hostname)); /* sanity check */ 867 GNUNET_assert (0 < strlen (hostname)); /* sanity check */
859 connection = GNUNET_new (struct GNUNET_CONNECTION_Handle); 868 connection = GNUNET_new (struct GNUNET_CONNECTION_Handle);
860 connection->cfg = cfg; 869 connection->cfg = cfg;
861 connection->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE; 870 connection->write_buffer_size = GNUNET_MIN_MESSAGE_SIZE;
862 connection->write_buffer = GNUNET_malloc (connection->write_buffer_size); 871 connection->write_buffer = GNUNET_malloc (connection->write_buffer_size);
863 connection->port = port; 872 connection->port = port;
864 connection->hostname = GNUNET_strdup (hostname); 873 connection->hostname = GNUNET_strdup (hostname);
865 connection->dns_active = 874 connection->dns_active =
866 GNUNET_RESOLVER_ip_get (connection->hostname, 875 GNUNET_RESOLVER_ip_get (connection->hostname,
867 AF_UNSPEC, 876 AF_UNSPEC,
868 GNUNET_CONNECTION_CONNECT_RETRY_TIMEOUT, 877 CONNECT_RETRY_TIMEOUT,
869 &try_connect_using_address, 878 &try_connect_using_address,
870 connection); 879 connection);
871 return connection; 880 return connection;
@@ -909,7 +918,7 @@ GNUNET_CONNECTION_create_from_connect_to_unixpath (const struct GNUNET_CONFIGURA
909#endif 918#endif
910 connection = GNUNET_new (struct GNUNET_CONNECTION_Handle); 919 connection = GNUNET_new (struct GNUNET_CONNECTION_Handle);
911 connection->cfg = cfg; 920 connection->cfg = cfg;
912 connection->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE; 921 connection->write_buffer_size = GNUNET_MIN_MESSAGE_SIZE;
913 connection->write_buffer = GNUNET_malloc (connection->write_buffer_size); 922 connection->write_buffer = GNUNET_malloc (connection->write_buffer_size);
914 connection->port = 0; 923 connection->port = 0;
915 connection->hostname = NULL; 924 connection->hostname = NULL;
@@ -1535,7 +1544,7 @@ GNUNET_CONNECTION_notify_transmit_ready (struct GNUNET_CONNECTION_Handle *connec
1535 return NULL; 1544 return NULL;
1536 } 1545 }
1537 GNUNET_assert (NULL != notify); 1546 GNUNET_assert (NULL != notify);
1538 GNUNET_assert (size < GNUNET_SERVER_MAX_MESSAGE_SIZE); 1547 GNUNET_assert (size < GNUNET_MAX_MESSAGE_SIZE);
1539 GNUNET_assert (connection->write_buffer_off <= connection->write_buffer_size); 1548 GNUNET_assert (connection->write_buffer_off <= connection->write_buffer_size);
1540 GNUNET_assert (connection->write_buffer_pos <= connection->write_buffer_size); 1549 GNUNET_assert (connection->write_buffer_pos <= connection->write_buffer_size);
1541 GNUNET_assert (connection->write_buffer_pos <= connection->write_buffer_off); 1550 GNUNET_assert (connection->write_buffer_pos <= connection->write_buffer_off);