projects
/
oweals
/
gnunet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
note about assertion actually failing
[oweals/gnunet.git]
/
src
/
transport
/
tcp_connection_legacy.c
diff --git
a/src/transport/tcp_connection_legacy.c
b/src/transport/tcp_connection_legacy.c
index f5253445da20b473df570f627d442e4a929e5d48..6ecf50b79666e92cc1e3b8b94c291e6a45397bfa 100644
(file)
--- a/
src/transport/tcp_connection_legacy.c
+++ b/
src/transport/tcp_connection_legacy.c
@@
-2,20
+2,20
@@
This file is part of GNUnet.
Copyright (C) 2009-2013 GNUnet e.V.
This file is part of GNUnet.
Copyright (C) 2009-2013 GNUnet e.V.
- GNUnet is free software
; you can redistribute it and/or modify
-
it under the terms of the GNU
General Public License as published
- by the Free Software Foundation
; either version 3, or (at your
- option) any later version.
+ GNUnet is free software
: you can redistribute it and/or modify it
+
under the terms of the GNU Affero
General Public License as published
+ by the Free Software Foundation
, either version 3 of the License,
+ o
r (at your o
ption) any later version.
GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
+ Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
- You should have received a copy of the GNU General Public License
- along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
+ SPDX-License-Identifier: AGPL3.0-or-later
*/
/**
*/
/**
@@
-35,6
+35,15
@@
#include "gnunet_resolver_service.h"
#include "gnunet_resolver_service.h"
+/**
+ * Timeout we use on TCP connect before trying another
+ * result from the DNS resolver. Actual value used
+ * is this value divided by the number of address families.
+ * Default is 5s.
+ */
+#define CONNECT_RETRY_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
+
+
#define LOG_STRERROR(kind,syscall) GNUNET_log_from_strerror (kind, "util-connection", syscall)
#define LOG_STRERROR(kind,syscall) GNUNET_log_from_strerror (kind, "util-connection", syscall)
@@
-304,7
+313,7
@@
GNUNET_CONNECTION_create_from_existing (struct GNUNET_NETWORK_Handle *osSocket)
struct GNUNET_CONNECTION_Handle *connection;
connection = GNUNET_new (struct GNUNET_CONNECTION_Handle);
struct GNUNET_CONNECTION_Handle *connection;
connection = GNUNET_new (struct GNUNET_CONNECTION_Handle);
- connection->write_buffer_size = GNUNET_
SERVER_MIN_BUFFER
_SIZE;
+ connection->write_buffer_size = GNUNET_
MIN_MESSAGE
_SIZE;
connection->write_buffer = GNUNET_malloc (connection->write_buffer_size);
connection->sock = osSocket;
return connection;
connection->write_buffer = GNUNET_malloc (connection->write_buffer_size);
connection->sock = osSocket;
return connection;
@@
-451,7
+460,7
@@
GNUNET_CONNECTION_create_from_accept (GNUNET_CONNECTION_AccessCheck access_cb,
return NULL;
}
connection = GNUNET_new (struct GNUNET_CONNECTION_Handle);
return NULL;
}
connection = GNUNET_new (struct GNUNET_CONNECTION_Handle);
- connection->write_buffer_size = GNUNET_
SERVER_MIN_BUFFER
_SIZE;
+ connection->write_buffer_size = GNUNET_
MIN_MESSAGE
_SIZE;
connection->write_buffer = GNUNET_malloc (connection->write_buffer_size);
connection->addr = uaddr;
connection->addrlen = addrlen;
connection->write_buffer = GNUNET_malloc (connection->write_buffer_size);
connection->addr = uaddr;
connection->addrlen = addrlen;
@@
-824,7
+833,7
@@
try_connect_using_address (void *cls,
return;
}
GNUNET_CONTAINER_DLL_insert (connection->ap_head, connection->ap_tail, ap);
return;
}
GNUNET_CONTAINER_DLL_insert (connection->ap_head, connection->ap_tail, ap);
- delay =
GNUNET_CONNECTION_
CONNECT_RETRY_TIMEOUT;
+ delay = CONNECT_RETRY_TIMEOUT;
if (NULL != connection->nth.notify_ready)
delay = GNUNET_TIME_relative_min (delay,
GNUNET_TIME_absolute_get_remaining (connection->nth.transmit_timeout));
if (NULL != connection->nth.notify_ready)
delay = GNUNET_TIME_relative_min (delay,
GNUNET_TIME_absolute_get_remaining (connection->nth.transmit_timeout));
@@
-858,14
+867,14
@@
GNUNET_CONNECTION_create_from_connect (const struct GNUNET_CONFIGURATION_Handle
GNUNET_assert (0 < strlen (hostname)); /* sanity check */
connection = GNUNET_new (struct GNUNET_CONNECTION_Handle);
connection->cfg = cfg;
GNUNET_assert (0 < strlen (hostname)); /* sanity check */
connection = GNUNET_new (struct GNUNET_CONNECTION_Handle);
connection->cfg = cfg;
- connection->write_buffer_size = GNUNET_
SERVER_MIN_BUFFER
_SIZE;
+ connection->write_buffer_size = GNUNET_
MIN_MESSAGE
_SIZE;
connection->write_buffer = GNUNET_malloc (connection->write_buffer_size);
connection->port = port;
connection->hostname = GNUNET_strdup (hostname);
connection->dns_active =
GNUNET_RESOLVER_ip_get (connection->hostname,
AF_UNSPEC,
connection->write_buffer = GNUNET_malloc (connection->write_buffer_size);
connection->port = port;
connection->hostname = GNUNET_strdup (hostname);
connection->dns_active =
GNUNET_RESOLVER_ip_get (connection->hostname,
AF_UNSPEC,
-
GNUNET_CONNECTION_
CONNECT_RETRY_TIMEOUT,
+ CONNECT_RETRY_TIMEOUT,
&try_connect_using_address,
connection);
return connection;
&try_connect_using_address,
connection);
return connection;
@@
-909,7
+918,7
@@
GNUNET_CONNECTION_create_from_connect_to_unixpath (const struct GNUNET_CONFIGURA
#endif
connection = GNUNET_new (struct GNUNET_CONNECTION_Handle);
connection->cfg = cfg;
#endif
connection = GNUNET_new (struct GNUNET_CONNECTION_Handle);
connection->cfg = cfg;
- connection->write_buffer_size = GNUNET_
SERVER_MIN_BUFFER
_SIZE;
+ connection->write_buffer_size = GNUNET_
MIN_MESSAGE
_SIZE;
connection->write_buffer = GNUNET_malloc (connection->write_buffer_size);
connection->port = 0;
connection->hostname = NULL;
connection->write_buffer = GNUNET_malloc (connection->write_buffer_size);
connection->port = 0;
connection->hostname = NULL;
@@
-1209,8
+1218,10
@@
RETRY:
* @param timeout maximum amount of time to wait
* @param receiver function to call with received data
* @param receiver_cls closure for @a receiver
* @param timeout maximum amount of time to wait
* @param receiver function to call with received data
* @param receiver_cls closure for @a receiver
+ * @return #GNUNET_SYSERR if @a connection died (receiver was
+ * called with error)
*/
*/
-void
+int
GNUNET_CONNECTION_receive (struct GNUNET_CONNECTION_Handle *connection,
size_t max,
struct GNUNET_TIME_Relative timeout,
GNUNET_CONNECTION_receive (struct GNUNET_CONNECTION_Handle *connection,
size_t max,
struct GNUNET_TIME_Relative timeout,
@@
-1232,7
+1243,7
@@
GNUNET_CONNECTION_receive (struct GNUNET_CONNECTION_Handle *connection,
connection->sock,
&receive_ready,
connection);
connection->sock,
&receive_ready,
connection);
- return;
+ return
GNUNET_OK
;
}
if ((NULL == connection->dns_active) &&
(NULL == connection->ap_head) &&
}
if ((NULL == connection->dns_active) &&
(NULL == connection->ap_head) &&
@@
-1243,8
+1254,9
@@
GNUNET_CONNECTION_receive (struct GNUNET_CONNECTION_Handle *connection,
NULL, 0,
NULL, 0,
ETIMEDOUT);
NULL, 0,
NULL, 0,
ETIMEDOUT);
- return;
+ return
GNUNET_SYSERR
;
}
}
+ return GNUNET_OK;
}
}
@@
-1535,7
+1547,7
@@
GNUNET_CONNECTION_notify_transmit_ready (struct GNUNET_CONNECTION_Handle *connec
return NULL;
}
GNUNET_assert (NULL != notify);
return NULL;
}
GNUNET_assert (NULL != notify);
- GNUNET_assert (size < GNUNET_
SERVER_
MAX_MESSAGE_SIZE);
+ GNUNET_assert (size < GNUNET_MAX_MESSAGE_SIZE);
GNUNET_assert (connection->write_buffer_off <= connection->write_buffer_size);
GNUNET_assert (connection->write_buffer_pos <= connection->write_buffer_size);
GNUNET_assert (connection->write_buffer_pos <= connection->write_buffer_off);
GNUNET_assert (connection->write_buffer_off <= connection->write_buffer_size);
GNUNET_assert (connection->write_buffer_pos <= connection->write_buffer_size);
GNUNET_assert (connection->write_buffer_pos <= connection->write_buffer_off);