gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r9774 - GNUnet/src/applications/dv/module
Date: Wed, 16 Dec 2009 03:13:28 +0100

Author: nevans
Date: 2009-12-16 03:13:28 +0100 (Wed, 16 Dec 2009)
New Revision: 9774

Modified:
   GNUnet/src/applications/dv/module/dv.c
   GNUnet/src/applications/dv/module/dv_heaptest.c
   GNUnet/src/applications/dv/module/dvtest.c
Log:
fixes for fixes

Modified: GNUnet/src/applications/dv/module/dv.c
===================================================================
--- GNUnet/src/applications/dv/module/dv.c      2009-12-15 20:45:08 UTC (rev 
9773)
+++ GNUnet/src/applications/dv/module/dv.c      2009-12-16 02:13:28 UTC (rev 
9774)
@@ -104,6 +104,7 @@
   GNUNET_GE_LOG (coreAPI->ectx,
                  GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
                  GNUNET_GE_BULK, "\tPeer: %s", (char *) &enc);
+  return 1;
 }
 #endif
 
@@ -115,8 +116,8 @@
 {
   if (stats == NULL)
     return;
-  stats->set (stat_dv_total_peers, 
-             GNUNET_multi_hash_map_size (ctx->extended_neighbors));          
+  stats->set (stat_dv_total_peers,
+             GNUNET_multi_hash_map_size (ctx->extended_neighbors));
 #if DEBUG_PEERS
   GNUNET_GE_LOG (coreAPI->ectx,
                  GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
@@ -264,10 +265,6 @@
 #endif
 
   if (GNUNET_YES ==
-      GNUNET_multi_hash_map_contains (ctx->direct_neighbors,
-                                      &peer->hashPubKey))    
-    return 0;    
-  if (GNUNET_YES ==
       GNUNET_multi_hash_map_contains (ctx->extended_neighbors,
                                      &peer->hashPubKey))
     {
@@ -277,13 +274,13 @@
       return neighbor->neighbor_id;
     }
 #if DEBUG_DV_FORWARD
-  GNUNET_hash_to_enc (&coreAPI->my_identity->hashPubKey, &encMe);
-  GNUNET_hash_to_enc (&peer->hashPubKey, &enc);
-  GNUNET_GE_LOG (coreAPI->ectx,
-                GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
-                GNUNET_GE_BULK,
-                "%s: I AM:\n%s\nAsked to send message to unknown 
peer:\n%s\n\n",
-                &shortID, (char *) &encMe, (char *) &enc);
+      GNUNET_hash_to_enc (&coreAPI->my_identity->hashPubKey, &encMe);
+      GNUNET_hash_to_enc (&peer->hashPubKey, &enc);
+      GNUNET_GE_LOG (coreAPI->ectx,
+                     GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+                     GNUNET_GE_BULK,
+                     "%s: I AM:\n%s\nCould not find peer:\n%s\n\n",
+                     &shortID, (char *) &encMe, (char *) &enc);
 #endif
   if (stats != NULL)
     stats->change (stat_dv_unknown_peer, 1);
@@ -310,7 +307,6 @@
   GNUNET_EncName encVia;
   GNUNET_EncName encRecipient;
   GNUNET_EncName encMe;
-  GNUNET_EncName encSender;
 
   GNUNET_GE_LOG (coreAPI->ectx,
                  GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
@@ -321,15 +317,68 @@
     return GNUNET_SYSERR;
   GNUNET_mutex_lock (ctx->dvMutex);
 
-  recipient_id = get_peer_id (recipient);
-  original_sender_id = get_peer_id (original_sender);
+  if (GNUNET_YES ==
+        GNUNET_multi_hash_map_contains (ctx->direct_neighbors,
+                                        &recipient->hashPubKey))
+  {
+    recipient_id = 0;
+  }
+  else
+  {
+    recipient_id = get_peer_id (recipient);
+  }
+
+  if (memcmp
+      (&coreAPI->my_identity->hashPubKey, &original_sender->hashPubKey,
+       sizeof (GNUNET_HashCode)) == 0)
+    {
+#if DEBUG_DV_FORWARD
+    GNUNET_GE_LOG (coreAPI->ectx,
+                     GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+                     GNUNET_GE_BULK, "%s: In send_message, origin and me are 
the same!\n", &shortID);
+#endif
+      original_sender_id = 0;
+    }
+  else
+    {
+      original_sender_id = get_peer_id (original_sender);
+    }
+
   if ( (GNUNET_SYSERR == recipient_id) ||
        (GNUNET_SYSERR == original_sender_id) )
     {
       GNUNET_mutex_unlock (ctx->dvMutex);
+      if (original_sender_id == GNUNET_SYSERR)
+      {
+#if DEBUG_DV_FORWARD
+  GNUNET_GE_LOG (coreAPI->ectx,
+     GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+     GNUNET_GE_BULK,
+     "%s: Original sender unknown\n",
+     &shortID);
+#endif
+      }
+      else if (recipient_id == GNUNET_SYSERR)
+      {
+#if DEBUG_DV_FORWARD
+  GNUNET_GE_LOG (coreAPI->ectx,
+     GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+     GNUNET_GE_BULK,
+     "%s: Recipient unknown\n",
+     &shortID);
+#endif
+      }
       return GNUNET_SYSERR;
     }
 
+#if DEBUG_DV_FORWARD
+  GNUNET_GE_LOG (coreAPI->ectx,
+     GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+     GNUNET_GE_BULK,
+     "%s: In send message, sender id is %d, recipient id is %d\n",
+     &shortID, original_sender_id, recipient_id);
+#endif
+
   neighbor =
     GNUNET_multi_hash_map_get (ctx->extended_neighbors,
                               &recipient->hashPubKey);
@@ -367,11 +416,11 @@
                     &shortID, (char *) &encMe, (char *) &encRecipient);
     }
 #endif
-  coreAPI->ciphertext_send ((neighbor->referrer != NULL) 
-                           ? neighbor->referrer 
+  coreAPI->ciphertext_send ((neighbor->referrer != NULL)
+                           ? neighbor->referrer
                            : neighbor->neighbor,
                            &toSend->header,
-                           importance, 
+                           importance,
                            maxdelay);
   if (stats != NULL)
     stats->change (stat_dv_actual_sent_messages, 1);
@@ -436,7 +485,7 @@
 
 #if DEBUG_DV_FORWARD
   GNUNET_hash_to_enc (&coreAPI->my_identity->hashPubKey, &encMe);
-  GNUNET_hash_to_enc (&recipient->hashPubKey, &encRecipient);
+  GNUNET_hash_to_enc (&recipient.hashPubKey, &encRecipient);
   GNUNET_hash_to_enc (&sender->hashPubKey, &encOrigin);
 
   GNUNET_GE_LOG (coreAPI->ectx,
@@ -446,7 +495,7 @@
                  &shortID, (char *) &encRecipient, (char *) &encMe,
                  (char *) &encOrigin);
 #endif
-  return send_message (&recipient, 
+  return send_message (&recipient,
                       sender,
                       packed_message, DV_PRIORITY, DV_DELAY);
 }
@@ -468,7 +517,7 @@
 #endif
   const p2p_dv_MESSAGE_Data *incoming
     = (const p2p_dv_MESSAGE_Data *) message;
-  const GNUNET_MessageHeader *packed_message 
+  const GNUNET_MessageHeader *packed_message
     = (const GNUNET_MessageHeader *) & incoming[1];
   GNUNET_PeerIdentity original_sender;
   int ret;
@@ -511,7 +560,7 @@
       return GNUNET_SYSERR;
     }
 
-#if DEBUG_DV 
+#if DEBUG_DV
   message_length =
     ntohs (incoming->header.size) - sizeof (p2p_dv_MESSAGE_Data);
   GNUNET_GE_LOG (coreAPI->ectx,
@@ -538,46 +587,46 @@
             {
               memcpy (&original_sender, &ctx->neighbor_id_array[i].identity,
                       sizeof (GNUNET_PeerIdentity));
-             ret = GNUNET_OK;
+              ret = GNUNET_OK;
               break;
             }
         }
       if (ret == GNUNET_SYSERR)
-       {
-         GNUNET_mutex_unlock (ctx->dvMutex);
-#if DEBUG_DV_FORWARD
-         GNUNET_hash_to_enc (&coreAPI->my_identity->hashPubKey, &encMe);
-         GNUNET_hash_to_enc (&sender->hashPubKey, &encSender);  
-         GNUNET_GE_LOG (coreAPI->ectx,
-                        GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
-                        GNUNET_GE_BULK,
-                        "%s: Received message:\nI am:\n%s\nImmediate 
sender:\n%s\nOriginal Sender UNKNOWN\n",
-                        &shortID, (char *) &encMe, (char *) &encSender);
-         
-#endif   
-         if (stats != NULL)
-           stats->change (stat_dv_unknown_peer, 1);
-         return GNUNET_SYSERR;
-       }
+      {
+        GNUNET_mutex_unlock (ctx->dvMutex);
+    #if DEBUG_DV_FORWARD
+        GNUNET_hash_to_enc (&coreAPI->my_identity->hashPubKey, &encMe);
+        GNUNET_hash_to_enc (&sender->hashPubKey, &encSender);
+        GNUNET_GE_LOG (coreAPI->ectx,
+           GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+           GNUNET_GE_BULK,
+           "%s: Received message:\nI am:\n%s\nImmediate sender:\n%s\nOriginal 
Sender UNKNOWN\n",
+           &shortID, (char *) &encMe, (char *) &encSender);
+
+    #endif
+        if (stats != NULL)
+          stats->change (stat_dv_unknown_peer, 1);
+        return GNUNET_SYSERR;
+      }
     }
   GNUNET_mutex_unlock (ctx->dvMutex);
 
   if (ntohl (incoming->recipient) == 0)
     {
-      coreAPI->loopback_send (&original_sender, 
+      coreAPI->loopback_send (&original_sender,
                              (const char *) packed_message,
                              ntohs (packed_message->size), GNUNET_YES,
                              NULL);
 #if DEBUG_DV_FORWARD
       GNUNET_hash_to_enc (&coreAPI->my_identity->hashPubKey, &encMe);
       GNUNET_hash_to_enc (&sender->hashPubKey, &encSender);
-      GNUNET_hash_to_enc (&original_sender.hashPubKey, &encOrigin);     
+      GNUNET_hash_to_enc (&original_sender.hashPubKey, &encOrigin);
       GNUNET_GE_LOG (coreAPI->ectx,
                     GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER
                     | GNUNET_GE_BULK,
                     "%s: Received message for me:\nI am:\n%s\nImmediate 
sender:\n%s\nOriginal Sender:\n%s\n",
                     &shortID, (char *) &encMe, (char *) &encSender,
-                    (char *) &encOrigin);      
+                    (char *) &encOrigin);
 #endif
     }
   else
@@ -589,7 +638,7 @@
            stats->change (stat_dv_forwarded_messages, 1);
          else
            stats->change (stat_dv_failed_forwards, 1);
-       }        
+       }
     }
   return ret;
 }
@@ -747,7 +796,7 @@
             }
         }
       GNUNET_mutex_unlock (ctx->dvMutex);
-      return GNUNET_NO;      
+      return GNUNET_NO;
     }
   if (GNUNET_NO ==
       GNUNET_multi_hash_map_contains (ctx->extended_neighbors,
@@ -760,8 +809,8 @@
          /* don't care, have plenty */
          /* FIXME: might want to consider cost here! */
          GNUNET_mutex_unlock (ctx->dvMutex);
-         return GNUNET_OK;               
-       }        
+         return GNUNET_OK;
+       }
       neighbor = GNUNET_malloc (sizeof (struct GNUNET_dv_neighbor));
       neighbor->cost = cost;
       neighbor->last_activity = now;
@@ -769,7 +818,7 @@
       neighbor->neighbor_id = neighbor_id;
       memcpy (neighbor->neighbor, peer, sizeof (GNUNET_PeerIdentity));
       addToNeighborMap (neighbor_id, peer);
-      
+
       if (referrer == NULL)
        neighbor->referrer = NULL;
       else
@@ -779,24 +828,24 @@
          memcpy (neighbor->referrer, referrer,
                  sizeof (GNUNET_PeerIdentity));
        }
-      
+
       GNUNET_multi_hash_map_put (ctx->extended_neighbors,
                                 &peer->hashPubKey, neighbor,
                                 GNUNET_MultiHashMapOption_REPLACE);
-      
+
       GNUNET_CONTAINER_heap_insert (ctx->neighbor_max_heap, neighbor,
                                    cost);
       GNUNET_CONTAINER_heap_insert (ctx->neighbor_min_heap, neighbor,
                                    cost);
       if (stats != NULL)
-       stats->change (stat_dv_total_peers, 1);    
+       stats->change (stat_dv_total_peers, 1);
       GNUNET_mutex_unlock (ctx->dvMutex);
-      return GNUNET_OK;      
+      return GNUNET_OK;
     }
   neighbor =
     GNUNET_multi_hash_map_get (ctx->extended_neighbors,
                               &peer->hashPubKey);
-  
+
   if ((((neighbor->referrer == NULL) && (referrer == NULL)) ||
        (((neighbor->referrer != NULL) && (referrer != NULL))
        &&
@@ -809,7 +858,7 @@
       if (neighbor->cost != cost)
        {
          /* update cost */
-         neighbor->cost = cost; 
+         neighbor->cost = cost;
          GNUNET_CONTAINER_heap_update_cost (ctx->neighbor_max_heap, neighbor,
                                             cost);
          GNUNET_CONTAINER_heap_update_cost (ctx->neighbor_min_heap, neighbor,
@@ -833,7 +882,7 @@
   neighbor->neighbor_id = neighbor_id;
   memcpy (neighbor->neighbor, peer, sizeof (GNUNET_PeerIdentity));
   addToNeighborMap (neighbor_id, peer);
-      
+
   if (referrer == NULL)
     neighbor->referrer = NULL;
   else
@@ -843,11 +892,11 @@
       memcpy (neighbor->referrer, referrer,
              sizeof (GNUNET_PeerIdentity));
     }
-  
+
   GNUNET_multi_hash_map_put (ctx->extended_neighbors,
                             &peer->hashPubKey, neighbor,
                             GNUNET_MultiHashMapOption_REPLACE);
-  
+
   GNUNET_CONTAINER_heap_insert (ctx->neighbor_max_heap, neighbor,
                                cost);
   GNUNET_CONTAINER_heap_insert (ctx->neighbor_min_heap, neighbor,
@@ -1118,7 +1167,7 @@
  * May need revisiting if we want to specify a maximum or minimum
  * value for this interval.
  */
-static void 
+static void
 updateSendInterval ()
 {
   unsigned int direct_neighbors;

Modified: GNUnet/src/applications/dv/module/dv_heaptest.c
===================================================================
--- GNUnet/src/applications/dv/module/dv_heaptest.c     2009-12-15 20:45:08 UTC 
(rev 9773)
+++ GNUnet/src/applications/dv/module/dv_heaptest.c     2009-12-16 02:13:28 UTC 
(rev 9774)
@@ -63,6 +63,7 @@
       temp_rand = GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 5);
       while ((cur_pos <= 1) && (temp_rand != 0))
         temp_rand = GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 5);
+      fprintf(stderr, "size is %d\n", GNUNET_CONTAINER_heap_get_size(minHeap));
       switch (temp_rand)
         {
         case 0:

Modified: GNUnet/src/applications/dv/module/dvtest.c
===================================================================
--- GNUnet/src/applications/dv/module/dvtest.c  2009-12-15 20:45:08 UTC (rev 
9773)
+++ GNUnet/src/applications/dv/module/dvtest.c  2009-12-16 02:13:28 UTC (rev 
9774)
@@ -34,7 +34,7 @@
 #include "gnunet_directories.h"
 
 #define START_PEERS 1
-#define NUM_RUNS 10
+#define NUM_RUNS 2
 
 static struct GNUNET_REMOTE_TESTING_DaemonContext *peer1;
 static struct GNUNET_REMOTE_TESTING_DaemonContext *peer2;
@@ -196,42 +196,42 @@
     {
       if (ret == 0)
         ret =
-          test (sock, 64, 1, 1, 500 * GNUNET_CRON_MILLISECONDS, 1,
-                15 * GNUNET_CRON_SECONDS, *peer2->peer);
+          test (sock, 64, 5, 5, 500 * GNUNET_CRON_MILLISECONDS, 1,
+                5 * GNUNET_CRON_SECONDS, *peer2->peer);
 
       printf (_("Sending from %s to %s...\n"), (char *) &peer1enc,
               (char *) &peer3enc);
       if (ret == 0)
         ret =
-          test (sock, 64, 1, 1, 50 * GNUNET_CRON_MILLISECONDS, 1,
+          test (sock, 64, 5, 5, 50 * GNUNET_CRON_MILLISECONDS, 1,
                 5 * GNUNET_CRON_SECONDS, *peer3->peer);
 
       printf (_("Sending from %s to %s...\n"), (char *) &peer1enc,
               (char *) &peer4enc);
       if (ret == 0)
         ret =
-          test (sock, 64, 1, 1, 50 * GNUNET_CRON_MILLISECONDS, 1,
+          test (sock, 64, 5, 5, 50 * GNUNET_CRON_MILLISECONDS, 1,
                 5 * GNUNET_CRON_SECONDS, *peer4->peer);
 
       printf (_("Sending from %s to %s...\n"), (char *) &peer1enc,
               (char *) &peer5enc);
       if (ret == 0)
         ret =
-          test (sock, 64, 1, 1, 50 * GNUNET_CRON_MILLISECONDS, 1,
+          test (sock, 64, 5, 5, 50 * GNUNET_CRON_MILLISECONDS, 1,
                 5 * GNUNET_CRON_SECONDS, *peer5->peer);
 
       printf (_("Sending from %s to %s...\n"), (char *) &peer1enc,
               (char *) &peer6enc);
       if (ret == 0)
         ret =
-          test (sock, 64, 1, 1, 50 * GNUNET_CRON_MILLISECONDS, 1,
+          test (sock, 64, 5, 5, 50 * GNUNET_CRON_MILLISECONDS, 1,
                 5 * GNUNET_CRON_SECONDS, *peer6->peer);
 
       printf (_("Sending from %s to %s...\n"), (char *) &peer1enc,
               (char *) &peer7enc);
       if (ret == 0)
         ret =
-          test (sock, 64, 1, 1, 50 * GNUNET_CRON_MILLISECONDS, 1,
+          test (sock, 64, 5, 5, 50 * GNUNET_CRON_MILLISECONDS, 1,
                 5 * GNUNET_CRON_SECONDS, *peer7->peer);
       sleep (60);
     }





reply via email to

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