[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r10020 - in gnunet/src: hostlist transport
From: |
gnunet |
Subject: |
[GNUnet-SVN] r10020 - in gnunet/src: hostlist transport |
Date: |
Sat, 16 Jan 2010 21:44:57 +0100 |
Author: grothoff
Date: 2010-01-16 21:44:56 +0100 (Sat, 16 Jan 2010)
New Revision: 10020
Modified:
gnunet/src/hostlist/test_gnunet_daemon_hostlist_peer1.conf
gnunet/src/hostlist/test_gnunet_daemon_hostlist_peer2.conf
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
gnunet/src/transport/test_plugin_transport.c
Log:
further simplify transport API
Modified: gnunet/src/hostlist/test_gnunet_daemon_hostlist_peer1.conf
===================================================================
--- gnunet/src/hostlist/test_gnunet_daemon_hostlist_peer1.conf 2010-01-16
20:08:30 UTC (rev 10019)
+++ gnunet/src/hostlist/test_gnunet_daemon_hostlist_peer1.conf 2010-01-16
20:44:56 UTC (rev 10020)
@@ -27,7 +27,7 @@
[core]
PORT = 12970
DEBUG = YES
-#PREFIX = xterm -e xterm -e valgrind --tool=memcheck
+PREFIX = valgrind --tool=memcheck
[testing]
WEAKRANDOM = YES
Modified: gnunet/src/hostlist/test_gnunet_daemon_hostlist_peer2.conf
===================================================================
--- gnunet/src/hostlist/test_gnunet_daemon_hostlist_peer2.conf 2010-01-16
20:08:30 UTC (rev 10019)
+++ gnunet/src/hostlist/test_gnunet_daemon_hostlist_peer2.conf 2010-01-16
20:44:56 UTC (rev 10020)
@@ -27,7 +27,7 @@
[core]
PORT = 22970
DEBUG = YES
-#PREFIX = xterm -e xterm -e valgrind --tool=memcheck
+PREFIX = valgrind --tool=memcheck
[testing]
WEAKRANDOM = YES
Modified: gnunet/src/transport/gnunet-service-transport.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport.c 2010-01-16 20:08:30 UTC
(rev 10019)
+++ gnunet/src/transport/gnunet-service-transport.c 2010-01-16 20:44:56 UTC
(rev 10020)
@@ -850,11 +850,11 @@
*/
static void
transmit_send_continuation (void *cls,
- struct ReadyList *rl,
const struct GNUNET_PeerIdentity *target,
int result)
{
struct MessageQueue *mq = cls;
+ struct ReadyList *rl;
struct SendOkMessage send_ok_msg;
struct NeighbourList *n;
@@ -864,13 +864,10 @@
GNUNET_assert (0 ==
memcmp (&n->id, target,
sizeof (struct GNUNET_PeerIdentity)));
- if (rl == NULL)
- {
- rl = n->plugins;
- while ((rl != NULL) && (rl->plugin != mq->plugin))
- rl = rl->next;
- GNUNET_assert (rl != NULL);
- }
+ rl = n->plugins;
+ while ((rl != NULL) && (rl->plugin != mq->plugin))
+ rl = rl->next;
+ GNUNET_assert (rl != NULL);
if (result == GNUNET_OK)
{
rl->timeout = GNUNET_TIME_relative_to_absolute
(GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
@@ -980,7 +977,6 @@
GNUNET_i2s (&neighbour->id), rl->plugin->short_name);
#endif
rl->plugin->api->send (rl->plugin->api->cls,
- rl,
&neighbour->id,
mq->priority,
mq->message,
@@ -1859,9 +1855,8 @@
n->plugins = rpos->next;
GNUNET_assert (rpos->neighbour == n);
if (GNUNET_YES == rpos->connected)
- rpos->plugin->api->cancel (rpos->plugin->api->cls,
- rpos,
- &n->id);
+ rpos->plugin->api->disconnect (rpos->plugin->api->cls,
+ &n->id);
GNUNET_free (rpos);
}
@@ -1974,9 +1969,6 @@
* and generally forward to our receive callback.
*
* @param cls the "struct TransportPlugin *" we gave to the plugin
- * @param service_context value passed to the transport-service
- * to identify the neighbour; will be NULL on the first
- * call for a given peer
* @param latency estimated latency for communicating with the
* given peer
* @param peer (claimed) identity of the other peer
@@ -1985,9 +1977,8 @@
* for future receive calls for messages from this
* particular peer
*/
-static struct ReadyList *
+static void
plugin_env_receive (void *cls,
- struct ReadyList *service_context,
struct GNUNET_TIME_Relative latency,
const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message)
@@ -1996,32 +1987,26 @@
htons (sizeof (struct GNUNET_MessageHeader)),
htons (GNUNET_MESSAGE_TYPE_TRANSPORT_ACK)
};
+ struct ReadyList *service_context;
struct TransportPlugin *plugin = cls;
struct TransportClient *cpos;
struct InboundMessage *im;
uint16_t msize;
struct NeighbourList *n;
- if (service_context != NULL)
+ n = find_neighbour (peer);
+ if (n == NULL)
{
- n = service_context->neighbour;
- GNUNET_assert (n != NULL);
+ if (message == NULL)
+ return; /* disconnect of peer already marked down */
+ n = setup_new_neighbour (peer);
}
- else
- {
- n = find_neighbour (peer);
- if (n == NULL)
- {
- if (message == NULL)
- return NULL; /* disconnect of peer already marked down */
- n = setup_new_neighbour (peer);
- }
- service_context = n->plugins;
- while ((service_context != NULL) && (plugin != service_context->plugin))
- service_context = service_context->next;
- GNUNET_assert ((plugin->api->send == NULL) ||
- (service_context != NULL));
- }
+ service_context = n->plugins;
+ while ( (service_context != NULL) &&
+ (plugin != service_context->plugin) )
+ service_context = service_context->next;
+ GNUNET_assert ((plugin->api->send == NULL) ||
+ (service_context != NULL));
if (message == NULL)
{
#if DEBUG_TRANSPORT
@@ -2033,7 +2018,7 @@
if (service_context != NULL)
service_context->connected = GNUNET_NO;
disconnect_neighbour (n, GNUNET_YES);
- return NULL;
+ return;
}
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
@@ -2073,7 +2058,7 @@
/* TODO: call stats */
GNUNET_assert ( (service_context == NULL) ||
(NULL != service_context->neighbour) );
- return service_context;
+ return;
}
switch (ntohs (message->type))
{
@@ -2119,7 +2104,6 @@
}
GNUNET_assert ( (service_context == NULL) ||
(NULL != service_context->neighbour) );
- return service_context;
}
Modified: gnunet/src/transport/plugin_transport.h
===================================================================
--- gnunet/src/transport/plugin_transport.h 2010-01-16 20:08:30 UTC (rev
10019)
+++ gnunet/src/transport/plugin_transport.h 2010-01-16 20:44:56 UTC (rev
10020)
@@ -44,23 +44,11 @@
#include "gnunet_transport_service.h"
/**
- * Opaque internal context for a particular peer of the transport
- * service. Plugins will be given a pointer to this type and, if
- * cheaply possible, should pass this pointer back to the transport
- * service whenever additional messages from the same peer are
- * received.
- */
-struct ReadyList;
-
-/**
* Function called by the transport for each received message.
* This function should also be called with "NULL" for the
* message to signal that the other peer disconnected.
*
* @param cls closure
- * @param service_context value passed to the transport-service
- * to identify the neighbour; will be NULL on the first
- * call for a given peer
* @param latency estimated latency for communicating with the
* given peer; should be set to GNUNET_TIME_UNIT_FOREVER_REL
* until the transport has seen messages transmitted in
@@ -70,20 +58,14 @@
* using this one plugin actually works
* @param peer (claimed) identity of the other peer
* @param message the message, NULL if peer was disconnected
- * @return the new service_context that the plugin should use
- * for future receive calls for messages from this
- * particular peer
*/
-typedef struct ReadyList *
- (*GNUNET_TRANSPORT_PluginReceiveCallback) (void *cls,
- struct ReadyList *
- service_context,
- struct GNUNET_TIME_Relative
- latency,
- const struct GNUNET_PeerIdentity
- * peer,
- const struct GNUNET_MessageHeader
- * message);
+typedef void (*GNUNET_TRANSPORT_PluginReceiveCallback) (void *cls,
+ struct
GNUNET_TIME_Relative
+ latency,
+ const struct
GNUNET_PeerIdentity
+ * peer,
+ const struct
GNUNET_MessageHeader
+ * message);
/**
@@ -247,8 +229,6 @@
* upon "completion".
*
* @param cls closure
- * @param service_context value passed to the transport-service
- * to identify the neighbour
* @param target who was the recipient of the message?
* @param result GNUNET_OK on success
* GNUNET_SYSERR if the target disconnected;
@@ -257,11 +237,10 @@
*/
typedef void
(*GNUNET_TRANSPORT_TransmitContinuation) (void *cls,
- struct ReadyList *
- service_context,
const struct GNUNET_PeerIdentity *
target, int result);
+
/**
* Function that can be used by the transport service to transmit
* a message using the plugin. Note that in the case of a
@@ -271,11 +250,6 @@
* a fresh connection to another peer.
*
* @param cls closure
- * @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
- * scheduled for immediate transmission, the plugin is to
- * call the continuation with failure immediately
* @param target who should receive this message
* @param priority how important is the message?
* @param msg the message to transmit
@@ -288,7 +262,6 @@
*/
typedef void
(*GNUNET_TRANSPORT_TransmitFunction) (void *cls,
- struct ReadyList * service_context,
const struct GNUNET_PeerIdentity *
target,
unsigned int priority,
@@ -312,18 +285,13 @@
* closed after a getting this call.
*
* @param cls closure
- * @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
- * context pointer! Never NULL.
* @param target peer for which the last transmission is
* to be cancelled
*/
typedef void
- (*GNUNET_TRANSPORT_CancelFunction) (void *cls,
- struct ReadyList * service_context,
- const struct GNUNET_PeerIdentity *
- target);
+ (*GNUNET_TRANSPORT_DisconnectFunction) (void *cls,
+ const struct GNUNET_PeerIdentity *
+ target);
/**
@@ -423,11 +391,13 @@
GNUNET_TRANSPORT_TransmitFunction send;
/**
- * Function that can be used to force the plugin to disconnect
- * from the given peer and cancel all previous transmissions
- * (and their continuationc).
+ * Function that can be used to force the plugin to disconnect from
+ * the given peer and cancel all previous transmissions (and their
+ * continuations). Note that if the transport does not have
+ * sessions / persistent connections (for example, UDP), this
+ * function may very well do nothing.
*/
- GNUNET_TRANSPORT_CancelFunction cancel;
+ GNUNET_TRANSPORT_DisconnectFunction disconnect;
/**
* Function to pretty-print addresses. NOTE: this function is not
Modified: gnunet/src/transport/plugin_transport_tcp.c
===================================================================
--- gnunet/src/transport/plugin_transport_tcp.c 2010-01-16 20:08:30 UTC (rev
10019)
+++ gnunet/src/transport/plugin_transport_tcp.c 2010-01-16 20:44:56 UTC (rev
10020)
@@ -264,11 +264,6 @@
struct GNUNET_SERVER_Client *client;
/**
- * gnunet-service-transport context for this connection.
- */
- struct ReadyList *service_context;
-
- /**
* Messages currently pending for transmission
* to this peer, if any.
*/
@@ -560,7 +555,6 @@
#endif
if (pm->transmit_cont != NULL)
pm->transmit_cont (pm->transmit_cont_cls,
- session->service_context,
&session->target, GNUNET_SYSERR);
GNUNET_free (pm);
}
@@ -600,7 +594,6 @@
session->pending_messages = pm->next;
if (pm->transmit_cont != NULL)
pm->transmit_cont (pm->transmit_cont_cls,
- session->service_context,
&session->target, GNUNET_OK);
GNUNET_free (pm);
session->gen_time[session->out_msg_counter % ACK_LOG_SIZE]
@@ -829,7 +822,6 @@
session->pending_messages = pm->next;
if (NULL != pm->transmit_cont)
pm->transmit_cont (pm->transmit_cont_cls,
- session->service_context,
&session->target, GNUNET_SYSERR);
GNUNET_free (pm);
}
@@ -846,7 +838,6 @@
know about this one, so we need to
notify transport service about disconnect */
session->plugin->env->receive (session->plugin->env->cls,
- session->service_context,
GNUNET_TIME_UNIT_ZERO,
&session->target, NULL);
}
@@ -1081,7 +1072,6 @@
*/
static void
tcp_plugin_send (void *cls,
- struct ReadyList *service_context,
const struct GNUNET_PeerIdentity *target,
unsigned int priority,
const struct GNUNET_MessageHeader *msg,
@@ -1117,7 +1107,6 @@
session->quota_in = plugin->env->default_quota_in;
session->expecting_welcome = GNUNET_YES;
session->pending_messages = pm;
- session->service_context = service_context;
session->ic = GNUNET_PEERINFO_iterate (plugin->env->cfg,
plugin->env->sched,
target,
@@ -1126,7 +1115,6 @@
}
GNUNET_assert (session != NULL);
GNUNET_assert (session->client != NULL);
- session->service_context = service_context;
/* append pm to pending_messages list */
pme = session->pending_messages;
if (pme == NULL)
@@ -1161,17 +1149,12 @@
* closed after a getting this call.
*
* @param cls closure
- * @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
- * context pointer! Never NULL.
* @param target peer for which the last transmission is
* to be cancelled
*/
static void
-tcp_plugin_cancel (void *cls,
- struct ReadyList *service_context,
- const struct GNUNET_PeerIdentity *target)
+tcp_plugin_disconnect (void *cls,
+ const struct GNUNET_PeerIdentity *target)
{
struct Plugin *plugin = cls;
struct Session *session;
@@ -1196,7 +1179,6 @@
pm->transmit_cont_cls = NULL;
pm = pm->next;
}
- session->service_context = NULL;
if (session->client != NULL)
{
GNUNET_SERVER_client_drop (session->client);
@@ -1866,10 +1848,8 @@
"Forwarding data of type %u to transport service.\n",
ntohs (msg->type));
#endif
- session->service_context
- = plugin->env->receive (plugin->env->cls,
- session->service_context,
- latency, &session->target, msg);
+ plugin->env->receive (plugin->env->cls,
+ latency, &session->target, msg);
/* update bandwidth used */
session->last_received += msize;
update_quota (session, GNUNET_NO);
@@ -2062,7 +2042,7 @@
api->cls = plugin;
api->validate = &tcp_plugin_validate;
api->send = &tcp_plugin_send;
- api->cancel = &tcp_plugin_cancel;
+ api->disconnect = &tcp_plugin_disconnect;
api->address_pretty_printer = &tcp_plugin_address_pretty_printer;
api->set_receive_quota = &tcp_plugin_set_receive_quota;
api->address_suggested = &tcp_plugin_address_suggested;
Modified: gnunet/src/transport/plugin_transport_template.c
===================================================================
--- gnunet/src/transport/plugin_transport_template.c 2010-01-16 20:08:30 UTC
(rev 10019)
+++ gnunet/src/transport/plugin_transport_template.c 2010-01-16 20:44:56 UTC
(rev 10020)
@@ -163,8 +163,6 @@
* a message using the plugin.
*
* @param cls closure
- * @param service_context value passed to the transport-service
- * to identify the neighbour
* @param target who should receive this message
* @param priority how important is the message
* @param msg the message to transmit
@@ -177,7 +175,6 @@
*/
static void
template_plugin_send (void *cls,
- struct ReadyList *service_context,
const struct GNUNET_PeerIdentity *target,
unsigned int priority,
const struct GNUNET_MessageHeader *msg,
@@ -196,17 +193,11 @@
* (and their continuationc).
*
* @param cls closure
- * @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
- * context pointer! Never NULL.
- * @param target peer for which the last transmission is
- * to be cancelled
+ * @param target peer from which to disconnect
*/
static void
-template_plugin_cancel (void *cls,
- struct ReadyList *service_context,
- const struct GNUNET_PeerIdentity *target)
+template_plugin_disconnect (void *cls,
+ const struct GNUNET_PeerIdentity *target)
{
// struct Plugin *plugin = cls;
// FIXME
@@ -301,7 +292,7 @@
api->cls = plugin;
api->validate = &template_plugin_validate;
api->send = &template_plugin_send;
- api->cancel = &template_plugin_cancel;
+ api->disconnect = &template_plugin_disconnect;
api->address_pretty_printer = &template_plugin_address_pretty_printer;
api->set_receive_quota = &template_plugin_set_receive_quota;
api->address_suggested = &template_plugin_address_suggested;
Modified: gnunet/src/transport/test_plugin_transport.c
===================================================================
--- gnunet/src/transport/test_plugin_transport.c 2010-01-16 20:08:30 UTC
(rev 10019)
+++ gnunet/src/transport/test_plugin_transport.c 2010-01-16 20:44:56 UTC
(rev 10020)
@@ -92,10 +92,8 @@
/**
* Initialize Environment for this plugin
*/
-struct ReadyList *
+static void
receive(void *cls,
- struct ReadyList *
- service_context,
struct GNUNET_TIME_Relative
latency,
const struct GNUNET_PeerIdentity
@@ -103,7 +101,7 @@
const struct GNUNET_MessageHeader
* message)
{
- return NULL;
+ /* do nothing */
}
void notify_address(void *cls,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r10020 - in gnunet/src: hostlist transport,
gnunet <=