gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r8816 - GNUnet/src/applications/dv/module


From: gnunet
Subject: [GNUnet-SVN] r8816 - GNUnet/src/applications/dv/module
Date: Thu, 30 Jul 2009 14:29:55 -0600

Author: nevans
Date: 2009-07-30 14:29:55 -0600 (Thu, 30 Jul 2009)
New Revision: 8816

Modified:
   GNUnet/src/applications/dv/module/dv.c
Log:


Modified: GNUnet/src/applications/dv/module/dv.c
===================================================================
--- GNUnet/src/applications/dv/module/dv.c      2009-07-30 20:15:47 UTC (rev 
8815)
+++ GNUnet/src/applications/dv/module/dv.c      2009-07-30 20:29:55 UTC (rev 
8816)
@@ -159,38 +159,15 @@
   return GNUNET_OK;
 }
 
-#if DEBUG_DV
 /*
- * Prints out the known neighbor routing tables.
- */
-static void
-print_tables ()
-{
-  GNUNET_GE_LOG (coreAPI->ectx,
-                 GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
-                 GNUNET_GE_BULK,
-                 "%s: Printing directly connected neighbors:\n", &shortID);
-  GNUNET_multi_hash_map_iterate (ctx->direct_neighbors, &printTableEntry,
-                                 "DIRECT");
-
-  GNUNET_GE_LOG (coreAPI->ectx,
-                 GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
-                 GNUNET_GE_BULK, "%s: Printing extended neighbors:\n",
-                 &shortID);
-  GNUNET_multi_hash_map_iterate (ctx->extended_neighbors, &printTableEntry,
-                                 "EXTENDED");
-  return;
-}
-#endif
-
-/*
  * A callback for iterating over all known nodes.
  */
 static int
-connection_iterate_callback (const GNUNET_HashCode * key, void *value,
-                             void *cls)
+connection_iterate_callback (void *element, GNUNET_CostType cost,
+                         struct GNUNET_CONTAINER_Heap *root, void *cls)
 {
-  struct GNUNET_dv_neighbor *neighbor = (struct GNUNET_dv_neighbor *) value;
+  struct GNUNET_dv_neighbor *neighbor;
+  neighbor = (struct GNUNET_dv_neighbor *) element;
   struct callbackWrapper *wrap = (struct callbackWrapper *) cls;
   wrap->method (neighbor->neighbor, wrap->arg);
   return GNUNET_OK;
@@ -245,11 +222,8 @@
 static void
 maintain_dv_job (void *unused)
 {
-  GNUNET_mutex_lock (ctx->dvMutex);
   GNUNET_CONTAINER_heap_iterate (ctx->neighbor_max_heap,
                                  &delete_expired_callback, NULL);
-
-  GNUNET_mutex_unlock (ctx->dvMutex);
 }
 
 /**
@@ -269,9 +243,10 @@
   wrap.arg = arg;
 
   GNUNET_mutex_lock (ctx->dvMutex);
-  ret =
+  /*ret =
     GNUNET_multi_hash_map_iterate (ctx->extended_neighbors,
-                                   &connection_iterate_callback, &wrap);
+                                   &connection_iterate_callback, &wrap);*/
+  ret = GNUNET_CONTAINER_heap_iterate (ctx->neighbor_max_heap, 
&connection_iterate_callback, &wrap);
   GNUNET_mutex_unlock (ctx->dvMutex);
   return ret;
 }
@@ -748,7 +723,6 @@
     }
 
 #if DEBUG_DV
-  print_tables ();
   GNUNET_GE_LOG (coreAPI->ectx,
                  GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
                  GNUNET_GE_BULK, "%s: Exiting addUpdateNeighbor\n", &shortID);
@@ -817,9 +791,6 @@
                  GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
                  GNUNET_GE_BULK, "%s: Entering peer_connect_handler:\n",
                  &shortID);
-  GNUNET_mutex_lock (ctx->dvMutex);
-  print_tables ();
-  GNUNET_mutex_unlock (ctx->dvMutex);
 
 #endif
   struct GNUNET_dv_neighbor *neighbor;
@@ -853,11 +824,6 @@
   GNUNET_mutex_unlock (ctx->dvMutex);
   addUpdateNeighbor (peer, NULL, cost);
 
-#if DEBUG_DV
-  GNUNET_mutex_lock (ctx->dvMutex);
-  print_tables ();
-  GNUNET_mutex_unlock (ctx->dvMutex);
-#endif
   return;
 
 }
@@ -932,9 +898,6 @@
                  GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
                  GNUNET_GE_BULK, "%s: disconnected peer: %s\n", &shortID,
                  (char *) &myself);
-  GNUNET_mutex_lock (ctx->dvMutex);
-  print_tables ();
-  GNUNET_mutex_unlock (ctx->dvMutex);
 #endif
 
   GNUNET_mutex_lock (ctx->dvMutex);
@@ -959,15 +922,10 @@
             GNUNET_free (neighbor->referrer);
 
           GNUNET_free (neighbor);
-
         }
     }
-
   GNUNET_mutex_unlock (ctx->dvMutex);
 #if DEBUG_DV
-  GNUNET_mutex_lock (ctx->dvMutex);
-  print_tables ();
-  GNUNET_mutex_unlock (ctx->dvMutex);
   GNUNET_GE_LOG (coreAPI->ectx,
                  GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
                  GNUNET_GE_BULK, "%s: Exiting peer_disconnect_handler\n",
@@ -1045,6 +1003,7 @@
        * TODO: Once we have more information about how to
        * control the sending interval change this.
        */
+      GNUNET_mutex_lock(ctx->dvMutex);
       about = chooseAboutNeighbor ();
       to = chooseToNeighbor ();
 
@@ -1072,6 +1031,7 @@
           if (stats != NULL)
             stats->change (stat_dv_sent_gossips, 1);
         }
+      GNUNET_mutex_unlock(ctx->dvMutex);
       GNUNET_thread_sleep (ctx->send_interval * GNUNET_CRON_MILLISECONDS);
     }
 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]