gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r18151 - gnunet/src/fs
Date: Tue, 15 Nov 2011 11:06:46 +0100

Author: grothoff
Date: 2011-11-15 11:06:46 +0100 (Tue, 15 Nov 2011)
New Revision: 18151

Modified:
   gnunet/src/fs/fs.h
   gnunet/src/fs/fs_download.c
   gnunet/src/fs/fs_search.c
   gnunet/src/fs/gnunet-service-fs_lc.c
Log:
towards fixing #1786

Modified: gnunet/src/fs/fs.h
===================================================================
--- gnunet/src/fs/fs.h  2011-11-15 09:59:33 UTC (rev 18150)
+++ gnunet/src/fs/fs.h  2011-11-15 10:06:46 UTC (rev 18151)
@@ -178,6 +178,25 @@
 
 
 /**
+ * No options.
+ */
+#define SEARCH_MESSAGE_OPTION_NONE 0
+
+/**
+ * Only search the local datastore (no network)
+ */
+#define SEARCH_MESSAGE_OPTION_LOOPBACK_ONLY 1
+
+/**
+ * Request is too large to fit in 64k format.  The list of
+ * already-known search results will be continued in another message
+ * for the same type/query/target and additional already-known results
+ * following this one).
+ */
+#define SEARCH_MESSAGE_OPTION_CONTINUED 2
+
+
+/**
  * Message sent from a GNUnet (fs) search activity to the
  * gnunet-service-fs to start a search.
  */
@@ -191,10 +210,15 @@
   struct GNUNET_MessageHeader header;
 
   /**
-   * Bitmask with options.  Zero for no options, one for loopback-only.
+   * Bitmask with options.  Zero for no options, one for
+   * loopback-only, two for 'to be continued' (with a second search
+   * message for the same type/query/target and additional
+   * already-known results following this one).  See
+   * SEARCH_MESSAGE_OPTION_ defines.
+   *
    * Other bits are currently not defined.
    */
-  int32_t options GNUNET_PACKED;
+  uint32_t options GNUNET_PACKED;
 
   /**
    * Type of the content that we're looking for.

Modified: gnunet/src/fs/fs_download.c
===================================================================
--- gnunet/src/fs/fs_download.c 2011-11-15 09:59:33 UTC (rev 18150)
+++ gnunet/src/fs/fs_download.c 2011-11-15 10:06:46 UTC (rev 18151)
@@ -1284,9 +1284,9 @@
     sm->header.size = htons (sizeof (struct SearchMessage));
     sm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_START_SEARCH);
     if (0 != (dc->options & GNUNET_FS_DOWNLOAD_OPTION_LOOPBACK_ONLY))
-      sm->options = htonl (1);
+      sm->options = htonl (GNUNET_FS_SEARCH_OPTION_LOOPBACK_ONLY);
     else
-      sm->options = htonl (0);
+      sm->options = htonl (GNUNET_FS_SEARCH_OPTION_NONE);
     if (dr->depth == 0)
       sm->type = htonl (GNUNET_BLOCK_TYPE_FS_DBLOCK);
     else

Modified: gnunet/src/fs/fs_search.c
===================================================================
--- gnunet/src/fs/fs_search.c   2011-11-15 09:59:33 UTC (rev 18150)
+++ gnunet/src/fs/fs_search.c   2011-11-15 10:06:46 UTC (rev 18151)
@@ -968,6 +968,7 @@
   GNUNET_HashCode key;
   GNUNET_HashCode idh;
   unsigned int sqms;
+  uint32_t options;
 
   if (NULL == buf)
   {
@@ -979,6 +980,9 @@
   sm = buf;
   sm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_START_SEARCH);
   mbc.xoff = (GNUNET_HashCode *) & sm[1];
+  options = SEARCH_MESSAGE_OPTION_NONE;
+  if (0 != (sc->options & GNUNET_FS_SEARCH_OPTION_LOOPBACK_ONLY))
+    options |= SEARCH_MESSAGE_OPTION_LOOPBACK_ONLY;
   if (GNUNET_FS_uri_test_ksk (sc->uri))
   {
     msize = sizeof (struct SearchMessage);
@@ -994,10 +998,7 @@
       GNUNET_assert (mbc.put_cnt > 0);
 
     sm->header.size = htons (msize);
-    if (0 != (sc->options & GNUNET_FS_SEARCH_OPTION_LOOPBACK_ONLY))
-      sm->options = htonl (1);
-    else
-      sm->options = htonl (0);
+    sm->options = htonl (options);
     sm->type = htonl (GNUNET_BLOCK_TYPE_ANY);
     sm->anonymity_level = htonl (sc->anonymity);
     memset (&sm->target, 0, sizeof (GNUNET_HashCode));
@@ -1025,10 +1026,7 @@
     GNUNET_assert (GNUNET_FS_uri_test_sks (sc->uri));
     msize = sizeof (struct SearchMessage);
     GNUNET_assert (size >= msize);
-    if (0 != (sc->options & GNUNET_FS_SEARCH_OPTION_LOOPBACK_ONLY))
-      sm->options = htonl (1);
-    else
-      sm->options = htonl (0);
+    sm->options = htonl (options);
     sm->type = htonl (GNUNET_BLOCK_TYPE_FS_SBLOCK);
     sm->anonymity_level = htonl (sc->anonymity);
     sm->target = sc->uri->data.sks.namespace;

Modified: gnunet/src/fs/gnunet-service-fs_lc.c
===================================================================
--- gnunet/src/fs/gnunet-service-fs_lc.c        2011-11-15 09:59:33 UTC (rev 
18150)
+++ gnunet/src/fs/gnunet-service-fs_lc.c        2011-11-15 10:06:46 UTC (rev 
18151)
@@ -362,9 +362,10 @@
   cr->lc = lc;
   GNUNET_CONTAINER_DLL_insert (lc->cr_head, lc->cr_tail, cr);
   options = GSF_PRO_LOCAL_REQUEST;
-  if (0 != (1 & ntohl (sm->options)))
+  if (0 != (GNUNET_FS_SEARCH_OPTION_LOOPBACK_ONLY & ntohl (sm->options)))
     options |= GSF_PRO_LOCAL_ONLY;
-  cr->pr = GSF_pending_request_create_ (options, type, &sm->query, (type == 
GNUNET_BLOCK_TYPE_FS_SBLOCK) ? &sm->target  /* namespace */
+  cr->pr = GSF_pending_request_create_ (options, type, &sm->query,
+                                       (type == GNUNET_BLOCK_TYPE_FS_SBLOCK) ? 
&sm->target  /* namespace */
                                         : NULL,
                                         (0 !=
                                          memcmp (&sm->target, &all_zeros,




reply via email to

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