[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r8813 - GNUnet/src/applications/dv/module
From: |
gnunet |
Subject: |
[GNUnet-SVN] r8813 - GNUnet/src/applications/dv/module |
Date: |
Thu, 30 Jul 2009 12:49:09 -0600 |
Author: nevans
Date: 2009-07-30 12:49:09 -0600 (Thu, 30 Jul 2009)
New Revision: 8813
Modified:
GNUnet/src/applications/dv/module/dv.c
Log:
locks and logic modifications
Modified: GNUnet/src/applications/dv/module/dv.c
===================================================================
--- GNUnet/src/applications/dv/module/dv.c 2009-07-30 15:56:48 UTC (rev
8812)
+++ GNUnet/src/applications/dv/module/dv.c 2009-07-30 18:49:09 UTC (rev
8813)
@@ -51,6 +51,7 @@
static int stat_dv_failed_forwards;
static int stat_dv_sent_gossips;
static int stat_dv_received_gossips;
+static int stat_dv_unknown_peer;
/*
* Global construct
@@ -211,6 +212,11 @@
now = GNUNET_get_time ();
struct GNUNET_dv_neighbor *neighbor;
neighbor = (struct GNUNET_dv_neighbor *) element;
+ /*
+ * Why do we check if it is a direct neighbor? delete_neighbor
+ * only deletes from the extended list anyways...
+ */
+ GNUNET_mutex_lock (ctx->dvMutex);
if ((GNUNET_NO ==
GNUNET_multi_hash_map_contains (ctx->direct_neighbors,
&neighbor->neighbor->hashPubKey))
@@ -229,7 +235,7 @@
#endif
delete_neighbor (neighbor);
}
-
+ GNUNET_mutex_unlock (ctx->dvMutex);
return GNUNET_OK;
}
@@ -282,6 +288,7 @@
p2p_dv_MESSAGE_Data *toSend;
unsigned int msg_size;
unsigned int cost;
+ int ret;
struct GNUNET_dv_neighbor *neighbor;
#if DEBUG_DV_FORWARD
GNUNET_EncName encVia;
@@ -292,6 +299,7 @@
GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
GNUNET_GE_BULK, "%s: Entered send_message!\n", &shortID);
#endif
+ GNUNET_mutex_lock (ctx->dvMutex);
if (GNUNET_YES ==
GNUNET_multi_hash_map_contains (ctx->extended_neighbors,
&recipient->hashPubKey))
@@ -346,7 +354,7 @@
importance, maxdelay);
}
GNUNET_free (toSend);
- return (int) cost;
+ ret = (int) cost;
}
else
{
@@ -359,8 +367,13 @@
"%s: I AM:\n%s\nAsked to send message to unknown
peer:\n%s\n\n",
&shortID, (char *) &encMe, (char *) &encRecipient);
#endif
- return GNUNET_SYSERR;
+ if (stats != NULL)
+ stats->change (stat_dv_unknown_peer, 1);
+
+ ret = GNUNET_SYSERR;
}
+ GNUNET_mutex_unlock (ctx->dvMutex);
+ return ret;
}
/*
@@ -621,9 +634,12 @@
{
ret = GNUNET_NO;
- if (GNUNET_YES ==
- GNUNET_multi_hash_map_contains (ctx->extended_neighbors,
- &peer->hashPubKey))
+ if ((GNUNET_YES ==
+ GNUNET_multi_hash_map_contains (ctx->extended_neighbors,
+ &peer->hashPubKey))
+ && (GNUNET_NO ==
+ GNUNET_multi_hash_map_contains (ctx->direct_neighbors,
+ &peer->hashPubKey)))
{
neighbor =
GNUNET_multi_hash_map_get (ctx->extended_neighbors,
@@ -731,7 +747,6 @@
}
}
-
#if DEBUG_DV
print_tables ();
GNUNET_GE_LOG (coreAPI->ectx,
@@ -1099,6 +1114,8 @@
stats->create (gettext_noop ("# dv gossips received"));
stat_dv_sent_gossips =
stats->create (gettext_noop ("# dv gossips sent"));
+ stat_dv_unknown_peer =
+ stats->create (gettext_noop ("# dv messages to unknown peers"));
}
ctx = GNUNET_malloc (sizeof (struct GNUNET_DV_Context));
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r8813 - GNUnet/src/applications/dv/module,
gnunet <=