fixes
authorChristian Grothoff <christian@grothoff.org>
Mon, 29 Mar 2010 17:51:49 +0000 (17:51 +0000)
committerChristian Grothoff <christian@grothoff.org>
Mon, 29 Mar 2010 17:51:49 +0000 (17:51 +0000)
src/fs/fs_publish.c
src/fs/fs_search.c
src/fs/fs_uri.c
src/fs/gnunet-service-fs.c
src/fs/test_fs_namespace.c
src/fs/test_fs_search.c
src/fs/test_fs_search_data.conf

index f6e66e456daeddcabee89a606c279f2b6311f285..dbecdfab706224faa1b9890a0a75f849aac5648e 100644 (file)
@@ -1498,7 +1498,6 @@ GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h,
     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 @@ GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h,
       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));
index 746a2f19d082a9e33f37a4eac76b69c745289d52..3b90338af6fee9f37253402be0200758167fe7b9 100644 (file)
@@ -438,7 +438,7 @@ process_sblock (struct GNUNET_FS_SearchContext *sc,
                      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 @@ process_sblock (struct GNUNET_FS_SearchContext *sc,
   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 @@ process_result (struct GNUNET_FS_SearchContext *sc,
                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_result (struct GNUNET_FS_SearchContext *sc,
       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 @@ receive_results (void *cls,
       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 @@ transmit_search_request (void *cls,
          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 @@ GNUNET_FS_search_stop (struct GNUNET_FS_SearchContext *sc)
   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);
index 5c95f0e7a2269d32faa4b9ad05f4835bea78d351..b402fa8308c11c74d0f7e13abad7a01f529f3027 100644 (file)
@@ -361,7 +361,7 @@ uri_sks_parse (const char *s, char **emsg)
        (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"));
index e230a5e7731a0effde2bbab0555d0e46441c3bd8..7f22307472826c4eb5d1210ba64276b6f095f023 100644 (file)
@@ -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 @@ process_reply (void *cls,
       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 @@ process_reply (void *cls,
          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 @@ process_reply (void *cls,
                                            &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 @@ process_reply (void *cls,
       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 @@ process_reply (void *cls,
                    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 @@ process_local_reply (void *cls,
                                             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 @@ process_local_reply (void *cls,
                                                      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;
index 6014e4394467574b5571901ded665a61773fed73..2284f3cef47ac0bc30fe6b6cbeb13dedef4f70c1 100644 (file)
@@ -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 @@ abort_ksk_search_task (void *cls,
       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 @@ abort_sks_search_task (void *cls,
 {
   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 @@ progress_cb (void *cls,
                      (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;
 }
 
 
index 4320f965f8edca72eb8fd2fc190fffd9afb29639..d4d000c4052353a7a8165f7acff6c3c97b371bc8 100644 (file)
@@ -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
 
index cffe83f57e184438d2de826fa94f5d3e9d94c787..40b440b2e6e700ebff5f2aa3ceca0a1477e7e680 100644 (file)
@@ -19,7 +19,7 @@ HOSTNAME = localhost
 DEFAULTSERVICES = resolver datastore transport core fs
 
 [datastore]
-#DEBUG = YES
+DEBUG = YES
 
 [statistics]
 PORT = 42467
@@ -36,7 +36,7 @@ HOSTNAME = localhost
 [fs]
 PORT = 42471
 HOSTNAME = localhost
-#DEBUG = YES
+DEBUG = YES
 
 [testing]
 WEAKRANDOM = YES