[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r10008 - in gnunet/src: arm hostlist topology transport
From: |
gnunet |
Subject: |
[GNUnet-SVN] r10008 - in gnunet/src: arm hostlist topology transport |
Date: |
Fri, 15 Jan 2010 10:38:53 +0100 |
Author: grothoff
Date: 2010-01-15 10:38:53 +0100 (Fri, 15 Jan 2010)
New Revision: 10008
Modified:
gnunet/src/arm/arm.h
gnunet/src/hostlist/test_gnunet_daemon_hostlist.c
gnunet/src/topology/gnunet-daemon-topology.c
gnunet/src/transport/gnunet-service-transport.c
gnunet/src/transport/plugin_transport.h
gnunet/src/transport/plugin_transport_tcp.c
gnunet/src/transport/plugin_transport_template.c
Log:
simplifying transport plugin API
Modified: gnunet/src/arm/arm.h
===================================================================
--- gnunet/src/arm/arm.h 2010-01-15 09:02:23 UTC (rev 10007)
+++ gnunet/src/arm/arm.h 2010-01-15 09:38:53 UTC (rev 10008)
@@ -31,6 +31,6 @@
* This option will turn on the DEBUG loglevel for
* all processes controlled by this ARM!
*/
-#define DEBUG_ARM GNUNET_NO
+#define DEBUG_ARM GNUNET_YES
#endif
Modified: gnunet/src/hostlist/test_gnunet_daemon_hostlist.c
===================================================================
--- gnunet/src/hostlist/test_gnunet_daemon_hostlist.c 2010-01-15 09:02:23 UTC
(rev 10007)
+++ gnunet/src/hostlist/test_gnunet_daemon_hostlist.c 2010-01-15 09:38:53 UTC
(rev 10008)
@@ -35,7 +35,7 @@
/**
* How long until we give up on transmitting the message?
*/
-#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15)
+#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 150)
static int ok;
Modified: gnunet/src/topology/gnunet-daemon-topology.c
===================================================================
--- gnunet/src/topology/gnunet-daemon-topology.c 2010-01-15 09:02:23 UTC
(rev 10007)
+++ gnunet/src/topology/gnunet-daemon-topology.c 2010-01-15 09:38:53 UTC
(rev 10008)
@@ -33,7 +33,7 @@
#include "gnunet_util_lib.h"
-#define DEBUG_TOPOLOGY GNUNET_YES
+#define DEBUG_TOPOLOGY GNUNET_NO
/**
* For how long do we blacklist a peer after a failed
@@ -388,7 +388,7 @@
#if DEBUG_TOPOLOGY
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Core told us that we connected to `%s'\n",
+ "Core told us that we are connecting to `%s'\n",
GNUNET_i2s (peer));
#endif
connection_count++;
Modified: gnunet/src/transport/gnunet-service-transport.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport.c 2010-01-15 09:02:23 UTC
(rev 10007)
+++ gnunet/src/transport/gnunet-service-transport.c 2010-01-15 09:38:53 UTC
(rev 10008)
@@ -251,12 +251,6 @@
struct NeighbourList *neighbour;
/**
- * Opaque handle (specific to the plugin) for the
- * connection to our target; can be NULL.
- */
- void *plugin_handle;
-
- /**
* What was the last latency observed for this plugin
* and peer? Invalid if connected is GNUNET_NO.
*/
@@ -887,7 +881,6 @@
"Transmission to peer `%s' failed, marking connection as
down.\n",
GNUNET_i2s(target));
rl->connected = GNUNET_NO;
- rl->plugin_handle = NULL;
}
if (!mq->internal_msg)
rl->transmit_ready = GNUNET_YES;
@@ -986,15 +979,13 @@
ntohs (mq->message->type),
GNUNET_i2s (&neighbour->id), rl->plugin->short_name);
#endif
- rl->plugin_handle
- = rl->plugin->api->send (rl->plugin->api->cls,
- rl->plugin_handle,
- rl,
- &neighbour->id,
- mq->priority,
- mq->message,
- GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
- &transmit_send_continuation, mq);
+ rl->plugin->api->send (rl->plugin->api->cls,
+ rl,
+ &neighbour->id,
+ mq->priority,
+ mq->message,
+ GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
+ &transmit_send_continuation, mq);
}
@@ -1939,7 +1930,6 @@
GNUNET_assert (rpos->neighbour == n);
if (GNUNET_YES == rpos->connected)
rpos->plugin->api->cancel (rpos->plugin->api->cls,
- rpos->plugin_handle,
rpos,
&n->id);
GNUNET_free (rpos);
@@ -2054,9 +2044,6 @@
* and generally forward to our receive callback.
*
* @param cls the "struct TransportPlugin *" we gave to the plugin
- * @param plugin_context value to pass to this plugin
- * to respond to the given peer (use is optional,
- * but may speed up processing)
* @param service_context value passed to the transport-service
* to identify the neighbour; will be NULL on the first
* call for a given peer
@@ -2070,7 +2057,6 @@
*/
static struct ReadyList *
plugin_env_receive (void *cls,
- void *plugin_context,
struct ReadyList *service_context,
struct GNUNET_TIME_Relative latency,
const struct GNUNET_PeerIdentity *peer,
@@ -2114,12 +2100,8 @@
GNUNET_i2s(&n->id));
#endif
/* TODO: call stats */
- if ((service_context != NULL) &&
- (service_context->plugin_handle == plugin_context))
- {
- service_context->connected = GNUNET_NO;
- service_context->plugin_handle = NULL;
- }
+ if (service_context != NULL)
+ service_context->connected = GNUNET_NO;
disconnect_neighbour (n, GNUNET_YES);
return NULL;
}
@@ -2138,7 +2120,6 @@
}
service_context->timeout
= GNUNET_TIME_relative_to_absolute
(GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
- service_context->plugin_handle = plugin_context;
service_context->latency = latency;
}
/* update traffic received amount ... */
Modified: gnunet/src/transport/plugin_transport.h
===================================================================
--- gnunet/src/transport/plugin_transport.h 2010-01-15 09:02:23 UTC (rev
10007)
+++ gnunet/src/transport/plugin_transport.h 2010-01-15 09:38:53 UTC (rev
10008)
@@ -58,9 +58,6 @@
* message to signal that the other peer disconnected.
*
* @param cls closure
- * @param plugin_context value to pass to this plugin
- * to respond to the given peer (use is optional,
- * but may speed up processing)
* @param service_context value passed to the transport-service
* to identify the neighbour; will be NULL on the first
* call for a given peer
@@ -79,7 +76,6 @@
*/
typedef struct ReadyList *
(*GNUNET_TRANSPORT_PluginReceiveCallback) (void *cls,
- void *plugin_context,
struct ReadyList *
service_context,
struct GNUNET_TIME_Relative
@@ -299,9 +295,6 @@
* a fresh connection to another peer.
*
* @param cls closure
- * @param plugin_context value we were asked to pass to this plugin
- * to respond to the given peer (use is optional,
- * but may speed up processing), can be NULL
* @param service_context value passed to the transport-service
* to identify the neighbour; NULL is used to indicate
* an urgent message. If the urgent message can not be
@@ -316,12 +309,9 @@
* for the next transmission call; or if the
* peer disconnected...); can be NULL
* @param cont_cls closure for cont
- * @return plugin_context that should be used next time for
- * sending messages to the specified peer
*/
-typedef void *
+typedef void
(*GNUNET_TRANSPORT_TransmitFunction) (void *cls,
- void *plugin_context,
struct ReadyList * service_context,
const struct GNUNET_PeerIdentity *
target,
@@ -346,14 +336,6 @@
* closed after a getting this call.
*
* @param cls closure
- * @param plugin_context value we were asked to pass to this plugin
- * to respond to the given peer (use is optional,
- * but may speed up processing), can be NULL (if
- * NULL was returned from the transmit function); note
- * that use of NULL is dangerous since then this call may
- * cancel any session with the target peer (including
- * HELLO validation sessions), which is likely not what
- * is intended.
* @param service_context must correspond to the service context
* of the corresponding Transmit call; the plugin should
* not cancel a send call made with a different service
@@ -363,7 +345,6 @@
*/
typedef void
(*GNUNET_TRANSPORT_CancelFunction) (void *cls,
- void *plugin_context,
struct ReadyList * service_context,
const struct GNUNET_PeerIdentity *
target);
Modified: gnunet/src/transport/plugin_transport_tcp.c
===================================================================
--- gnunet/src/transport/plugin_transport_tcp.c 2010-01-15 09:02:23 UTC (rev
10007)
+++ gnunet/src/transport/plugin_transport_tcp.c 2010-01-15 09:38:53 UTC (rev
10008)
@@ -386,6 +386,11 @@
struct GNUNET_SERVER_MessageHandler *handlers;
/**
+ * Handle for request of hostname resolution, non-NULL if pending.
+ */
+ struct GNUNET_RESOLVER_RequestHandle *hostname_dns;
+
+ /**
* ID of task used to update our addresses when one expires.
*/
GNUNET_SCHEDULER_TaskIdentifier address_update_task;
@@ -404,14 +409,7 @@
};
-
/**
- * Handle for request of hostname resolution, non-NULL if pending.
- */
-static struct GNUNET_RESOLVER_RequestHandle *hostname_dns;
-
-
-/**
* Find the session handle for the given peer.
*/
static struct Session *
@@ -837,7 +835,6 @@
know about this one, so we need to
notify transport service about disconnect */
session->plugin->env->receive (session->plugin->env->cls,
- session,
session->service_context,
GNUNET_TIME_UNIT_ZERO,
&session->target, NULL);
@@ -1058,9 +1055,6 @@
* a message using the plugin.
*
* @param cls closure
- * @param plugin_context value we were asked to pass to this plugin
- * to respond to the given peer (use is optional,
- * but may speed up processing), can be NULL
* @param service_context value passed to the transport-service
* to identify the neighbour
* @param target who should receive this message
@@ -1072,12 +1066,9 @@
* for the next transmission call; or if the
* peer disconnected...)
* @param cont_cls closure for cont
- * @return plugin_context that should be used next time for
- * sending messages to the specified peer
*/
-static void *
+static void
tcp_plugin_send (void *cls,
- void *plugin_context,
struct ReadyList *service_context,
const struct GNUNET_PeerIdentity *target,
unsigned int priority,
@@ -1086,12 +1077,11 @@
GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls)
{
struct Plugin *plugin = cls;
- struct Session *session = plugin_context;
+ struct Session *session;
struct PendingMessage *pm;
struct PendingMessage *pme;
- if (session == NULL)
- session = find_session_by_target (plugin, target);
+ session = find_session_by_target (plugin, target);
pm = GNUNET_malloc (sizeof (struct PendingMessage) + ntohs (msg->size));
pm->msg = (struct GNUNET_MessageHeader *) &pm[1];
memcpy (pm->msg, msg, ntohs (msg->size));
@@ -1120,7 +1110,7 @@
plugin->env->sched,
target,
0, timeout, &session_try_connect, session);
- return session;
+ return;
}
GNUNET_assert (session != NULL);
GNUNET_assert (session->client != NULL);
@@ -1142,7 +1132,6 @@
"tcp", "Asked to transmit, added message to list.\n");
#endif
process_pending_messages (session);
- return session;
}
@@ -1160,14 +1149,6 @@
* closed after a getting this call.
*
* @param cls closure
- * @param plugin_context value we were asked to pass to this plugin
- * to respond to the given peer (use is optional,
- * but may speed up processing), can be NULL (if
- * NULL was returned from the transmit function); note
- * that use of NULL is dangerous since then this call may
- * cancel any session with the target peer (including
- * HELLO validation sessions), which is likely not what
- * is intended.
* @param service_context must correspond to the service context
* of the corresponding Transmit call; the plugin should
* not cancel a send call made with a different service
@@ -1177,26 +1158,16 @@
*/
static void
tcp_plugin_cancel (void *cls,
- void *plugin_context,
struct ReadyList *service_context,
const struct GNUNET_PeerIdentity *target)
{
struct Plugin *plugin = cls;
- struct Session *session = plugin_context;
+ struct Session *session;
struct PendingMessage *pm;
+ session = find_session_by_target (plugin, target);
if (session == NULL)
{
-#if DEBUG_TCP
- GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING,
- "tcp",
- "Asked to cancel with `%4s' without specification of
specifics; will try to find an applicable session\n",
- GNUNET_i2s(target));
-#endif
- session = find_session_by_target (plugin, target);
- }
- if (session == NULL)
- {
GNUNET_break (0);
return;
}
@@ -1886,7 +1857,6 @@
#endif
session->service_context
= plugin->env->receive (plugin->env->cls,
- session,
session->service_context,
latency, &session->target, msg);
/* update bandwidth used */
@@ -2014,7 +1984,7 @@
if (addr == NULL)
{
- hostname_dns = NULL;
+ plugin->hostname_dns = NULL;
return;
}
process_interfaces (plugin,
@@ -2100,11 +2070,11 @@
GNUNET_SERVER_disconnect_notify (plugin->server, &disconnect_notify,
plugin);
GNUNET_OS_network_interfaces_list (&process_interfaces, plugin);
- hostname_dns = GNUNET_RESOLVER_hostname_resolve (env->sched,
- env->cfg,
- AF_UNSPEC,
- HOSTNAME_RESOLVE_TIMEOUT,
- &process_hostname_ips,
plugin);
+ plugin->hostname_dns = GNUNET_RESOLVER_hostname_resolve (env->sched,
+ env->cfg,
+ AF_UNSPEC,
+
HOSTNAME_RESOLVE_TIMEOUT,
+
&process_hostname_ips, plugin);
return api;
}
@@ -2121,10 +2091,10 @@
while (NULL != (session = plugin->sessions))
disconnect_session (session);
- if (NULL != hostname_dns)
+ if (NULL != plugin->hostname_dns)
{
- GNUNET_RESOLVER_request_cancel (hostname_dns);
- hostname_dns = NULL;
+ GNUNET_RESOLVER_request_cancel (plugin->hostname_dns);
+ plugin->hostname_dns = NULL;
}
GNUNET_SERVICE_stop (plugin->service);
GNUNET_free (plugin->handlers);
Modified: gnunet/src/transport/plugin_transport_template.c
===================================================================
--- gnunet/src/transport/plugin_transport_template.c 2010-01-15 09:02:23 UTC
(rev 10007)
+++ gnunet/src/transport/plugin_transport_template.c 2010-01-15 09:38:53 UTC
(rev 10008)
@@ -163,9 +163,6 @@
* a message using the plugin.
*
* @param cls closure
- * @param plugin_context value we were asked to pass to this plugin
- * to respond to the given peer (use is optional,
- * but may speed up processing), can be NULL
* @param service_context value passed to the transport-service
* to identify the neighbour
* @param target who should receive this message
@@ -177,12 +174,9 @@
* for the next transmission call; or if the
* peer disconnected...)
* @param cont_cls closure for cont
- * @return plugin_context that should be used next time for
- * sending messages to the specified peer
*/
-static void *
+static void
template_plugin_send (void *cls,
- void *plugin_context,
struct ReadyList *service_context,
const struct GNUNET_PeerIdentity *target,
unsigned int priority,
@@ -192,18 +186,16 @@
void *cont_cls)
{
// struct Plugin *plugin = cls;
- return NULL;
}
/**
+ * Function that can be used to force the plugin to disconnect
+ * from the given peer and cancel all previous transmissions
+ * (and their continuationc).
*
* @param cls closure
- * @param plugin_context value we were asked to pass to this plugin
- * to respond to the given peer (use is optional,
- * but may speed up processing), can be NULL (if
- * NULL was returned from the transmit function)
* @param service_context must correspond to the service context
* of the corresponding Transmit call; the plugin should
* not cancel a send call made with a different service
@@ -213,7 +205,6 @@
*/
static void
template_plugin_cancel (void *cls,
- void *plugin_context,
struct ReadyList *service_context,
const struct GNUNET_PeerIdentity *target)
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r10008 - in gnunet/src: arm hostlist topology transport,
gnunet <=