[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r8701 - gnunet/src/transport
From: |
gnunet |
Subject: |
[GNUnet-SVN] r8701 - gnunet/src/transport |
Date: |
Wed, 15 Jul 2009 17:43:00 -0600 |
Author: grothoff
Date: 2009-07-15 17:43:00 -0600 (Wed, 15 Jul 2009)
New Revision: 8701
Modified:
gnunet/src/transport/gnunet-service-transport.c
gnunet/src/transport/plugin_transport.h
gnunet/src/transport/plugin_transport_tcp.c
gnunet/src/transport/transport_api.c
Log:
bugfixes
Modified: gnunet/src/transport/gnunet-service-transport.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport.c 2009-07-15 22:21:00 UTC
(rev 8700)
+++ gnunet/src/transport/gnunet-service-transport.c 2009-07-15 23:43:00 UTC
(rev 8701)
@@ -873,6 +873,10 @@
rl->transmit_ready = GNUNET_YES;
if (mq->client != NULL)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Notifying client %p about failed transission to peer
`%4s'.\n",
+ mq->client,
+ GNUNET_i2s(target));
send_ok_msg.header.size = htons (sizeof (send_ok_msg));
send_ok_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK);
send_ok_msg.success = htonl (result);
@@ -885,6 +889,8 @@
another message (if available) */
if (result == GNUNET_OK)
try_transmission_to_peer (n);
+ else
+ disconnect_neighbour (n);
}
@@ -1867,13 +1873,15 @@
/* notify all clients about disconnect */
notify_clients_disconnect (&n->id);
- /* clean up all plugins, cancel connections & pending transmissions */
+ /* clean up all plugins, cancel connections and pending transmissions */
while (NULL != (rpos = n->plugins))
{
n->plugins = rpos->next;
GNUNET_assert (rpos->neighbour == n);
rpos->plugin->api->cancel (rpos->plugin->api->cls,
- rpos->plugin_handle, rpos, &n->id);
+ rpos->plugin_handle,
+ rpos,
+ &n->id);
GNUNET_free (rpos);
}
@@ -2040,14 +2048,19 @@
}
if (message == NULL)
{
+#if DEBUG_TRANSPORT
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
+ "Receive failed from `%4s', triggering disconnect\n",
+ GNUNET_i2s(&n->id));
+#endif
+ /* TODO: call stats */
+ disconnect_neighbour (n);
if ((service_context != NULL) &&
(service_context->plugin_handle == plugin_context))
{
service_context->connected = GNUNET_NO;
service_context->plugin_handle = NULL;
}
- /* TODO: call stats */
- disconnect_neighbour (n);
return NULL;
}
#if DEBUG_TRANSPORT
@@ -2362,8 +2375,10 @@
tcm = (const struct TryConnectMessage *) message;
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received `%s' request from client asking to connect to `%4s'\n",
- "TRY_CONNECT", GNUNET_i2s (&tcm->peer));
+ "Received `%s' request from client %p asking to connect to
`%4s'\n",
+ "TRY_CONNECT",
+ client,
+ GNUNET_i2s (&tcm->peer));
#endif
if (NULL == find_neighbour (&tcm->peer))
setup_new_neighbour (&tcm->peer);
Modified: gnunet/src/transport/plugin_transport.h
===================================================================
--- gnunet/src/transport/plugin_transport.h 2009-07-15 22:21:00 UTC (rev
8700)
+++ gnunet/src/transport/plugin_transport.h 2009-07-15 23:43:00 UTC (rev
8701)
@@ -349,7 +349,11 @@
* @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)
+ * 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
Modified: gnunet/src/transport/plugin_transport_tcp.c
===================================================================
--- gnunet/src/transport/plugin_transport_tcp.c 2009-07-15 22:21:00 UTC (rev
8700)
+++ gnunet/src/transport/plugin_transport_tcp.c 2009-07-15 23:43:00 UTC (rev
8701)
@@ -216,7 +216,6 @@
*/
struct GNUNET_MessageHeader *msg;
-
/**
* Continuation function to call once the message
* has been sent. Can be NULL if there is no
@@ -540,10 +539,17 @@
while (NULL != (pm = session->pending_messages))
{
session->pending_messages = pm->next;
+#if DEBUG_TCP
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
+ "tcp",
+ "Failed to transmit message of type %u to `%4s'.\n",
+ ntohs(pm->msg->type),
+ GNUNET_i2s(&session->target));
+#endif
if (pm->transmit_cont != NULL)
- pm->transmit_cont (pm->transmit_cont_cls,
- session->service_context,
- &session->target, GNUNET_SYSERR);
+ pm->transmit_cont (pm->transmit_cont_cls,
+ session->service_context,
+ &session->target, GNUNET_SYSERR);
GNUNET_free (pm);
}
return 0;
@@ -787,16 +793,6 @@
else
prev->next = session->next;
/* clean up state */
- if (session->client != NULL)
- {
-#if DEBUG_TCP
- GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
- "tcp",
- "Disconnecting from client address %p\n",
session->client);
-#endif
- GNUNET_SERVER_client_drop (session->client);
- session->client = NULL;
- }
if (session->transmit_handle != NULL)
{
GNUNET_NETWORK_notify_transmit_ready_cancel (session->transmit_handle);
@@ -804,6 +800,15 @@
}
while (NULL != (pm = session->pending_messages))
{
+#if DEBUG_TCP
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
+ "tcp",
+ pm->transmit_cont != NULL
+ ? "Could not deliver message of type %u to `%4s'.\n"
+ : "Could not deliver message of type %u to `%4s',
notifying.\n",
+ ntohs(pm->msg->type),
+ GNUNET_i2s(&session->target));
+#endif
session->pending_messages = pm->next;
if (NULL != pm->transmit_cont)
pm->transmit_cont (pm->transmit_cont_cls,
@@ -811,12 +816,24 @@
&session->target, GNUNET_SYSERR);
GNUNET_free (pm);
}
- /* notify transport service about disconnect */
- session->plugin->env->receive (session->plugin->env->cls,
- session,
- session->service_context,
- GNUNET_TIME_UNIT_ZERO,
- &session->target, NULL);
+ if (GNUNET_NO == session->expecting_welcome)
+ {
+#if DEBUG_TCP
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
+ "tcp",
+ "Notifying transport service about loss of data
connection with `%4s'.\n",
+ GNUNET_i2s(&session->target));
+#endif
+ /* Data session that actually went past the
+ initial handshake; transport service may
+ 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);
+ }
GNUNET_free_non_null (session->connect_addr);
GNUNET_free (session);
}
@@ -1132,7 +1149,11 @@
* @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)
+ * 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
@@ -1147,35 +1168,47 @@
const struct GNUNET_PeerIdentity *target)
{
struct Plugin *plugin = cls;
+ struct Session *session = plugin_context;
struct PendingMessage *pm;
- struct Session *session;
- struct Session *next;
+ 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;
+ }
+#if DEBUG_TCP
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
"tcp",
- "Asked to close session with `%4s'\n",
+ "Asked to cancel session %p with `%4s'\n",
+ plugin_context,
GNUNET_i2s(target));
- session = plugin->sessions;
- while (session != NULL)
+#endif
+ pm = session->pending_messages;
+ while (pm != NULL)
{
- next = session->next;
- if (0 == memcmp (target,
- &session->target, sizeof (struct GNUNET_PeerIdentity)))
- {
- pm = session->pending_messages;
- while (pm != NULL)
- {
- pm->transmit_cont = NULL;
- pm->transmit_cont_cls = NULL;
- pm = pm->next;
- }
- session->service_context = NULL;
- GNUNET_SERVER_client_disconnect (session->client);
- /* rest of the clean-up of the session will be done as part of
- disconnect_notify which should be triggered any time now */
- }
- session = next;
+ pm->transmit_cont = NULL;
+ pm->transmit_cont_cls = NULL;
+ pm = pm->next;
}
+ session->service_context = NULL;
+ if (session->client != NULL)
+ {
+ GNUNET_SERVER_client_drop (session->client);
+ session->client = NULL;
+ }
+ /* rest of the clean-up of the session will be done as part of
+ disconnect_notify which should be triggered any time now
+ (or which may be triggering this call in the first place) */
}
Modified: gnunet/src/transport/transport_api.c
===================================================================
--- gnunet/src/transport/transport_api.c 2009-07-15 22:21:00 UTC (rev
8700)
+++ gnunet/src/transport/transport_api.c 2009-07-15 23:43:00 UTC (rev
8701)
@@ -1054,6 +1054,11 @@
struct NeighbourList *pos;
struct GNUNET_TRANSPORT_TransmitHandle *th;
+#if DEBUG_TRANSPORT
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Removing neighbour `%s' from list of connected peers.\n",
+ GNUNET_i2s (peer));
+#endif
prev = NULL;
pos = h->neighbours;
while ((pos != NULL) &&
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r8701 - gnunet/src/transport,
gnunet <=