[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r31392 - in gnunet/src: include transport
From: |
gnunet |
Subject: |
[GNUnet-SVN] r31392 - in gnunet/src: include transport |
Date: |
Sun, 15 Dec 2013 02:56:00 +0100 |
Author: LRN
Date: 2013-12-15 02:56:00 +0100 (Sun, 15 Dec 2013)
New Revision: 31392
Modified:
gnunet/src/include/gnunet_transport_plugin.h
gnunet/src/transport/gnunet-service-transport_neighbours.c
gnunet/src/transport/plugin_transport_bluetooth.c
gnunet/src/transport/plugin_transport_http_client.c
gnunet/src/transport/plugin_transport_http_server.c
gnunet/src/transport/plugin_transport_tcp.c
gnunet/src/transport/plugin_transport_template.c
gnunet/src/transport/plugin_transport_udp.c
gnunet/src/transport/plugin_transport_unix.c
gnunet/src/transport/plugin_transport_wlan.c
Log:
Non-uniform keepalive timeout for different plugins
Modified: gnunet/src/include/gnunet_transport_plugin.h
===================================================================
--- gnunet/src/include/gnunet_transport_plugin.h 2013-12-14 23:44:22 UTC
(rev 31391)
+++ gnunet/src/include/gnunet_transport_plugin.h 2013-12-15 01:56:00 UTC
(rev 31392)
@@ -390,7 +390,18 @@
(*GNUNET_TRANSPORT_DisconnectSessionFunction) (void *cls,
struct Session *session);
+/**
+ * Function that is called to get the keepalive factor.
+ * GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT is divided by this number to
+ * calculate the interval between keepalive packets.
+ *
+ * @param cls closure with the `struct Plugin`
+ * @return keepalive factor
+ */
+typedef unsigned int
+(*GNUNET_TRANSPORT_QueryKeepaliveFactorFunction) (void *cls);
+
/**
* Function that can be called to force a disconnect from the
* specified neighbour. This should also cancel all previously
@@ -565,6 +576,13 @@
GNUNET_TRANSPORT_DisconnectSessionFunction disconnect_session;
/**
+ * Function that is used to query keepalive factor.
+ * GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT is divided by this number to
+ * calculate the interval between keepalive packets.
+ */
+ GNUNET_TRANSPORT_QueryKeepaliveFactorFunction query_keepalive_factor;
+
+ /**
* Function to pretty-print addresses. NOTE: this function is not
* yet used by transport-service, but will be used in the future
* once the transport-API has been completed.
Modified: gnunet/src/transport/gnunet-service-transport_neighbours.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_neighbours.c 2013-12-14
23:44:22 UTC (rev 31391)
+++ gnunet/src/transport/gnunet-service-transport_neighbours.c 2013-12-15
01:56:00 UTC (rev 31392)
@@ -55,15 +55,6 @@
#define QUOTA_VIOLATION_DROP_THRESHOLD 10
/**
- * How often do we send KEEPALIVE messages to each of our neighbours and
measure
- * the latency with this neighbour?
- * (idle timeout is 5 minutes or 300 seconds, so with 100s interval we
- * send 3 keepalives in each interval, so 3 messages would need to be
- * lost in a row for a disconnect).
- */
-#define KEEPALIVE_FREQUENCY GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_SECONDS, 100)
-
-/**
* How long are we willing to wait for a response from ATS before timing out?
*/
#define ATS_RESPONSE_TIMEOUT GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_MILLISECONDS, 5000)
@@ -963,18 +954,24 @@
* @param msgbuf_size number of bytes in @a msgbuf buffer
* @param priority transmission priority
* @param timeout transmission timeout
+ * @param use_keepalive_timeout #GNUNET_YES to use plugin-specific keep-alive
+ * timeout (@a timeout is ignored in that case), #GNUNET_NO otherwise
* @param cont continuation to call when finished (can be NULL)
* @param cont_cls closure for @a cont
+ * @return timeout (copy of @a timeout or a calculated one if
+ * @a use_keepalive_timeout is #GNUNET_YES.
*/
-static void
+static struct GNUNET_TIME_Relative
send_with_session (struct NeighbourMapEntry *n,
const char *msgbuf, size_t msgbuf_size,
uint32_t priority,
struct GNUNET_TIME_Relative timeout,
+ unsigned int use_keepalive_timeout,
GNUNET_TRANSPORT_TransmitContinuation cont,
void *cont_cls)
{
struct GNUNET_TRANSPORT_PluginFunctions *papi;
+ struct GNUNET_TIME_Relative result = GNUNET_TIME_UNIT_FOREVER_REL;
GNUNET_assert (n->primary_address.session != NULL);
if ( ((NULL == (papi = GST_plugins_find
(n->primary_address.address->transport_name)) ||
@@ -982,13 +979,16 @@
n->primary_address.session,
msgbuf, msgbuf_size,
priority,
- timeout,
+ (result = (GNUNET_NO == use_keepalive_timeout) ?
timeout :
+ GNUNET_TIME_relative_divide
(GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
+
papi->query_keepalive_factor (papi->cls))),
cont, cont_cls)))) &&
(NULL != cont))
cont (cont_cls, &n->id, GNUNET_SYSERR, msgbuf_size, 0);
GST_neighbours_notify_data_sent (&n->id,
n->primary_address.address, n->primary_address.session, msgbuf_size);
GNUNET_break (NULL != papi);
+ return result;
}
@@ -1063,10 +1063,10 @@
&disconnect_msg.purpose,
&disconnect_msg.signature));
- send_with_session (n,
- (const char *) &disconnect_msg, sizeof (disconnect_msg),
- UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL,
- &send_disconnect_cont, NULL);
+ (void) send_with_session (n,
+ (const char *) &disconnect_msg, sizeof
(disconnect_msg),
+ UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL,
+ GNUNET_NO, &send_disconnect_cont, NULL);
GNUNET_STATISTICS_update (GST_stats,
gettext_noop
("# DISCONNECT messages sent"), 1,
@@ -1278,10 +1278,10 @@
return; /* no more messages */
GNUNET_CONTAINER_DLL_remove (n->messages_head, n->messages_tail, mq);
n->is_active = mq;
- send_with_session (n,
- mq->message_buf, mq->message_buf_size,
- 0 /* priority */, timeout,
- &transmit_send_continuation, mq);
+ (void) send_with_session (n,
+ mq->message_buf, mq->message_buf_size,
+ 0 /* priority */, timeout, GNUNET_NO,
+ &transmit_send_continuation, mq);
}
@@ -1297,6 +1297,7 @@
send_keepalive (struct NeighbourMapEntry *n)
{
struct GNUNET_MessageHeader m;
+ struct GNUNET_TIME_Relative timeout;
GNUNET_assert ((S_CONNECTED == n->state) ||
(S_CONNECTED_SWITCHING_BLACKLIST == n->state) ||
@@ -1305,16 +1306,16 @@
return; /* no keepalive needed at this time */
m.size = htons (sizeof (struct GNUNET_MessageHeader));
m.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE);
- send_with_session (n,
- (const void *) &m, sizeof (m),
- UINT32_MAX /* priority */,
- KEEPALIVE_FREQUENCY,
- NULL, NULL);
+ timeout = send_with_session (n,
+ (const void *) &m, sizeof (m),
+ UINT32_MAX /* priority */,
+ GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES,
+ NULL, NULL);
GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# keepalives sent"), 1,
GNUNET_NO);
n->expect_latency_response = GNUNET_YES;
n->last_keep_alive_time = GNUNET_TIME_absolute_get ();
- n->keep_alive_time = GNUNET_TIME_relative_to_absolute (KEEPALIVE_FREQUENCY);
+ n->keep_alive_time = GNUNET_TIME_relative_to_absolute (timeout);
}
@@ -1349,11 +1350,11 @@
/* send reply to allow neighbour to measure latency */
m.size = htons (sizeof (struct GNUNET_MessageHeader));
m.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE_RESPONSE);
- send_with_session(n,
- (const void *) &m, sizeof (m),
- UINT32_MAX /* priority */,
- KEEPALIVE_FREQUENCY,
- NULL, NULL);
+ (void) send_with_session(n,
+ (const void *) &m, sizeof (m),
+ UINT32_MAX /* priority */,
+ GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES,
+ NULL, NULL);
}
@@ -2769,7 +2770,7 @@
msg.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_ACK);
(void) send_with_session(n,
(const char *) &msg, sizeof (struct
GNUNET_MessageHeader),
- UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL,
+ UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_NO,
NULL, NULL);
}
Modified: gnunet/src/transport/plugin_transport_bluetooth.c
===================================================================
--- gnunet/src/transport/plugin_transport_bluetooth.c 2013-12-14 23:44:22 UTC
(rev 31391)
+++ gnunet/src/transport/plugin_transport_bluetooth.c 2013-12-15 01:56:00 UTC
(rev 31392)
@@ -1120,6 +1120,21 @@
/**
+ * Function that is called to get the keepalive factor.
+ * GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT is divided by this number to
+ * calculate the interval between keepalive packets.
+ *
+ * @param cls closure with the `struct Plugin`
+ * @return keepalive factor
+ */
+static unsigned int
+bluetooth_query_keepalive_factor (void *cls)
+{
+ return 3;
+}
+
+
+/**
* Function that can be used by the transport service to transmit
* a message using the plugin. Note that in the case of a
* peer disconnecting, the continuation MUST be called
@@ -1912,6 +1927,7 @@
api->get_session = &bluetooth_plugin_get_session;
api->disconnect_peer = &bluetooth_plugin_disconnect_peer;
api->disconnect_session = &bluetooth_plugin_disconnect_session;
+ api->query_keepalive_factor = &bluetooth_query_keepalive_factor;
api->address_pretty_printer = &bluetooth_plugin_address_pretty_printer;
api->check_address = &bluetooth_plugin_address_suggested;
api->address_to_string = &bluetooth_plugin_address_to_string;;
Modified: gnunet/src/transport/plugin_transport_http_client.c
===================================================================
--- gnunet/src/transport/plugin_transport_http_client.c 2013-12-14 23:44:22 UTC
(rev 31391)
+++ gnunet/src/transport/plugin_transport_http_client.c 2013-12-15 01:56:00 UTC
(rev 31392)
@@ -700,6 +700,21 @@
/**
+ * Function that is called to get the keepalive factor.
+ * GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT is divided by this number to
+ * calculate the interval between keepalive packets.
+ *
+ * @param cls closure with the `struct Plugin`
+ * @return keepalive factor
+ */
+static unsigned int
+http_client_query_keepalive_factor (void *cls)
+{
+ return 3;
+}
+
+
+/**
* Function that can be used to force the plugin to disconnect
* from the given peer and cancel all previous transmissions
* (and their continuationc).
@@ -1773,6 +1788,7 @@
api->cls = plugin;
api->send = &http_client_plugin_send;
api->disconnect_session = &http_client_session_disconnect;
+ api->query_keepalive_factor = &http_client_query_keepalive_factor;
api->disconnect_peer = &http_client_peer_disconnect;
api->check_address = &http_client_plugin_address_suggested;
api->get_session = &http_client_plugin_get_session;
Modified: gnunet/src/transport/plugin_transport_http_server.c
===================================================================
--- gnunet/src/transport/plugin_transport_http_server.c 2013-12-14 23:44:22 UTC
(rev 31391)
+++ gnunet/src/transport/plugin_transport_http_server.c 2013-12-15 01:56:00 UTC
(rev 31392)
@@ -887,6 +887,21 @@
/**
+ * Function that is called to get the keepalive factor.
+ * GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT is divided by this number to
+ * calculate the interval between keepalive packets.
+ *
+ * @param cls closure with the `struct Plugin`
+ * @return keepalive factor
+ */
+static unsigned int
+http_server_query_keepalive_factor (void *cls)
+{
+ return 3;
+}
+
+
+/**
* Tell MHD that the connection should timeout after @a to seconds.
*
* @param plugin our plugin
@@ -3098,6 +3113,7 @@
api->send = &http_server_plugin_send;
api->disconnect_peer = &http_server_plugin_disconnect_peer;
api->disconnect_session = &http_server_plugin_disconnect_session;
+ api->query_keepalive_factor = &http_server_query_keepalive_factor;
api->check_address = &http_server_plugin_address_suggested;
api->get_session = &http_server_plugin_get_session;
Modified: gnunet/src/transport/plugin_transport_tcp.c
===================================================================
--- gnunet/src/transport/plugin_transport_tcp.c 2013-12-14 23:44:22 UTC (rev
31391)
+++ gnunet/src/transport/plugin_transport_tcp.c 2013-12-15 01:56:00 UTC (rev
31392)
@@ -865,6 +865,21 @@
/**
+ * Function that is called to get the keepalive factor.
+ * GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT is divided by this number to
+ * calculate the interval between keepalive packets.
+ *
+ * @param cls closure with the `struct Plugin`
+ * @return keepalive factor
+ */
+static unsigned int
+tcp_query_keepalive_factor (void *cls)
+{
+ return 3;
+}
+
+
+/**
* Session was idle, so disconnect it
*
* @param cls the `struct Session` of the idle session
@@ -2665,6 +2680,7 @@
api->get_session = &tcp_plugin_get_session;
api->disconnect_session = &tcp_disconnect_session;
+ api->query_keepalive_factor = &tcp_query_keepalive_factor;
api->disconnect_peer = &tcp_plugin_disconnect;
api->address_pretty_printer = &tcp_plugin_address_pretty_printer;
api->check_address = &tcp_plugin_check_address;
Modified: gnunet/src/transport/plugin_transport_template.c
===================================================================
--- gnunet/src/transport/plugin_transport_template.c 2013-12-14 23:44:22 UTC
(rev 31391)
+++ gnunet/src/transport/plugin_transport_template.c 2013-12-15 01:56:00 UTC
(rev 31392)
@@ -224,6 +224,21 @@
/**
+ * Function that is called to get the keepalive factor.
+ * GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT is divided by this number to
+ * calculate the interval between keepalive packets.
+ *
+ * @param cls closure with the `struct Plugin`
+ * @return keepalive factor
+ */
+static unsigned int
+template_plugin_query_keepalive_factor (void *cls)
+{
+ return 3;
+}
+
+
+/**
* Function obtain the network type for a session
*
* @param cls closure ('struct Plugin*')
@@ -393,6 +408,7 @@
api->send = &template_plugin_send;
api->disconnect_peer = &template_plugin_disconnect_peer;
api->disconnect_session = &template_plugin_disconnect_session;
+ api->query_keepalive_factor = &template_plugin_query_keepalive_factor;
api->address_pretty_printer = &template_plugin_address_pretty_printer;
api->check_address = &template_plugin_address_suggested;
api->address_to_string = &template_plugin_address_to_string;
Modified: gnunet/src/transport/plugin_transport_udp.c
===================================================================
--- gnunet/src/transport/plugin_transport_udp.c 2013-12-14 23:44:22 UTC (rev
31391)
+++ gnunet/src/transport/plugin_transport_udp.c 2013-12-15 01:56:00 UTC (rev
31392)
@@ -1314,6 +1314,21 @@
/**
+ * Function that is called to get the keepalive factor.
+ * GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT is divided by this number to
+ * calculate the interval between keepalive packets.
+ *
+ * @param cls closure with the `struct Plugin`
+ * @return keepalive factor
+ */
+static unsigned int
+udp_query_keepalive_factor (void *cls)
+{
+ return 15;
+}
+
+
+/**
* Destroy a session, plugin is being unloaded.
*
* @param cls the `struct Plugin`
@@ -3169,6 +3184,7 @@
api->cls = p;
api->send = NULL;
api->disconnect_session = &udp_disconnect_session;
+ api->query_keepalive_factor = &udp_query_keepalive_factor;
api->disconnect_peer = &udp_disconnect;
api->address_pretty_printer = &udp_plugin_address_pretty_printer;
api->address_to_string = &udp_address_to_string;
Modified: gnunet/src/transport/plugin_transport_unix.c
===================================================================
--- gnunet/src/transport/plugin_transport_unix.c 2013-12-14 23:44:22 UTC
(rev 31391)
+++ gnunet/src/transport/plugin_transport_unix.c 2013-12-15 01:56:00 UTC
(rev 31392)
@@ -600,6 +600,21 @@
/**
+ * Function that is called to get the keepalive factor.
+ * GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT is divided by this number to
+ * calculate the interval between keepalive packets.
+ *
+ * @param cls closure with the `struct Plugin`
+ * @return keepalive factor
+ */
+static unsigned int
+unix_query_keepalive_factor (void *cls)
+{
+ return 3;
+}
+
+
+/**
* Actually send out the message, assume we've got the address and
* send_handle squared away!
*
@@ -1614,6 +1629,7 @@
api->send = &unix_plugin_send;
api->disconnect_peer = &unix_peer_disconnect;
api->disconnect_session = &unix_session_disconnect;
+ api->query_keepalive_factor = &unix_query_keepalive_factor;
api->address_pretty_printer = &unix_plugin_address_pretty_printer;
api->address_to_string = &unix_address_to_string;
api->check_address = &unix_check_address;
Modified: gnunet/src/transport/plugin_transport_wlan.c
===================================================================
--- gnunet/src/transport/plugin_transport_wlan.c 2013-12-14 23:44:22 UTC
(rev 31391)
+++ gnunet/src/transport/plugin_transport_wlan.c 2013-12-15 01:56:00 UTC
(rev 31392)
@@ -696,6 +696,21 @@
/**
+ * Function that is called to get the keepalive factor.
+ * GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT is divided by this number to
+ * calculate the interval between keepalive packets.
+ *
+ * @param cls closure with the `struct Plugin`
+ * @return keepalive factor
+ */
+static unsigned int
+wlan_plugin_query_keepalive_factor (void *cls)
+{
+ return 3;
+}
+
+
+/**
* A session is timing out. Clean up.
*
* @param cls pointer to the Session
@@ -1968,6 +1983,7 @@
api->get_session = &wlan_plugin_get_session;
api->disconnect_peer = &wlan_plugin_disconnect_peer;
api->disconnect_session = &wlan_plugin_disconnect_session;
+ api->query_keepalive_factor = &wlan_plugin_query_keepalive_factor;
api->address_pretty_printer = &wlan_plugin_address_pretty_printer;
api->check_address = &wlan_plugin_address_suggested;
api->address_to_string = &wlan_plugin_address_to_string;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r31392 - in gnunet/src: include transport,
gnunet <=