[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r9074 - gnunet/src/transport
From: |
gnunet |
Subject: |
[GNUnet-SVN] r9074 - gnunet/src/transport |
Date: |
Fri, 2 Oct 2009 07:02:40 -0600 |
Author: grothoff
Date: 2009-10-02 07:02:40 -0600 (Fri, 02 Oct 2009)
New Revision: 9074
Modified:
gnunet/src/transport/gnunet-service-transport.c
gnunet/src/transport/plugin_transport_tcp.c
gnunet/src/transport/test_transport_api.c
gnunet/src/transport/test_transport_api_peer1.conf
gnunet/src/transport/test_transport_api_peer2.conf
gnunet/src/transport/transport_api.c
Log:
misc bugfixes
Modified: gnunet/src/transport/gnunet-service-transport.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport.c 2009-10-02 12:55:26 UTC
(rev 9073)
+++ gnunet/src/transport/gnunet-service-transport.c 2009-10-02 13:02:40 UTC
(rev 9074)
@@ -67,8 +67,13 @@
/**
* How long until a HELLO verification attempt should time out?
+ * Must be rather small, otherwise a partially successful HELLO
+ * validation (some addresses working) might not be available
+ * before a client's request for a connection fails for good.
+ * Besides, if a single request to an address takes a long time,
+ * then the peer is unlikely worthwhile anyway.
*/
-#define HELLO_VERIFICATION_TIMEOUT GNUNET_TIME_UNIT_MINUTES
+#define HELLO_VERIFICATION_TIMEOUT GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_SECONDS, 3)
/**
* How often do we re-add (cheaper) plugins to our list of plugins
@@ -692,6 +697,11 @@
msize = ntohs (msg->size);
if (msize + tsize > size)
break;
+#if DEBUG_TRANSPORT
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Transmitting message of type %u to client.\n",
+ ntohs (msg->type));
+#endif
client->message_queue_head = q->next;
if (q->next == NULL)
client->message_queue_tail = NULL;
@@ -1451,6 +1461,7 @@
struct ValidationList *pos;
struct ValidationList *prev;
struct GNUNET_TIME_Absolute now;
+ struct GNUNET_TIME_Absolute first;
struct GNUNET_HELLO_Message *hello;
struct GNUNET_PeerIdentity pid;
struct NeighbourList *n;
@@ -1506,16 +1517,22 @@
/* finally, reschedule cleanup if needed; list is
ordered by timeout, so we need the last element... */
- pos = pending_validations;
- while ((pos != NULL) && (pos->next != NULL))
- pos = pos->next;
- if (NULL != pos)
- GNUNET_SCHEDULER_add_delayed (sched,
- GNUNET_NO,
- GNUNET_SCHEDULER_PRIORITY_IDLE,
- GNUNET_SCHEDULER_NO_TASK,
- GNUNET_TIME_absolute_get_remaining
- (pos->timeout), &cleanup_validation, NULL);
+ if (NULL != pending_validations)
+ {
+ first = pos->timeout;
+ pos = pending_validations;
+ while (pos != NULL)
+ {
+ first = GNUNET_TIME_absolute_min (first, pos->timeout);
+ pos = pos->next;
+ }
+ GNUNET_SCHEDULER_add_delayed (sched,
+ GNUNET_NO,
+ GNUNET_SCHEDULER_PRIORITY_IDLE,
+ GNUNET_SCHEDULER_NO_TASK,
+ GNUNET_TIME_absolute_get_remaining (first),
+ &cleanup_validation, NULL);
+ }
}
@@ -1543,7 +1560,7 @@
uint32_t challenge,
const char *sender_addr)
{
- int all_done;
+ unsigned int not_done;
int matched;
struct ValidationList *pos;
struct ValidationAddress *va;
@@ -1570,7 +1587,7 @@
GNUNET_i2s(peer));
return;
}
- all_done = GNUNET_YES;
+ not_done = 0;
matched = GNUNET_NO;
va = pos->addresses;
while (va != NULL)
@@ -1579,7 +1596,10 @@
{
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Confirmed validity of peer address.\n");
+ "Confirmed validity of address, peer `%4s' has address
`%s'.\n",
+ GNUNET_i2s (peer),
+ GNUNET_a2s ((const struct sockaddr*) &va[1],
+ va->addr_len));
#endif
GNUNET_log (GNUNET_ERROR_TYPE_INFO | GNUNET_ERROR_TYPE_BULK,
_("Another peer saw us using the address `%s' via `%s'.
If this is not plausible, this address should be listed in the configuration as
implausible to avoid MiM attacks.\n"),
@@ -1591,7 +1611,7 @@
matched = GNUNET_YES;
}
if (va->ok != GNUNET_YES)
- all_done = GNUNET_NO;
+ not_done++;
va = va->next;
}
if (GNUNET_NO == matched)
@@ -1602,8 +1622,14 @@
("Received `%s' message but have no record of a matching
`%s' message. Ignoring.\n"),
"PONG", "PING");
}
- if (GNUNET_YES == all_done)
+ if (0 == not_done)
{
+#if DEBUG_TRANSPORT
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "All addresses validated, will now construct `%s' for
`%4s'.\n",
+ "HELLO",
+ GNUNET_i2s (peer));
+#endif
pos->timeout.value = 0;
GNUNET_SCHEDULER_add_delayed (sched,
GNUNET_NO,
@@ -1612,6 +1638,17 @@
GNUNET_TIME_UNIT_ZERO,
&cleanup_validation, NULL);
}
+ else
+ {
+#if DEBUG_TRANSPORT
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Still waiting for %u additional `%s' messages before
constructing `%s' for `%4s'.\n",
+ not_done,
+ "PONG",
+ "HELLO",
+ GNUNET_i2s (peer));
+#endif
+ }
}
@@ -1731,14 +1768,21 @@
GNUNET_assert (GNUNET_OK ==
GNUNET_HELLO_get_id (chvc->hello,
&apeer));
+#if DEBUG_TRANSPORT
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Ready to validate addresses from `%s' message for peer `%4s'\n",
+ "HELLO", GNUNET_i2s (&apeer));
+#endif
va = chvc->e->addresses;
while (va != NULL)
{
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Establishing `%s' connection to validate `%s' of `%4s'\n",
+ "Establishing `%s' connection to validate `%s' address `%s'
of `%4s'\n",
va->transport_name,
"HELLO",
+ GNUNET_a2s ((const struct sockaddr*) &va[1],
+ va->addr_len),
GNUNET_i2s (&apeer));
#endif
tp = find_transport (va->transport_name);
@@ -1753,14 +1797,12 @@
va->ok = GNUNET_SYSERR;
va = va->next;
}
- if (chvc->e->next == NULL)
- GNUNET_SCHEDULER_add_delayed (sched,
- GNUNET_NO,
- GNUNET_SCHEDULER_PRIORITY_IDLE,
- GNUNET_SCHEDULER_NO_TASK,
- GNUNET_TIME_absolute_get_remaining
- (chvc->e->timeout), &cleanup_validation,
- NULL);
+ GNUNET_SCHEDULER_add_delayed (sched,
+ GNUNET_NO,
+ GNUNET_SCHEDULER_PRIORITY_IDLE,
+ GNUNET_SCHEDULER_NO_TASK,
+ GNUNET_TIME_absolute_get_remaining
(chvc->e->timeout),
+ &cleanup_validation, NULL);
GNUNET_free (chvc);
}
Modified: gnunet/src/transport/plugin_transport_tcp.c
===================================================================
--- gnunet/src/transport/plugin_transport_tcp.c 2009-10-02 12:55:26 UTC (rev
9073)
+++ gnunet/src/transport/plugin_transport_tcp.c 2009-10-02 13:02:40 UTC (rev
9074)
@@ -39,7 +39,7 @@
#include "plugin_transport.h"
#include "transport.h"
-#define DEBUG_TCP GNUNET_NO
+#define DEBUG_TCP GNUNET_YES
/**
* After how long do we expire an address that we
@@ -1490,8 +1490,17 @@
void *addr;
#if DEBUG_TRANSPORT
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
- "Processing PING\n");
+ if (GNUNET_OK ==
+ GNUNET_SERVER_client_get_address (client,
+ (void **) &addr,
+ &addrlen))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
+ "Processing `%s' from `%s'\n",
+ "PING",
+ GNUNET_a2s (addr, addrlen));
+ GNUNET_free (addr);
+ }
#endif
msize = ntohs (message->size);
if (msize < sizeof (struct ValidationChallengeMessage))
@@ -1570,25 +1579,12 @@
/**
- * Handle PING-message. If the plugin that gave us the message is
- * able to queue the PONG immediately, we only queue one PONG.
- * Otherwise we send at most TWO PONG messages, one via an unconfirmed
- * transport and one via a confirmed transport. Both addresses are
- * selected randomly among those available.
+ * Handle PONG-message.
*
- * @param plugin plugin that gave us the message
- * @param sender claimed sender of the PING
- * @param plugin_context context that might be used to send response
+ * @param plugin handle for this plugin
+ * @param sender claimed sender of the PONG
* @param message the actual message
*/
-/**
- * We've received a PING from this peer via TCP.
- * Send back our PONG.
- *
- * @param cls closure
- * @param client identification of the client
- * @param message the actual message
- */
static void
handle_tcp_pong (void *cls,
struct GNUNET_SERVER_Client *client,
@@ -1604,8 +1600,19 @@
struct sockaddr_in6 v6;
#if DEBUG_TRANSPORT
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
- "Processing PONG\n");
+ struct sockaddr *claddr;
+
+ if (GNUNET_OK ==
+ GNUNET_SERVER_client_get_address (client,
+ (void**) &claddr,
+ &addrlen))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
+ "Processing `%s' from `%s'\n",
+ "PONG",
+ GNUNET_a2s (claddr, addrlen));
+ GNUNET_free (claddr);
+ }
#endif
if (ntohs(message->size) < sizeof(struct ValidationChallengeResponse))
{
@@ -2002,9 +2009,11 @@
if (addr == NULL)
return;
- plugin->env->notify_address (plugin->env->cls,
- "tcp",
- addr, addrlen, GNUNET_TIME_UNIT_FOREVER_REL);
+ process_interfaces (plugin,
+ "<hostname>",
+ GNUNET_YES,
+ addr,
+ addrlen);
}
Modified: gnunet/src/transport/test_transport_api.c
===================================================================
--- gnunet/src/transport/test_transport_api.c 2009-10-02 12:55:26 UTC (rev
9073)
+++ gnunet/src/transport/test_transport_api.c 2009-10-02 13:02:40 UTC (rev
9074)
@@ -223,7 +223,8 @@
GNUNET_assert (GNUNET_OK ==
GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
message, &me->id));
- GNUNET_TRANSPORT_get_hello (p2.th, GNUNET_TIME_UNIT_MINUTES,
+ GNUNET_TRANSPORT_get_hello (p2.th,
+ TIMEOUT,
&exchange_hello_last, &p2);
}
@@ -241,7 +242,7 @@
setup_peer (&p1, "test_transport_api_peer1.conf");
setup_peer (&p2, "test_transport_api_peer2.conf");
GNUNET_TRANSPORT_get_hello (p1.th,
- GNUNET_TIME_UNIT_MINUTES, &exchange_hello, &p1);
+ TIMEOUT, &exchange_hello, &p1);
}
Modified: gnunet/src/transport/test_transport_api_peer1.conf
===================================================================
--- gnunet/src/transport/test_transport_api_peer1.conf 2009-10-02 12:55:26 UTC
(rev 9073)
+++ gnunet/src/transport/test_transport_api_peer1.conf 2009-10-02 13:02:40 UTC
(rev 9074)
@@ -9,7 +9,10 @@
[transport]
PORT = 12365
PLUGINS = tcp
-#DEBUG = YES
+DEBUG = YES
+#PREFIX = xterm -T t1 -e gdb -x cmd --args
+#BINARY = /home/grothoff/bin/gnunet-service-transport
+#PREFIX = valgrind --tool=memcheck
[arm]
PORT = 12366
Modified: gnunet/src/transport/test_transport_api_peer2.conf
===================================================================
--- gnunet/src/transport/test_transport_api_peer2.conf 2009-10-02 12:55:26 UTC
(rev 9073)
+++ gnunet/src/transport/test_transport_api_peer2.conf 2009-10-02 13:02:40 UTC
(rev 9074)
@@ -10,6 +10,9 @@
PORT = 22365
PLUGINS = tcp
#DEBUG = YES
+#PREFIX = xterm -T t2 -e gdb -x cmd --args
+#BINARY = /home/grothoff/bin/gnunet-service-transport
+#PREFIX = valgrind --tool=memcheck
[arm]
PORT = 22366
Modified: gnunet/src/transport/transport_api.c
===================================================================
--- gnunet/src/transport/transport_api.c 2009-10-02 12:55:26 UTC (rev
9073)
+++ gnunet/src/transport/transport_api.c 2009-10-02 13:02:40 UTC (rev
9074)
@@ -1108,6 +1108,10 @@
}
else
{
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ _("Connection with `%4s' failed, will keep trying for
%llu ms to deliver message\n"),
+ GNUNET_i2s (peer),
+ GNUNET_TIME_absolute_get_remaining (th->timeout).value);
/* try again in a bit */
GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == th->notify_delay_task);
th->notify_delay_task
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r9074 - gnunet/src/transport,
gnunet <=