[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r8362 - GNUnet/src/applications/dv/module
From: |
gnunet |
Subject: |
[GNUnet-SVN] r8362 - GNUnet/src/applications/dv/module |
Date: |
Tue, 31 Mar 2009 14:33:26 -0600 |
Author: nevans
Date: 2009-03-31 14:33:26 -0600 (Tue, 31 Mar 2009)
New Revision: 8362
Modified:
GNUnet/src/applications/dv/module/Makefile.am
GNUnet/src/applications/dv/module/dv.c
GNUnet/src/applications/dv/module/dvtest.c
GNUnet/src/applications/dv/module/gnunetd_dv.conf
Log:
service cleanup
Modified: GNUnet/src/applications/dv/module/Makefile.am
===================================================================
--- GNUnet/src/applications/dv/module/Makefile.am 2009-03-31 19:33:41 UTC
(rev 8361)
+++ GNUnet/src/applications/dv/module/Makefile.am 2009-03-31 20:33:26 UTC
(rev 8362)
@@ -19,8 +19,7 @@
libgnunetmodule_dv_tbench.la
libgnunetmodule_dv_la_SOURCES = \
- dv.c heap.c \
- service.c
+ dv.c heap.c
libgnunetmodule_dv_la_LDFLAGS = \
$(GN_PLUGIN_LDFLAGS)
libgnunetmodule_dv_la_LIBADD = \
Modified: GNUnet/src/applications/dv/module/dv.c
===================================================================
--- GNUnet/src/applications/dv/module/dv.c 2009-03-31 19:33:41 UTC (rev
8361)
+++ GNUnet/src/applications/dv/module/dv.c 2009-03-31 20:33:26 UTC (rev
8362)
@@ -29,7 +29,7 @@
#include "gnunet_protocols.h"
#include "gnunet_util.h"
#include "gnunet_core.h"
-#include "gnunet_dv_lib.h"
+#include "gnunet_dv_service.h"
#include "dv.h"
#include "heap.h"
@@ -103,6 +103,28 @@
}
/*
+ * Deletes a neighbor from the max and min heaps and
+ * from the extended neighbor hash map. Does not delete
+ * from the directly connected neighbor list, because
+ * we like to keep those around.
+ */
+static int
+delete_neighbor(struct GNUNET_dv_neighbor *neighbor)
+{
+ 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_free (neighbor->neighbor);
+ if (neighbor->referrer != NULL)
+ GNUNET_free (neighbor->referrer);
+ GNUNET_free (neighbor);
+
+ return GNUNET_OK;
+}
+
+/*
* Prints out the known neighbor routing tables.
*/
static void
@@ -163,21 +185,12 @@
"%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_free (neighbor->neighbor);
- if (neighbor->referrer != NULL)
- GNUNET_free (neighbor->referrer);
- GNUNET_free (neighbor);
+ delete_neighbor(neighbor);
}
return GNUNET_OK;
}
-
/**
* Cron job to maintain dv routing table.
*/
@@ -536,15 +549,7 @@
(neighbor->referrer, referrer,
sizeof (GNUNET_PeerIdentity)) == 0)))
{
- GNUNET_DV_Heap_removeNode (&ctx->neighbor_max_heap, neighbor);
- GNUNET_DV_Heap_removeNode (&ctx->neighbor_min_heap, neighbor);
-
- GNUNET_free (neighbor->neighbor);
- if (neighbor->referrer != NULL)
- GNUNET_free (neighbor->referrer);
- GNUNET_free (neighbor);
- GNUNET_multi_hash_map_remove_all (ctx->extended_neighbors,
- &peer->hashPubKey);
+ delete_neighbor(neighbor);
}
}
ret = GNUNET_NO;
@@ -595,16 +600,7 @@
}
else if (neighbor->cost > cost)
{
- GNUNET_DV_Heap_removeNode (&ctx->neighbor_max_heap, neighbor);
- GNUNET_DV_Heap_removeNode (&ctx->neighbor_min_heap, neighbor);
-
- GNUNET_free (neighbor->neighbor);
- if (neighbor->referrer != NULL)
- GNUNET_free (neighbor->referrer);
- GNUNET_free (neighbor);
- GNUNET_multi_hash_map_remove_all (ctx->extended_neighbors,
- &peer->hashPubKey);
-
+ delete_neighbor(neighbor);
neighbor = GNUNET_malloc (sizeof (struct GNUNET_dv_neighbor));
neighbor->cost = cost;
neighbor->last_activity = now;
@@ -734,9 +730,6 @@
{
neighbor->last_activity = GNUNET_get_time();
neighbor->cost = cost;
- /*GNUNET_multi_hash_map_put (ctx->direct_neighbors,
&peer->hashPubKey,
- neighbor,
- GNUNET_MultiHashMapOption_REPLACE); */
}
}
@@ -792,15 +785,7 @@
(GNUNET_PeerIdentity)) ==
0)))
{
- 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_free (neighbor->neighbor);
- if (neighbor->referrer != NULL)
- GNUNET_free (neighbor->referrer);
- GNUNET_free (neighbor);
+ delete_neighbor(neighbor);
}
return GNUNET_OK;
}
@@ -849,7 +834,8 @@
GNUNET_DV_Heap_Iterator (&ctx->neighbor_max_heap,
ctx->neighbor_max_heap.root,
&delete_callback, (void *) peer);
-
+ /* Note that we do not use delete_neighbor here because
+ * we are deleting from the direct neighbor list! */
GNUNET_free (neighbor->neighbor);
if (neighbor->referrer != NULL)
GNUNET_free (neighbor->referrer);
@@ -972,15 +958,21 @@
}
/*
- * Initializes the DV module
+ * Initializes and provides the fisheye DV service
+ *
+ * @param capi the core API
+ * @return NULL on errors, DV_API otherwise
*/
-int
-initialize_module_dv (GNUNET_CoreAPIForPlugins * capi)
+GNUNET_DV_ServiceAPI *
+provide_module_dv (GNUNET_CoreAPIForPlugins * capi)
{
int ok = GNUNET_OK;
unsigned long long max_hosts;
GNUNET_EncName encMe;
+ static GNUNET_DV_ServiceAPI api;
+ api.dv_send = &GNUNET_DV_send_message;
+ api.dv_connections_iterate = &GNUNET_DV_connection_iterate_peers;
ctx = GNUNET_malloc (sizeof (struct GNUNET_DV_Context));
ctx->neighbor_min_heap.type = GNUNET_DV_MIN_HEAP;
@@ -1065,14 +1057,14 @@
GNUNET_cron_add_job (coreAPI->cron, &maintain_dv_job,
GNUNET_DV_MAINTAIN_FREQUENCY,
GNUNET_DV_MAINTAIN_FREQUENCY, NULL);
- return ok;
+ return &api;
}
/*
* Shuts down and cleans up the DV module
*/
void
-done_module_dv ()
+release_module_dv ()
{
void *unused;
ctx->closing = 1;
Modified: GNUnet/src/applications/dv/module/dvtest.c
===================================================================
--- GNUnet/src/applications/dv/module/dvtest.c 2009-03-31 19:33:41 UTC (rev
8361)
+++ GNUnet/src/applications/dv/module/dvtest.c 2009-03-31 20:33:26 UTC (rev
8362)
@@ -185,8 +185,8 @@
sock = GNUNET_client_connection_create (NULL, peers->config);
/* 'slow' pass: wait for bandwidth negotiation! */
- printf (_("Sleeping 55 seconds to let topology stabilize...\n"));
- sleep (55);
+ printf (_("Sleeping 15 seconds to let topology stabilize...\n"));
+ sleep (15);
printf (_("Running benchmark...\n"));
printf (_("Sending from %s to %s...\n"), (char *) &peer1enc,
(char *) &peer2enc);
Modified: GNUnet/src/applications/dv/module/gnunetd_dv.conf
===================================================================
--- GNUnet/src/applications/dv/module/gnunetd_dv.conf 2009-03-31 19:33:41 UTC
(rev 8361)
+++ GNUnet/src/applications/dv/module/gnunetd_dv.conf 2009-03-31 20:33:26 UTC
(rev 8362)
@@ -6,7 +6,7 @@
GNUNETD_HOME =
[GNUNETD]
-APPLICATIONS = advertising getoption stats tracekit dv_tbench dv
+APPLICATIONS = advertising getoption stats tracekit dv_tbench
TRANSPORTS = udp tcp nat
HOSTS = $GNUNETD_HOME/data/hosts/
HTTP-PROXY =
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r8362 - GNUnet/src/applications/dv/module,
gnunet <=