gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r11176 - in gnunet: . src/fs


From: gnunet
Subject: [GNUnet-SVN] r11176 - in gnunet: . src/fs
Date: Tue, 4 May 2010 13:55:52 +0200

Author: grothoff
Date: 2010-05-04 13:55:52 +0200 (Tue, 04 May 2010)
New Revision: 11176

Modified:
   gnunet/TODO
   gnunet/src/fs/fs.c
   gnunet/src/fs/fs.h
   gnunet/src/fs/fs_download.c
   gnunet/src/fs/fs_publish.c
   gnunet/src/fs/fs_search.c
   gnunet/src/fs/fs_unindex.c
Log:
code cleanup

Modified: gnunet/TODO
===================================================================
--- gnunet/TODO 2010-05-04 11:14:25 UTC (rev 11175)
+++ gnunet/TODO 2010-05-04 11:55:52 UTC (rev 11176)
@@ -2,7 +2,12 @@
 * FS: [CG]
   - code review:
     => refactor fs.c to join common code segments!
+       => pbuf sprintf'ing
+       => initial master directory scanning
     => document directory structure (and use #define's for the directory 
names!)
+  - SKS update searches should be attached to individual search results, not 
to the 
+    entire SKS search (!)
+    => API change (event signalling) & serialization change (!)
   - persistence testing (publish, unindex, search, download):
     => need driver!
     => schedule suspending tasks DURING event handler => good coverage!
@@ -114,7 +119,6 @@
 * FS:
   - reconstruct IBLOCKS from DBLOCKS if possible (during download; see FIXME 
in fs_download)
 
-
 0.9.0:
 * new webpage:
   - expand bibliography

Modified: gnunet/src/fs/fs.c
===================================================================
--- gnunet/src/fs/fs.c  2010-05-04 11:14:25 UTC (rev 11175)
+++ gnunet/src/fs/fs.c  2010-05-04 11:55:52 UTC (rev 11176)
@@ -817,7 +817,7 @@
   struct GNUNET_BIO_ReadHandle *rh;
   char *emsg;
 
-  rh = get_read_handle (h, "publish-fi", filename);
+  rh = get_read_handle (h, GNUNET_FS_SYNC_PATH_FILE_INFO, filename);
   if (rh == NULL)
     return NULL;
   ret = deserialize_fi_node (h, filename, rh);
@@ -952,10 +952,10 @@
   char *chks;
 
   if (NULL == fi->serialization)    
-    fi->serialization = make_serialization_file_name (fi->h, "publish-fi");
+    fi->serialization = make_serialization_file_name (fi->h, 
GNUNET_FS_SYNC_PATH_FILE_INFO);
   if (NULL == fi->serialization)
     return;
-  wh = get_write_handle (fi->h, "publish-fi", fi->serialization);
+  wh = get_write_handle (fi->h, GNUNET_FS_SYNC_PATH_FILE_INFO, 
fi->serialization);
   if (wh == NULL)
     {
       GNUNET_free (fi->serialization);
@@ -1058,7 +1058,7 @@
   (void) GNUNET_BIO_write_close (wh);
   GNUNET_free_non_null (chks);
   GNUNET_free_non_null (ksks);
-  fn = get_serialization_file_name (fi->h, "publish-fi", fi->serialization);
+  fn = get_serialization_file_name (fi->h, GNUNET_FS_SYNC_PATH_FILE_INFO, 
fi->serialization);
   if (0 != UNLINK (fn))
     GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", fn);
   GNUNET_free (fn);
@@ -1254,8 +1254,8 @@
     }
   if (pc->fi != NULL)
     GNUNET_FS_file_information_destroy (pc->fi, NULL, NULL);
-  if (pc->serialization != NULL)
-    GNUNET_FS_remove_sync_file_ (h, "publish", pc->serialization);
+  if (0 != UNLINK (filename))
+    GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", filename);
   GNUNET_free_non_null (pc->serialization);
   GNUNET_free (pc);
   return GNUNET_OK;
@@ -1277,7 +1277,7 @@
 
   if (NULL == pc->serialization)
     pc->serialization = make_serialization_file_name (pc->h,
-                                                     "publish");
+                                                     
GNUNET_FS_SYNC_PATH_MASTER_PUBLISH);
   if (NULL == pc->serialization)
     return;
   if (NULL == pc->fi)
@@ -1287,7 +1287,7 @@
       GNUNET_break (0);
       return;
     }
-  wh = get_write_handle (pc->h, "publish", pc->serialization);
+  wh = get_write_handle (pc->h, GNUNET_FS_SYNC_PATH_MASTER_PUBLISH, 
pc->serialization);
   if ( (GNUNET_OK !=
        GNUNET_BIO_write_string (wh, pc->nid)) ||
        (GNUNET_OK !=
@@ -1303,20 +1303,21 @@
        (GNUNET_OK !=
        GNUNET_BIO_write_string (wh, (pc->namespace == NULL) ? NULL : 
pc->namespace->name)) )
    {
-     (void) GNUNET_BIO_write_close (wh);
-     GNUNET_FS_remove_sync_file_ (pc->h, "publish", pc->serialization);
-     GNUNET_free (pc->serialization);
-     pc->serialization = NULL;
-     return;
+     goto cleanup;
    }
  if (GNUNET_OK !=
      GNUNET_BIO_write_close (wh))
    {
-     GNUNET_FS_remove_sync_file_ (pc->h, "publish", pc->serialization);
-     GNUNET_free (pc->serialization);
-     pc->serialization = NULL;
-     return;     
-   }  
+     wh = NULL;
+     goto cleanup;
+   }
+ return;
+ cleanup:
+ if (wh != NULL)
+     (void) GNUNET_BIO_write_close (wh); 
+ GNUNET_FS_remove_sync_file_ (pc->h, GNUNET_FS_SYNC_PATH_MASTER_PUBLISH, 
pc->serialization);
+ GNUNET_free (pc->serialization);
+ pc->serialization = NULL;
 }
 
 
@@ -1337,10 +1338,10 @@
     return;
   if (NULL == uc->serialization)
     uc->serialization = make_serialization_file_name (uc->h,
-                                                     "unindex");
+                                                     
GNUNET_FS_SYNC_PATH_MASTER_UNINDEX);
   if (NULL == uc->serialization)
     return;
-  wh = get_write_handle (uc->h, "unindex", uc->serialization);
+  wh = get_write_handle (uc->h, GNUNET_FS_SYNC_PATH_MASTER_UNINDEX, 
uc->serialization);
   if ( (GNUNET_OK !=
        GNUNET_BIO_write_string (wh, uc->filename)) ||
        (GNUNET_OK !=
@@ -1355,21 +1356,20 @@
        ( (uc->state == UNINDEX_STATE_ERROR) &&
         (GNUNET_OK !=
          GNUNET_BIO_write_string (wh, uc->emsg)) ) )
-    {
-      (void) GNUNET_BIO_write_close (wh);
-      GNUNET_FS_remove_sync_file_ (uc->h, "publish", uc->serialization);
-      GNUNET_free (uc->serialization);
-      uc->serialization = NULL;
-      return;
-    }
+    goto cleanup;
   if (GNUNET_OK !=
       GNUNET_BIO_write_close (wh))
     {
-      GNUNET_FS_remove_sync_file_ (uc->h, "unindex", uc->serialization);
-      GNUNET_free (uc->serialization);
-      uc->serialization = NULL;
-      return;     
+      wh = NULL;
+      goto cleanup;
     }  
+  return;
+ cleanup:
+  if (wh != NULL)
+    (void) GNUNET_BIO_write_close (wh);
+  GNUNET_FS_remove_sync_file_ (uc->h, GNUNET_FS_SYNC_PATH_MASTER_UNINDEX, 
uc->serialization);
+  GNUNET_free (uc->serialization);
+  uc->serialization = NULL;
 }
 
 
@@ -1445,14 +1445,14 @@
       GNUNET_snprintf (pbuf,
                       sizeof (pbuf),
                       "%s%s%s",
-                      "subdownloads",
+                      GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD,
                       DIR_SEPARATOR_STR,
                       dc->parent->serialization);
       category = pbuf;
     }
   else
     {
-      category = "download";
+      category = GNUNET_FS_SYNC_PATH_MASTER_DOWNLOAD;
     }
   if (NULL == dc->serialization)    
     dc->serialization = make_serialization_file_name (dc->h, 
@@ -1544,10 +1544,10 @@
   uris = NULL;
   if (NULL == sr->serialization)
     sr->serialization = make_serialization_file_name (sr->sc->h,
-                                                     "search-results");
+                                                     
GNUNET_FS_SYNC_PATH_SEARCH_RESULT);
   if (NULL == sr->serialization)
     return;
-  wh = get_write_handle (sr->sc->h, "search-results", sr->serialization);
+  wh = get_write_handle (sr->sc->h, GNUNET_FS_SYNC_PATH_SEARCH_RESULT, 
sr->serialization);
   uris = GNUNET_FS_uri_to_string (sr->uri);
   if ( (GNUNET_OK !=
        GNUNET_BIO_write_string (wh, uris)) ||
@@ -1578,7 +1578,7 @@
   GNUNET_free_non_null (uris);
   if (wh != NULL)
     (void)  GNUNET_BIO_write_close (wh);
-  GNUNET_FS_remove_sync_file_ (sr->sc->h, "search-results", sr->serialization);
+  GNUNET_FS_remove_sync_file_ (sr->sc->h, GNUNET_FS_SYNC_PATH_SEARCH_RESULT, 
sr->serialization);
   GNUNET_free (sr->serialization);
   sr->serialization = NULL;
 }
@@ -1599,13 +1599,16 @@
   struct GNUNET_FS_SearchContext *scc;
   char *uris;
   char in_pause;
+  const char *category;
 
+  
+  category = (sc->parent == NULL) ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH : 
GNUNET_FS_SYNC_PATH_CHILD_SEARCH;      
   if (NULL == sc->serialization)
     sc->serialization = make_serialization_file_name (sc->h,
-                                                     "search");
+                                                     category);
   if (NULL == sc->serialization)
     return;
-  wh = get_write_handle (sc->h, "search", sc->serialization);
+  wh = get_write_handle (sc->h, category, sc->serialization);
   GNUNET_assert ( (GNUNET_YES == GNUNET_FS_uri_test_ksk (sc->uri)) ||
                  (GNUNET_YES == GNUNET_FS_uri_test_sks (sc->uri)) );
   uris = GNUNET_FS_uri_to_string (sc->uri);
@@ -1647,7 +1650,7 @@
   if (wh != NULL)
     (void) GNUNET_BIO_write_close (wh);
   GNUNET_free_non_null (uris);
-  GNUNET_FS_remove_sync_file_ (sc->h, "search", sc->serialization);
+  GNUNET_FS_remove_sync_file_ (sc->h, category, sc->serialization);
   GNUNET_free (sc->serialization);
   sc->serialization = NULL;
 }
@@ -1663,7 +1666,7 @@
 {
   char *dn;
 
-  dn = get_serialization_file_name (h, "publish", "");
+  dn = get_serialization_file_name (h, GNUNET_FS_SYNC_PATH_MASTER_PUBLISH, "");
   if (dn == NULL)
     return;
   GNUNET_DISK_directory_scan (dn, &deserialize_publish_file, h);
@@ -1786,7 +1789,7 @@
       GNUNET_free (emsg);
     }
   if (uc->serialization != NULL)
-    GNUNET_FS_remove_sync_file_ (h, "unindex", uc->serialization);
+    GNUNET_FS_remove_sync_file_ (h, GNUNET_FS_SYNC_PATH_MASTER_UNINDEX, 
uc->serialization);
   GNUNET_free_non_null (uc->serialization);
   GNUNET_free (uc);
   return GNUNET_OK;
@@ -1803,7 +1806,7 @@
 {
   char *dn;
 
-  dn = get_serialization_file_name (h, "unindex", "");
+  dn = get_serialization_file_name (h,  GNUNET_FS_SYNC_PATH_MASTER_UNINDEX, 
"");
   if (dn == NULL)
     return;
   GNUNET_DISK_directory_scan (dn, &deserialize_unindex_file, h);
@@ -1859,7 +1862,7 @@
          GNUNET_snprintf (pbuf,
                           sizeof (pbuf),
                           "%s%s%s",
-                          "search-results",
+                          GNUNET_FS_SYNC_PATH_SEARCH_RESULT,
                           DIR_SEPARATOR_STR,
                           sc->serialization);
          GNUNET_FS_remove_sync_file_ (sc->h, pbuf, ser);
@@ -1894,7 +1897,7 @@
   if (download != NULL)
     {
       drh = get_read_handle (sc->h, 
-                            "subdownloads",
+                            GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD,
                             download);
       deserialize_download (sc->h,
                            drh,
@@ -2044,7 +2047,7 @@
     }
   GNUNET_free_non_null (sc->emsg);
   if (sc->serialization != NULL)
-    GNUNET_FS_remove_sync_file_ (sc->h, "search", sc->serialization);
+    GNUNET_FS_remove_sync_file_ (sc->h, GNUNET_FS_SYNC_PATH_MASTER_SEARCH, 
sc->serialization);
   /* FIXME: remove 'pbuf' directory with search results as well! */
   GNUNET_free_non_null (sc->serialization);
   if (sc->uri != NULL)
@@ -2227,7 +2230,7 @@
   GNUNET_snprintf (pbuf,
                   sizeof (pbuf),
                   "%s%s%s",
-                  "subdownloads",
+                  GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD,
                   DIR_SEPARATOR_STR,
                   dc->serialization);
   dn = get_serialization_file_name (h, pbuf, "");
@@ -2333,7 +2336,7 @@
   GNUNET_snprintf (pbuf,
                   sizeof (pbuf),
                   "%s%s%s",
-                  "search-results",
+                  GNUNET_FS_SYNC_PATH_SEARCH_RESULT,
                   DIR_SEPARATOR_STR,
                   sc->serialization);
   dn = get_serialization_file_name (h, pbuf, "");
@@ -2356,7 +2359,7 @@
        goto cleanup;
       if (child_ser == NULL)
        break;    
-      rhc = get_read_handle (h, "search-children", child_ser);
+      rhc = get_read_handle (h, GNUNET_FS_SYNC_PATH_CHILD_SEARCH, child_ser);
       if (rhc != NULL)
        {
          scc = deserialize_search (h, rhc, sc, child_ser);
@@ -2419,7 +2422,7 @@
     {
       if (ser != NULL)
        {
-         GNUNET_FS_remove_sync_file_ (h, "search", ser);
+         GNUNET_FS_remove_sync_file_ (h, GNUNET_FS_SYNC_PATH_MASTER_SEARCH, 
ser);
          GNUNET_free (ser);
        }
       return GNUNET_OK;
@@ -2449,7 +2452,7 @@
 {
   char *dn;
 
-  dn = get_serialization_file_name (h, "search", "");
+  dn = get_serialization_file_name (h, GNUNET_FS_SYNC_PATH_MASTER_SEARCH, "");
   if (dn == NULL)
     return;
   GNUNET_DISK_directory_scan (dn, &deserialize_search_file, h);
@@ -2513,7 +2516,7 @@
 {
   char *dn;
 
-  dn = get_serialization_file_name (h, "download", "");
+  dn = get_serialization_file_name (h, GNUNET_FS_SYNC_PATH_MASTER_DOWNLOAD, 
"");
   if (dn == NULL)
     return;
   GNUNET_DISK_directory_scan (dn, &deserialize_download_file, h);
@@ -2543,22 +2546,15 @@
                 ...)
 {
   struct GNUNET_FS_Handle *ret;
-  struct GNUNET_CLIENT_Connection *client;
   enum GNUNET_FS_OPTIONS opt;
   va_list ap;
 
-  client = GNUNET_CLIENT_connect (sched,
-                                 "fs",
-                                 cfg);
-  if (NULL == client)
-    return NULL;
   ret = GNUNET_malloc (sizeof (struct GNUNET_FS_Handle));
   ret->sched = sched;
   ret->cfg = cfg;
   ret->client_name = GNUNET_strdup (client_name);
   ret->upcb = upcb;
   ret->upcb_cls = upcb_cls;
-  ret->client = client;
   ret->flags = flags;
   ret->max_parallel_downloads = 1;
   ret->max_parallel_requests = 1;
@@ -2583,7 +2579,6 @@
        }
     }
   va_end (ap);
-  // FIXME: setup receive-loop with client (do we need one?)
   if (0 != (GNUNET_FS_FLAGS_PERSISTENCE & flags))
     {
       /* FIXME: could write one generic deserialization
@@ -2610,11 +2605,10 @@
   /* generate SUSPEND events and clean up state */
   while (h->top_head != NULL)
     h->top_head->ssf (h->top_head->ssf_cls);
-  // FIXME: terminate receive-loop with client  (do we need one?)
+  /* FIXME: terminate receive-loop with client  (do we need one?) */
   if (h->queue_job != GNUNET_SCHEDULER_NO_TASK)
     GNUNET_SCHEDULER_cancel (h->sched,
                             h->queue_job);
-  GNUNET_CLIENT_disconnect (h->client, GNUNET_NO);
   GNUNET_free (h->client_name);
   GNUNET_free (h);
 }

Modified: gnunet/src/fs/fs.h
===================================================================
--- gnunet/src/fs/fs.h  2010-05-04 11:14:25 UTC (rev 11175)
+++ gnunet/src/fs/fs.h  2010-05-04 11:55:52 UTC (rev 11176)
@@ -151,9 +151,50 @@
  */
 #define IDLE_LOAD_THRESHOLD ((100 + GNUNET_CONSTANTS_IDLE_LOAD_THRESHOLD) / 2)
 
+/**
+ * Name of the directory with top-level searches.
+ */
+#define GNUNET_FS_SYNC_PATH_MASTER_SEARCH "search"
 
+/**
+ * Name of the directory with sub-searches (namespace-updates).
+ */
+#define GNUNET_FS_SYNC_PATH_CHILD_SEARCH "search-child"
 
 /**
+ * Name of the directory with search results.
+ */
+#define GNUNET_FS_SYNC_PATH_SEARCH_RESULT "search-result"
+
+/**
+ * Name of the directory with master downloads (not associated
+ * with search or part of another download).
+ */
+#define GNUNET_FS_SYNC_PATH_MASTER_DOWNLOAD "download"
+
+/**
+ * Name of the directory with downloads that are part of another
+ * download or a search.
+ */
+#define GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD "download-child"
+
+/**
+ * Name of the directory with publishing operations.
+ */
+#define GNUNET_FS_SYNC_PATH_MASTER_PUBLISH "publish"
+
+/**
+ * Name of the directory with files that are being published
+ */
+#define GNUNET_FS_SYNC_PATH_FILE_INFO "publish-file"
+
+/**
+ * Name of the directory with unindex operations.
+ */
+#define GNUNET_FS_SYNC_PATH_MASTER_UNINDEX "unindex"
+
+
+/**
  * @brief content hash key
  */
 struct ContentHashKey 
@@ -1082,11 +1123,6 @@
   void *upcb_cls;
 
   /**
-   * Connection to the FS service.
-   */
-  struct GNUNET_CLIENT_Connection *client;
-
-  /**
    * Head of DLL of top-level activities.
    */
   struct TopLevelActivity *top_head;

Modified: gnunet/src/fs/fs_download.c
===================================================================
--- gnunet/src/fs/fs_download.c 2010-05-04 11:14:25 UTC (rev 11175)
+++ gnunet/src/fs/fs_download.c 2010-05-04 11:55:52 UTC (rev 11176)
@@ -1749,13 +1749,13 @@
                                 dc);  
   if (dc->serialization != NULL)
     GNUNET_FS_remove_sync_file_ (dc->h,
-                                (dc->parent != NULL) 
-                                ? "subdownloads" 
-                                : "download", 
+                                ( (dc->parent != NULL)  || (dc->search != 
NULL) )
+                                ? GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD 
+                                : GNUNET_FS_SYNC_PATH_MASTER_DOWNLOAD , 
                                 dc->serialization);
   if (GNUNET_YES == have_children)
     GNUNET_FS_remove_sync_dir_ (dc->h,                       
-                               "subdownloads",
+                               GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD,
                                dc->serialization);  
   pi.status = GNUNET_FS_STATUS_DOWNLOAD_STOPPED;
   GNUNET_FS_download_make_status_ (&pi, dc);

Modified: gnunet/src/fs/fs_publish.c
===================================================================
--- gnunet/src/fs/fs_publish.c  2010-05-04 11:14:25 UTC (rev 11175)
+++ gnunet/src/fs/fs_publish.c  2010-05-04 11:55:52 UTC (rev 11176)
@@ -1149,7 +1149,7 @@
     }
   if (pc->serialization != NULL) 
     {
-      GNUNET_FS_remove_sync_file_ (pc->h, "publish", pc->serialization);
+      GNUNET_FS_remove_sync_file_ (pc->h, GNUNET_FS_SYNC_PATH_MASTER_PUBLISH, 
pc->serialization);
       GNUNET_free (pc->serialization);
       pc->serialization = NULL;
     }

Modified: gnunet/src/fs/fs_search.c
===================================================================
--- gnunet/src/fs/fs_search.c   2010-05-04 11:14:25 UTC (rev 11175)
+++ gnunet/src/fs/fs_search.c   2010-05-04 11:55:52 UTC (rev 11176)
@@ -24,7 +24,6 @@
  * @author Christian Grothoff
  *
  * TODO:
- * - remove *directory* with search results upon completion
  * - centralize code that sprintf's the 'pbuf[32]' strings
  * - add support for pushing "already seen" information
  *   to FS service for bloomfilter (can wait)
@@ -38,8 +37,6 @@
 
 #define DEBUG_SEARCH GNUNET_NO
 
-
-
 /**
  * Fill in all of the generic fields for a search event and
  * call the callback.
@@ -527,8 +524,7 @@
   uu.type = sks;
   uu.data.sks.namespace = sc->uri->data.sks.namespace;
   uu.data.sks.identifier = GNUNET_strdup (id_update);
-  /* FIXME: should attach update search
-     to the individual result, not
+  /* FIXME: should attach update search to the individual result, not
      the entire SKS search! */
   search_start (sc->h,
                &uu,
@@ -956,6 +952,9 @@
          sm[i].type = htonl (GNUNET_BLOCK_TYPE_ANY);
          sm[i].anonymity_level = htonl (sc->anonymity);
          sm[i].query = sc->requests[i].query;
+         /* FIXME: should transmit hash codes of all already-known results 
here! 
+            (and if they do not fit, add another message with the same 
+            header and additional already-seen results!) */
        }
     }
   else
@@ -984,6 +983,9 @@
       GNUNET_CRYPTO_hash_xor (&idh,
                              &sm->target,
                              &sm->query);
+      /* FIXME: should transmit hash codes of all already-known results here!
+        (and if they do not fit, add another message with the same 
+        header and additional already-seen results!) */      
    }
   GNUNET_CLIENT_receive (sc->client,
                         &receive_results,
@@ -1177,8 +1179,59 @@
 }
 
 
+/**
+ * Freeze probes for the given search result.
+ *
+ * @param cls the global FS handle
+ * @param key the key for the search result (unused)
+ * @param value the search result to free
+ * @return GNUNET_OK
+ */
+static int
+search_result_freeze_probes (void *cls,
+                            const GNUNET_HashCode * key,
+                            void *value)
+{
+  struct GNUNET_FS_SearchContext *sc = cls;
+  struct GNUNET_FS_Handle *h = sc->h;
+  struct GNUNET_FS_SearchResult *sr = value;
 
+  if (sr->probe_ctx != NULL)
+    {
+      GNUNET_FS_download_stop (sr->probe_ctx, GNUNET_YES);    
+      sr->probe_ctx = NULL;
+    }
+  if (sr->probe_cancel_task != GNUNET_SCHEDULER_NO_TASK)
+    {
+      GNUNET_SCHEDULER_cancel (h->sched,
+                              sr->probe_cancel_task);  
+      sr->probe_cancel_task = GNUNET_SCHEDULER_NO_TASK;
+    }
+  return GNUNET_OK;
+}
+
+
 /**
+ * Resume probes for the given search result.
+ *
+ * @param cls the global FS handle
+ * @param key the key for the search result (unused)
+ * @param value the search result to free
+ * @return GNUNET_OK
+ */
+static int
+search_result_resume_probes (void *cls,
+                            const GNUNET_HashCode * key,
+                            void *value)
+{
+  struct GNUNET_FS_SearchResult *sr = value;
+
+  GNUNET_FS_search_start_probe_ (sr);
+  return GNUNET_OK;
+}
+
+
+/**
  * Signal suspend and free the given search result.
  *
  * @param cls the global FS handle
@@ -1309,7 +1362,9 @@
     GNUNET_CLIENT_disconnect (sc->client, GNUNET_NO);
   sc->client = NULL;
   GNUNET_FS_search_sync_ (sc);
-  // FIXME: should this freeze all active probes?
+  GNUNET_CONTAINER_multihashmap_iterate (sc->master_result_map,
+                                        &search_result_freeze_probes,
+                                        sc);
   pi.status = GNUNET_FS_STATUS_SEARCH_PAUSED;
   sc->client_info = GNUNET_FS_search_make_status_ (&pi, sc);
 }
@@ -1331,6 +1386,9 @@
   GNUNET_FS_search_sync_ (sc);
   pi.status = GNUNET_FS_STATUS_SEARCH_CONTINUED;
   sc->client_info = GNUNET_FS_search_make_status_ (&pi, sc);
+  GNUNET_CONTAINER_multihashmap_iterate (sc->master_result_map,
+                                        &search_result_resume_probes,
+                                        sc);
 }
 
 
@@ -1356,10 +1414,18 @@
   if (NULL != sr->download)
     {
       sr->download->search = NULL;
+      if (NULL != sr->download->serialization)
+       {
+         GNUNET_FS_remove_sync_file_ (sc->h,
+                                      GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD,
+                                      sr->download->serialization);
+         GNUNET_free (sr->download->serialization);
+         sr->download->serialization = NULL;
+       }
       pi.status = GNUNET_FS_STATUS_DOWNLOAD_LOST_PARENT;
       GNUNET_FS_download_make_status_ (&pi,
-                                      sr->download);
-      /* FIXME: promote download to top-level! */
+                                      sr->download);      
+      GNUNET_FS_download_sync_ (sr->download);
       sr->download = NULL;     
     }
   pi.status = GNUNET_FS_STATUS_SEARCH_RESULT_STOPPED;
@@ -1373,7 +1439,7 @@
       GNUNET_snprintf (pbuf,
                       sizeof (pbuf),
                       "%s%s%s",
-                      "search-results",
+                      GNUNET_FS_SYNC_PATH_SEARCH_RESULT,
                       DIR_SEPARATOR_STR,
                       sc->serialization);
       GNUNET_FS_remove_sync_file_ (sc->h,
@@ -1410,7 +1476,9 @@
     GNUNET_FS_end_top (sc->h, sc->top);
   if (sc->serialization != NULL)
     GNUNET_FS_remove_sync_file_ (sc->h,
-                                (sc->parent != NULL) ? "search-children" : 
"search",
+                                (sc->parent != NULL)  
+                                ? GNUNET_FS_SYNC_PATH_CHILD_SEARCH 
+                                : GNUNET_FS_SYNC_PATH_MASTER_SEARCH,
                                 sc->serialization);
   if (NULL != (parent = sc->parent))
     {
@@ -1426,7 +1494,9 @@
                                         &search_result_free,
                                         sc);
   if (had_result)
-    GNUNET_FS_remove_sync_dir_ (sc->h, "search-results", sc->serialization);
+    GNUNET_FS_remove_sync_dir_ (sc->h, 
+                               GNUNET_FS_SYNC_PATH_SEARCH_RESULT,
+                               sc->serialization);
   pi.status = GNUNET_FS_STATUS_SEARCH_STOPPED;
   sc->client_info = GNUNET_FS_search_make_status_ (&pi, sc);
   GNUNET_break (NULL == sc->client_info);

Modified: gnunet/src/fs/fs_unindex.c
===================================================================
--- gnunet/src/fs/fs_unindex.c  2010-05-04 11:14:25 UTC (rev 11175)
+++ gnunet/src/fs/fs_unindex.c  2010-05-04 11:55:52 UTC (rev 11176)
@@ -487,7 +487,7 @@
     }
   if (uc->serialization != NULL)
     {
-      GNUNET_FS_remove_sync_file_ (uc->h, "unindex", uc->serialization);
+      GNUNET_FS_remove_sync_file_ (uc->h, GNUNET_FS_SYNC_PATH_MASTER_UNINDEX, 
uc->serialization);
       GNUNET_free (uc->serialization);
       uc->serialization = NULL;
     }





reply via email to

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