gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r10712 - gnunet/src/fs


From: gnunet
Subject: [GNUnet-SVN] r10712 - gnunet/src/fs
Date: Mon, 29 Mar 2010 19:51:49 +0200

Author: grothoff
Date: 2010-03-29 19:51:49 +0200 (Mon, 29 Mar 2010)
New Revision: 10712

Modified:
   gnunet/src/fs/fs_publish.c
   gnunet/src/fs/fs_search.c
   gnunet/src/fs/fs_uri.c
   gnunet/src/fs/gnunet-service-fs.c
   gnunet/src/fs/test_fs_namespace.c
   gnunet/src/fs/test_fs_search.c
   gnunet/src/fs/test_fs_search_data.conf
Log:
fixes

Modified: gnunet/src/fs/fs_publish.c
===================================================================
--- gnunet/src/fs/fs_publish.c  2010-03-29 17:05:32 UTC (rev 10711)
+++ gnunet/src/fs/fs_publish.c  2010-03-29 17:51:49 UTC (rev 10712)
@@ -1498,7 +1498,6 @@
     update = "";
   nidlen = strlen (update) + 1;
   mdsize = GNUNET_CONTAINER_meta_data_get_serialized_size (meta);
-
   size = sizeof (struct SBlock) + slen + nidlen + mdsize;
   if (size > MAX_SBLOCK_SIZE)
     {
@@ -1526,7 +1525,7 @@
       return;
     }
   size = sizeof (struct SBlock) + mdsize + slen + nidlen;
-  sb_enc = GNUNET_malloc (sizeof (struct SBlock) + size);
+  sb_enc = GNUNET_malloc (size);
   GNUNET_CRYPTO_hash (identifier, idlen, &key);
   GNUNET_CRYPTO_hash (&key, sizeof (GNUNET_HashCode), &id);
   sks_uri = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri));

Modified: gnunet/src/fs/fs_search.c
===================================================================
--- gnunet/src/fs/fs_search.c   2010-03-29 17:05:32 UTC (rev 10711)
+++ gnunet/src/fs/fs_search.c   2010-03-29 17:51:49 UTC (rev 10712)
@@ -438,7 +438,7 @@
                      strlen (identifier), 
                      &key);
   GNUNET_CRYPTO_hash_to_aes_key (&key, &skey, &iv);
-  GNUNET_CRYPTO_aes_encrypt (&sb[1],
+  GNUNET_CRYPTO_aes_decrypt (&sb[1],
                             len,
                             &skey,
                             &iv,
@@ -464,6 +464,9 @@
   uri = GNUNET_FS_uri_parse (uris, &emsg);
   if (uri == NULL)
     {
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                 "Failed to parse URI `%s': %s\n",
+                 uris, emsg);
       GNUNET_break_op (0);     /* sblock malformed */
       GNUNET_free_non_null (emsg);
       GNUNET_CONTAINER_meta_data_destroy (meta);
@@ -494,7 +497,11 @@
                size_t size)
 {
   if (GNUNET_TIME_absolute_get_duration (expiration).value > 0)
-    return; /* result expired */
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                 "Result received has already expired.\n");
+      return; /* result expired */
+    }
   switch (type)
     {
     case GNUNET_DATASTORE_BLOCKTYPE_KBLOCK:
@@ -511,7 +518,7 @@
       process_kblock (sc, data, size);
       break;
     case GNUNET_DATASTORE_BLOCKTYPE_SBLOCK:
-      if (! GNUNET_FS_uri_test_ksk (sc->uri))
+      if (! GNUNET_FS_uri_test_sks (sc->uri))
        {
          GNUNET_break (0);
          return;
@@ -572,6 +579,9 @@
       return;
     }
   msize = ntohs (msg->size);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Receiving %u bytes of result from fs service\n",
+             msize);
   cm = (const struct PutMessage*) msg;
   process_result (sc, 
                  ntohl (cm->type),
@@ -624,7 +634,7 @@
          sm[i].header.size = htons (sizeof (struct SearchMessage));
          sm[i].header.type = htons (GNUNET_MESSAGE_TYPE_FS_START_SEARCH);
          sm[i].type = htonl (GNUNET_DATASTORE_BLOCKTYPE_KBLOCK);
-  sm[i].anonymity_level = htonl (sc->anonymity);
+         sm[i].anonymity_level = htonl (sc->anonymity);
          sm[i].query = sc->requests[i].query;
        }
     }
@@ -966,8 +976,12 @@
   if (NULL != sc->client)
     GNUNET_CLIENT_disconnect (sc->client, GNUNET_NO);
   GNUNET_CONTAINER_multihashmap_destroy (sc->master_result_map);
-  for (i=0;i<sc->uri->data.ksk.keywordCount;i++)
-    GNUNET_CONTAINER_multihashmap_destroy (sc->requests[i].results);
+  if (sc->requests != NULL)
+    {
+      GNUNET_assert (GNUNET_FS_uri_test_ksk (sc->uri));
+      for (i=0;i<sc->uri->data.ksk.keywordCount;i++)
+       GNUNET_CONTAINER_multihashmap_destroy (sc->requests[i].results);
+    }
   GNUNET_free_non_null (sc->requests);
   GNUNET_FS_uri_destroy (sc->uri);
   GNUNET_free (sc);

Modified: gnunet/src/fs/fs_uri.c
===================================================================
--- gnunet/src/fs/fs_uri.c      2010-03-29 17:05:32 UTC (rev 10711)
+++ gnunet/src/fs/fs_uri.c      2010-03-29 17:51:49 UTC (rev 10712)
@@ -361,7 +361,7 @@
        (0 != strncmp (s, GNUNET_FS_URI_PREFIX GNUNET_FS_URI_SKS_INFIX, 
                      pos) ) )
     return NULL; /* not an SKS URI */
-  if ( (slen < pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) + 1) ||
+  if ( (slen < pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)) ||
        (s[pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1] != '/') )
     {
       *emsg = GNUNET_strdup (_("Malformed SKS URI"));

Modified: gnunet/src/fs/gnunet-service-fs.c
===================================================================
--- gnunet/src/fs/gnunet-service-fs.c   2010-03-29 17:05:32 UTC (rev 10711)
+++ gnunet/src/fs/gnunet-service-fs.c   2010-03-29 17:51:49 UTC (rev 10712)
@@ -23,6 +23,8 @@
  * @brief gnunet anonymity protocol implementation
  * @author Christian Grothoff
  *
+ * FIXME:
+ * - code not clear in terms of which function initializes bloomfilter when!
  * TODO:
  * - have non-zero preference / priority for requests we initiate!
  * - track stats for hot-path routing
@@ -1844,7 +1846,11 @@
       if (0 != memcmp (pr->namespace,
                       &prq->namespace,
                       sizeof (GNUNET_HashCode)))
-       return GNUNET_YES; /* wrong namespace */        
+       {
+         GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                     _("Reply mismatched in terms of namespace.  
Discarded.\n"));
+         return GNUNET_YES; /* wrong namespace */      
+       }
       /* then: fall-through! */
     case GNUNET_DATASTORE_BLOCKTYPE_KBLOCK:
       if (pr->bf != NULL) 
@@ -1852,7 +1858,19 @@
          mingle_hash (&chash, pr->mingle, &mhash);
          if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (pr->bf,
                                                               &mhash))
-           return GNUNET_YES; /* duplicate */
+           {
+             GNUNET_STATISTICS_update (stats,
+                                       gettext_noop ("# duplicate replies 
discarded (bloomfilter)"),
+                                       1,
+                                       GNUNET_NO);
+             GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                         "Duplicate response `%s', discarding.\n",
+                         GNUNET_h2s (&mhash));
+             return GNUNET_YES; /* duplicate */
+           }
+         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                     "New response `%s', adding to filter.\n",
+                     GNUNET_h2s (&mhash));
          GNUNET_CONTAINER_bloomfilter_add (pr->bf,
                                            &mhash);
        }
@@ -1870,8 +1888,7 @@
                                            &pr->bf_size,
                                            pr->replies_seen);
            }
-           pr->replies_seen[pr->replies_seen_off++] = chash;
-             
+           pr->replies_seen[pr->replies_seen_off++] = chash;         
        }
       break;
     case GNUNET_DATASTORE_BLOCKTYPE_NBLOCK:
@@ -1910,11 +1927,18 @@
       pm->expiration = GNUNET_TIME_absolute_hton (prq->expiration);
       memcpy (&pm[1], prq->data, prq->size);      
       if (NULL == cl->th)
-       cl->th = GNUNET_SERVER_notify_transmit_ready (cl->client,
-                                                     msize,
-                                                     
GNUNET_TIME_UNIT_FOREVER_REL,
-                                                     &transmit_to_client,
-                                                     cl);
+       {
+#if DEBUG_FS
+         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                     "Transmitting result for query `%s' to client\n",
+                     GNUNET_h2s (key));
+#endif  
+         cl->th = GNUNET_SERVER_notify_transmit_ready (cl->client,
+                                                       msize,
+                                                       
GNUNET_TIME_UNIT_FOREVER_REL,
+                                                       &transmit_to_client,
+                                                       cl);
+       }
       GNUNET_break (cl->th != NULL);
     }
   else
@@ -1953,11 +1977,9 @@
                    GNUNET_CONTAINER_multihashmap_remove (query_request_map,
                                                          key,
                                                          pr));
-      // FIXME: request somehow does not fully
-      // disappear; how to fix? 
+      // FIXME: request somehow does not fully disappear; how to fix? 
       // destroy_pending_request (pr); (not like this!)
     }
-
   // FIXME: implement hot-path routing statistics keeping!
   return GNUNET_YES;
 }
@@ -2188,6 +2210,10 @@
                                             pr);      
       return;
     }
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "New local response to `%s' of type %u.\n",
+             GNUNET_h2s (key),
+             type);
   if (type == GNUNET_DATASTORE_BLOCKTYPE_ONDEMAND)
     {
 #if DEBUG_FS
@@ -2248,8 +2274,13 @@
                                                      pr->bf_size, 
                                                      BLOOMFILTER_K);
        }
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                 "New local response `%s', adding to filter.\n",
+                 GNUNET_h2s (&mhash));
+#if 0
       GNUNET_CONTAINER_bloomfilter_add (pr->bf, 
                                        &mhash);
+#endif
     }
   memset (&prq, 0, sizeof (prq));
   prq.data = data;

Modified: gnunet/src/fs/test_fs_namespace.c
===================================================================
--- gnunet/src/fs/test_fs_namespace.c   2010-03-29 17:05:32 UTC (rev 10711)
+++ gnunet/src/fs/test_fs_namespace.c   2010-03-29 17:51:49 UTC (rev 10712)
@@ -23,6 +23,9 @@
  * @brief Test for fs_namespace.c
  * @author Christian Grothoff
  *
+ *
+ * FIXME:
+ * - child search of "sks" search (the "next" identifier) is not stopped => no 
termination!
  * TODO:
  * - add timeout task
  */
@@ -105,7 +108,10 @@
       GNUNET_FS_search_stop (ksk_search);
       ksk_search = NULL;
       if (sks_search == NULL)
-       GNUNET_FS_stop (fs);
+       {
+         fprintf (stderr, "initiating shutdown\n");
+         GNUNET_FS_stop (fs);
+       }
     }
 }
 
@@ -116,16 +122,18 @@
 {
   struct GNUNET_FS_Namespace *ns;
 
-  if (sks_search != NULL)
+  if (sks_search == NULL)
+    return;
+  GNUNET_FS_search_stop (sks_search); 
+  sks_search = NULL;
+  ns = GNUNET_FS_namespace_create (fs,
+                                  "testNamespace");
+  GNUNET_assert (GNUNET_OK == GNUNET_FS_namespace_delete (ns, GNUNET_YES));
+  if (ksk_search == NULL)
     {
-      GNUNET_FS_search_stop (sks_search);
-      sks_search = NULL;
-      ns = GNUNET_FS_namespace_create (fs,
-                                      "testNamespace");
-      GNUNET_assert (GNUNET_OK == GNUNET_FS_namespace_delete (ns, GNUNET_YES));
-      if (ksk_search == NULL)
-       GNUNET_FS_stop (fs);
-    }
+      fprintf (stderr, "initiating shutdown\n");
+      GNUNET_FS_stop (fs);
+    }    
 }
 
 
@@ -202,26 +210,26 @@
                      (0 == strcmp ("ksk_search", event->value.search.cctx)));
       if (NULL == event->value.search.cctx)
        {
-         GNUNET_assert (sks_search == event->value.search.pctx);
+         GNUNET_assert (0 == strcmp ("sks_search", event->value.search.pctx));
          update_started = GNUNET_YES;
        }
       GNUNET_assert (1 == event->value.search.anonymity);
       break;
     case GNUNET_FS_STATUS_SEARCH_RESULT_STOPPED:
-      break;
+      return NULL;
     case GNUNET_FS_STATUS_SEARCH_STOPPED:
       fprintf (stderr,
               "Search stop event received\n");
       GNUNET_assert ( (ksk_search == event->value.search.sc) ||
                      (sks_search == event->value.search.sc));
-      break;
+      return NULL;
     default:
       fprintf (stderr,
               "Unexpected event: %d\n", 
               event->status);
       break;
     }
-  return NULL;
+  return event->value.search.cctx;
 }
 
 

Modified: gnunet/src/fs/test_fs_search.c
===================================================================
--- gnunet/src/fs/test_fs_search.c      2010-03-29 17:05:32 UTC (rev 10711)
+++ gnunet/src/fs/test_fs_search.c      2010-03-29 17:51:49 UTC (rev 10712)
@@ -29,7 +29,7 @@
 #include "gnunet_arm_service.h"
 #include "gnunet_fs_service.h"
 
-#define VERBOSE GNUNET_NO
+#define VERBOSE GNUNET_YES
 
 #define START_ARM GNUNET_YES
 

Modified: gnunet/src/fs/test_fs_search_data.conf
===================================================================
--- gnunet/src/fs/test_fs_search_data.conf      2010-03-29 17:05:32 UTC (rev 
10711)
+++ gnunet/src/fs/test_fs_search_data.conf      2010-03-29 17:51:49 UTC (rev 
10712)
@@ -19,7 +19,7 @@
 DEFAULTSERVICES = resolver datastore transport core fs
 
 [datastore]
-#DEBUG = YES
+DEBUG = YES
 
 [statistics]
 PORT = 42467
@@ -36,7 +36,7 @@
 [fs]
 PORT = 42471
 HOSTNAME = localhost
-#DEBUG = YES
+DEBUG = YES
 
 [testing]
 WEAKRANDOM = YES





reply via email to

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