[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r8361 - GNUnet/src/applications/dv/module
From: |
gnunet |
Subject: |
[GNUnet-SVN] r8361 - GNUnet/src/applications/dv/module |
Date: |
Tue, 31 Mar 2009 13:33:41 -0600 |
Author: nevans
Date: 2009-03-31 13:33:41 -0600 (Tue, 31 Mar 2009)
New Revision: 8361
Modified:
GNUnet/src/applications/dv/module/dv.c
Log:
bugfix
Modified: GNUnet/src/applications/dv/module/dv.c
===================================================================
--- GNUnet/src/applications/dv/module/dv.c 2009-03-31 16:49:45 UTC (rev
8360)
+++ GNUnet/src/applications/dv/module/dv.c 2009-03-31 19:33:41 UTC (rev
8361)
@@ -33,6 +33,7 @@
#include "dv.h"
#include "heap.h"
+#define DEBUG_DV_MAINTAIN GNUNET_YES
#define DEBUG_DV GNUNET_NO
#define DEBUG_DV_FORWARD GNUNET_NO
/* How long to allow a message to be delayed */
@@ -70,9 +71,10 @@
static struct GNUNET_ThreadHandle *sendingThread;
static GNUNET_CoreAPIForPlugins *coreAPI;
-// CG: unless defined in a header and used by
-// other C source files (or used with dlsym),'
-// make sure all of your functions are declared "static"
+/*
+ * Callback for printing a single entry in one of the
+ * DV routing tables
+ */
static int
printTableEntry (const GNUNET_HashCode * key, void *value, void *cls)
{
@@ -100,6 +102,9 @@
return GNUNET_OK;
}
+/*
+ * Prints out the known neighbor routing tables.
+ */
static void
print_tables ()
{
@@ -145,17 +150,23 @@
struct GNUNET_dv_heap *root, void *cls)
{
GNUNET_CronTime now;
-
now = GNUNET_get_time();
- if (now - neighbor->last_activity > GNUNET_DV_PEER_EXPIRATION_TIME)
+ if ((GNUNET_NO == GNUNET_multi_hash_map_contains(ctx->direct_neighbors,
&neighbor->neighbor->hashPubKey)) && (now - neighbor->last_activity >
GNUNET_DV_PEER_EXPIRATION_TIME))
{
+#if DEBUG_DV_MAINTAIN
+ GNUNET_EncName encToDel;
+ GNUNET_hash_to_enc (&neighbor->neighbor->hashPubKey, &encToDel);
+ GNUNET_GE_LOG (coreAPI->ectx,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+ GNUNET_GE_BULK,
+ "%s: Entering delete_expired_callback, now is %llu,
last_activity is %llu\nDifference is %llu, Max is %llu\nNode to remove is %s\n",
+ &shortID, now, neighbor->last_activity,now -
neighbor->last_activity, GNUNET_DV_PEER_EXPIRATION_TIME, (char *)&encToDel);
+#endif
GNUNET_DV_Heap_removeNode (&ctx->neighbor_max_heap, neighbor);
GNUNET_DV_Heap_removeNode (&ctx->neighbor_min_heap, neighbor);
GNUNET_multi_hash_map_remove_all (ctx->extended_neighbors,
&neighbor->neighbor->hashPubKey);
- GNUNET_multi_hash_map_remove_all (ctx->direct_neighbors,
- &neighbor->neighbor->hashPubKey);
GNUNET_free (neighbor->neighbor);
if (neighbor->referrer != NULL)
@@ -178,7 +189,7 @@
ctx->neighbor_max_heap.root,
&delete_expired_callback, NULL);
- GNUNET_mutex_lock (ctx->dvMutex);
+ GNUNET_mutex_unlock (ctx->dvMutex);
}
/**
@@ -205,6 +216,9 @@
return ret;
}
+/*
+ * Low level sending of a DV message
+ */
static int
send_message (const GNUNET_PeerIdentity * recipient,
const GNUNET_PeerIdentity * original_sender,
@@ -297,7 +311,8 @@
/*
* Forward a received message that was not intended
- * for us.
+ * for us. Does not verify that destination peer
+ * is known to us.
*
* @recipient for which peer is this message intended
* @message message being forwarded
@@ -329,9 +344,9 @@
}
/*
- * Handle a message receipt, if recipient matches ident message is
- * for this peer, otherwise check if we know of the intended
- * recipient and send onwards
+ * Handle a DATA message receipt, if recipient matches our identity
+ * message is for this peer, otherwise check if we know of the
+ * intended recipient and send onwards
*/
static int
p2pHandleDVDataMessage (const GNUNET_PeerIdentity * sender,
@@ -391,7 +406,6 @@
(coreAPI->my_identity, &incoming->recipient,
sizeof (GNUNET_PeerIdentity)) == 0)
{
- /*FIXME: Deliver message up to ??? Handle arbitrary messages? */
#if DEBUG_DV_FORWARD
GNUNET_hash_to_enc (&coreAPI->my_identity->hashPubKey, &encMe);
@@ -614,6 +628,10 @@
GNUNET_DV_Heap_insert (&ctx->neighbor_max_heap, neighbor);
GNUNET_DV_Heap_insert (&ctx->neighbor_min_heap, neighbor);
}
+ else if(neighbor->cost == cost)
+ {
+ neighbor->last_activity = now;
+ }
}
@@ -628,6 +646,11 @@
return ret;
}
+/*
+ * Handles a gossip message from another peer. Basically
+ * just check the message size, cast to the correct type
+ * and call addUpdateNeighbor to do the real work.
+ */
static int
p2pHandleDVNeighborMessage (const GNUNET_PeerIdentity * sender,
const GNUNET_MessageHeader * message)
@@ -667,7 +690,9 @@
}
/*
- * Handles a peer connect notification, eliminates any need for polling.
+ * Handles a peer connect notification, indicating a peer should
+ * be added to the direct neighbor table.
+ *
* @param peer - ident of the connected peer
* @param unused - unused closure arg
*/
@@ -847,6 +872,10 @@
return;
}
+/*
+ * Chooses a neighbor at random to gossip peer information
+ * to
+ */
static struct GNUNET_dv_neighbor *
chooseToNeighbor ()
{
@@ -857,6 +886,10 @@
GNUNET_multi_hash_map_get_random (ctx->direct_neighbors);
}
+/*
+ * Chooses a neighbor to send information about
+ * by walking through the neighbor heap
+ */
static struct GNUNET_dv_neighbor *
chooseAboutNeighbor ()
{
@@ -875,6 +908,12 @@
}
+/*
+ * Thread which chooses a peer to gossip about and
+ * a peer to gossip to, then constructs the message
+ * and sends it out. Will run until done_module_dv
+ * is called.
+ */
static void *
neighbor_send_thread (void *rcls)
{
@@ -897,7 +936,10 @@
while (!ctx->closing)
{
- //updateSendInterval();
+ /*updateSendInterval();
+ * TODO: Once we have more information about how to
+ * control the sending interval change this.
+ */
about = chooseAboutNeighbor ();
to = chooseToNeighbor ();
@@ -929,6 +971,9 @@
return NULL;
}
+/*
+ * Initializes the DV module
+ */
int
initialize_module_dv (GNUNET_CoreAPIForPlugins * capi)
{
@@ -1023,6 +1068,9 @@
return ok;
}
+/*
+ * Shuts down and cleans up the DV module
+ */
void
done_module_dv ()
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r8361 - GNUnet/src/applications/dv/module,
gnunet <=