PHASE #1: (Goal: settle key design questions)
-TRANSPORT:
-* Make sure that the service does not go bezerk
- on all plugins and all sessions on disconnects,
- specifically, whenever disconnect_neighbour is called.
- (We may have other sessions, in particular through other transports,
- that are active for the same peer; clearly we should
- not immediately discard all messages and stop all
- plugins); the call is fine in the various places where it is; but except in the
- timeout case, we should check the status of the other plugins before killing all.
-
-* "Another peer saw us using..." messages for TCP
- use the (random, high) sender port instead of the
- adjusted port; this will be confusing to users...
-
-==9033== Invalid read of size 8
-==9033== at 0x4042FA: plugin_env_receive (gnunet-service-transport.c:2058)
-==9033== by 0x7287643: disconnect_session (plugin_transport_tcp.c:831)
-==9033== by 0x7289539: disconnect_notify (plugin_transport_tcp.c:1919)
-==9033== by 0x524BE24: ??? (server.c:645)
-==9033== by 0x524C040: ??? (server.c:752)
-==9033== by 0x5245734: ??? (network.c:810)
-==9033== by 0x5245881: ??? (network.c:850)
-==9033== by 0x524A497: ??? (scheduler.c:425)
-==9033== by 0x524A77A: GNUNET_SCHEDULER_run (scheduler.c:520)
-==9033== by 0x524FF5C: GNUNET_SERVICE_run (service.c:1326)
-==9033== by 0x4054F4: main (gnunet-service-transport.c:2644)
-==9033== Address 0x6edaec0 is 24 bytes inside a block of size 64 free'd
-==9033== at 0x4C2130F: free (vg_replace_malloc.c:323)
-==9033== by 0x523453A: GNUNET_xfree_ (common_allocation.c:109)
-==9033== by 0x403DC8: disconnect_neighbour (gnunet-service-transport.c:1885)
-==9033== by 0x4042EE: plugin_env_receive (gnunet-service-transport.c:2057)
-==9033== by 0x7287643: disconnect_session (plugin_transport_tcp.c:831)
-==9033== by 0x7289539: disconnect_notify (plugin_transport_tcp.c:1919)
-==9033== by 0x524BE24: ??? (server.c:645)
-==9033== by 0x524C040: ??? (server.c:752)
-==9033== by 0x5245734: ??? (network.c:810)
-==9033== by 0x5245881: ??? (network.c:850)
-==9033== by 0x524A497: ??? (scheduler.c:425)
-==9033== by 0x524A77A: GNUNET_SCHEDULER_run (scheduler.c:520)
-==9033==
-
-
-==9033== Invalid write of size 4
-==9033== at 0x404308: plugin_env_receive (gnunet-service-transport.c:2061)
-==9033== by 0x7287643: disconnect_session (plugin_transport_tcp.c:831)
-==9033== by 0x7289539: disconnect_notify (plugin_transport_tcp.c:1919)
-==9033== by 0x524BE24: ??? (server.c:645)
-==9033== by 0x524C040: ??? (server.c:752)
-==9033== by 0x5245734: ??? (network.c:810)
-==9033== by 0x5245881: ??? (network.c:850)
-==9033== by 0x524A497: ??? (scheduler.c:425)
-==9033== by 0x524A77A: GNUNET_SCHEDULER_run (scheduler.c:520)
-==9033== by 0x524FF5C: GNUNET_SERVICE_run (service.c:1326)
-==9033== by 0x4054F4: main (gnunet-service-transport.c:2644)
-==9033== Address 0x6edaed8 is 48 bytes inside a block of size 64 free'd
-==9033== at 0x4C2130F: free (vg_replace_malloc.c:323)
-==9033== by 0x523453A: GNUNET_xfree_ (common_allocation.c:109)
-==9033== by 0x403DC8: disconnect_neighbour (gnunet-service-transport.c:1885)
-==9033== by 0x4042EE: plugin_env_receive (gnunet-service-transport.c:2057)
-==9033== by 0x7287643: disconnect_session (plugin_transport_tcp.c:831)
-==9033== by 0x7289539: disconnect_notify (plugin_transport_tcp.c:1919)
-==9033== by 0x524BE24: ??? (server.c:645)
-==9033== by 0x524C040: ??? (server.c:752)
-==9033== by 0x5245734: ??? (network.c:810)
-==9033== by 0x5245881: ??? (network.c:850)
-==9033== by 0x524A497: ??? (scheduler.c:425)
-==9033== by 0x524A77A: GNUNET_SCHEDULER_run (scheduler.c:520)
-==9033==
-
-
-
-CORE:
-* fails non-deterministically with empty /tmp directory
-
-
Util:
* improve disk API [Nils] (Nils, is this done? -Christian)
- should latency be included in the ReceiveCallback and
NotifyConnect or passed on request?
- FIXME's with latency being simply set to 0 in a few places
+ - Memory leak (running valgrind --trace-children=yes on test_transport_api:
+ ==28393== 16 bytes in 1 blocks are indirectly lost in loss record 1 of 5
+ ==28393== at 0x4C2260E: malloc (vg_replace_malloc.c:207)
+ ==28393== by 0x52343E3: GNUNET_xmalloc_unchecked_ (common_allocation.c:62)
+ ==28393== by 0x5234389: GNUNET_xmalloc_ (common_allocation.c:53)
+ ==28393== by 0x524458A: GNUNET_NETWORK_socket_create_from_accept (network.c:289)
+ ==28393== by 0x524B2DA: ??? (server.c:332)
+ ==28393== by 0x524A4C7: ??? (scheduler.c:425)
+ ==28393== by 0x524A73D: GNUNET_SCHEDULER_run (scheduler.c:510)
+ ==28393== by 0x524FF8C: GNUNET_SERVICE_run (service.c:1326)
+ ==28393== by 0x405500: main (gnunet-service-transport.c:2645)
+ And also:
+ ==28393== 65,744 (65,728 direct, 16 indirect) bytes in 1 blocks are definitely lost in loss record 5 of 5
+ ==28393== at 0x4C2260E: malloc (vg_replace_malloc.c:207)
+ ==28393== by 0x52343E3: GNUNET_xmalloc_unchecked_ (common_allocation.c:62)
+ ==28393== by 0x5234389: GNUNET_xmalloc_ (common_allocation.c:53)
+ ==28393== by 0x524473E: GNUNET_NETWORK_socket_create_from_accept (network.c:323)
+ (rest of trace identical)
+
* SETUP:
- auto-generate "defaults.conf" using gnunet-setup from "config.scm"
- integrate all options into "config.scm"
/**
* General core debugging.
*/
-#define DEBUG_CORE GNUNET_YES
+#define DEBUG_CORE GNUNET_NO
/**
* Debugging interaction core-clients.
*/
-#define DEBUG_CORE_CLIENT GNUNET_YES
+#define DEBUG_CORE_CLIENT GNUNET_NO
/**
* Definition of bits in the InitMessage's options field that specify
#include "gnunet_scheduler_lib.h"
#include "gnunet_transport_service.h"
-#define VERBOSE GNUNET_YES
+#define VERBOSE GNUNET_NO
#define START_ARM GNUNET_YES
#PREFIX = xterm -T transport1 -e
#PREFIX = xterm -T transport1 -e gdb -x cmd --args
#PREFIX = xterm -T transport1 -e valgrind --tool=memcheck
-DEBUG = YES
+#DEBUG = YES
[arm]
PORT = 12466
#OPTIONS = -l log-core-1
#PREFIX = xterm -T core1 -e gdb -x cmd --args
#PREFIX = xterm -T core1 -e
-DEBUG = YES
+#DEBUG = YES
[testing]
WEAKRANDOM = YES
PLUGINS = tcp
#PREFIX = xterm -T transport2 -e
#PREFIX = xterm -T transport2 -e valgrind --tool=memcheck
-DEBUG = YES
+#DEBUG = YES
[arm]
PORT = 22466
PORT = 22470
#PREFIX = xterm -T core2 -e
#PREFIX = xterm -T core2 -e valgrind --tool=memcheck
-DEBUG = YES
+#DEBUG = YES
[testing]
WEAKRANDOM = YES
/**
- * Check the ready list for the given neighbour and
- * if a plugin is ready for transmission (and if we
- * have a message), do so!
+ * The peer specified by the given neighbour has timed-out or a plugin
+ * has disconnected. We may either need to do nothing (other plugins
+ * still up), or trigger a full disconnect and clean up. This
+ * function updates our state and do the necessary notifications.
+ * Also notifies our clients that the neighbour is now officially
+ * gone.
*
- * @param neighbour target peer for which to check the plugins
+ * @param n the neighbour list entry for the peer
+ * @param check should we just check if all plugins
+ * disconnected or must we ask all plugins to
+ * disconnect?
*/
-static void try_transmission_to_peer (struct NeighbourList *neighbour);
+static void
+disconnect_neighbour (struct NeighbourList *n,
+ int check);
/**
- * The peer specified by the given neighbour has timed-out. Update
- * our state and do the necessary notifications. Also notifies
- * our clients that the neighbour is now officially gone.
+ * Check the ready list for the given neighbour and
+ * if a plugin is ready for transmission (and if we
+ * have a message), do so!
*
- * @param n the neighbour list entry for the peer
+ * @param neighbour target peer for which to check the plugins
*/
-static void
-disconnect_neighbour (struct NeighbourList *n);
+static void
+try_transmission_to_peer (struct NeighbourList *neighbour);
/**
"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;
another message (if available) */
if (result == GNUNET_OK)
try_transmission_to_peer (n);
- else
- disconnect_neighbour (n);
+ else
+ disconnect_neighbour (n, GNUNET_YES);
}
/**
- * The peer specified by the given neighbour has timed-out. Update
- * our state and do the necessary notifications. Also notifies
- * our clients that the neighbour is now officially gone.
+ * The peer specified by the given neighbour has timed-out or a plugin
+ * has disconnected. We may either need to do nothing (other plugins
+ * still up), or trigger a full disconnect and clean up. This
+ * function updates our state and do the necessary notifications.
+ * Also notifies our clients that the neighbour is now officially
+ * gone.
*
* @param n the neighbour list entry for the peer
+ * @param check should we just check if all plugins
+ * disconnected or must we ask all plugins to
+ * disconnect?
*/
static void
-disconnect_neighbour (struct NeighbourList *n)
+disconnect_neighbour (struct NeighbourList *n,
+ int check)
{
struct ReadyList *rpos;
struct NeighbourList *npos;
struct NeighbourList *nprev;
struct MessageQueue *mq;
+
+ if (GNUNET_YES == check)
+ {
+ rpos = n->plugins;
+ while (NULL != rpos)
+ {
+ if (GNUNET_YES == rpos->connected)
+ return; /* still connected */
+ rpos = rpos->next;
+ }
+ }
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
GNUNET_i2s(&n->id));
#endif
n->timeout_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK;
- disconnect_neighbour (n);
+ disconnect_neighbour (n, GNUNET_NO);
}
service_context->connected = GNUNET_NO;
service_context->plugin_handle = NULL;
}
- disconnect_neighbour (n);
+ disconnect_neighbour (n, GNUNET_YES);
return NULL;
}
#if DEBUG_TRANSPORT
struct GNUNET_PeerIdentity peer;
char *sender_addr;
size_t addrlen;
+ const struct sockaddr *addr;
+ struct sockaddr_in v4;
+ struct sockaddr_in6 v6;
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
GNUNET_CRYPTO_hash (&vcr->signer,
sizeof( struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
&peer.hashPubKey);
- sender_addr = GNUNET_strdup (GNUNET_a2s((const struct sockaddr*) &vcr[1],
- addrlen));
+ addr = (const struct sockaddr*) &vcr[1];
+ if (addrlen == sizeof (struct sockaddr_in))
+ {
+ memcpy (&v4, addr, sizeof (struct sockaddr_in));
+ v4.sin_port = htons(check_port (plugin, ntohs (v4.sin_port)));
+ sender_addr = GNUNET_strdup (GNUNET_a2s((const struct sockaddr*) &v4,
+ addrlen));
+ }
+ else if (addrlen == sizeof (struct sockaddr_in6))
+ {
+ memcpy (&v6, addr, sizeof (struct sockaddr_in6));
+ v6.sin6_port = htons(check_port (plugin, ntohs (v6.sin6_port)));
+ sender_addr = GNUNET_strdup (GNUNET_a2s((const struct sockaddr*) &v6,
+ addrlen));
+ }
+ else
+ {
+ GNUNET_break_op (0);
+ GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+ return;
+ }
plugin->env->notify_validation (plugin->env->cls,
"tcp",
&peer,
#include "gnunet_transport_service.h"
#include "transport.h"
-#define VERBOSE GNUNET_YES
+#define VERBOSE GNUNET_NO
#define START_ARM GNUNET_YES
#include "gnunet_time_lib.h"
#include "gnunet_transport_service.h"
-#define DEBUG_TRANSPORT GNUNET_YES
+#define DEBUG_TRANSPORT GNUNET_NO
/**
* For how long do we allow unused bandwidth