gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r3420 - GNUnet/src/applications/fs/fsui


From: grothoff
Subject: [GNUnet-SVN] r3420 - GNUnet/src/applications/fs/fsui
Date: Fri, 29 Sep 2006 13:15:19 -0700 (PDT)

Author: grothoff
Date: 2006-09-29 13:15:17 -0700 (Fri, 29 Sep 2006)
New Revision: 3420

Modified:
   GNUnet/src/applications/fs/fsui/downloadtest.c
   GNUnet/src/applications/fs/fsui/fsui.h
   GNUnet/src/applications/fs/fsui/unindex.c
Log:
fixing unindex

Modified: GNUnet/src/applications/fs/fsui/downloadtest.c
===================================================================
--- GNUnet/src/applications/fs/fsui/downloadtest.c      2006-09-29 05:23:26 UTC 
(rev 3419)
+++ GNUnet/src/applications/fs/fsui/downloadtest.c      2006-09-29 20:15:17 UTC 
(rev 3420)
@@ -55,8 +55,8 @@
   SNPRINTF(fn,
           strlen(name) + 40,
           "%s%sFSUITEST%u",
+          name,
           DIR_SEPARATOR_STR,
-          name,
           i);
   FREE(name);
   return fn;
@@ -188,7 +188,9 @@
   struct ECRS_MetaData * meta;
   struct ECRS_URI * kuri = NULL;
   struct GC_Configuration * cfg;
-  struct FSUI_SearchList * search;
+  struct FSUI_SearchList * search = NULL;
+  struct FSUI_UnindexList * unindex = NULL;
+  struct FSUI_UploadList * upload = NULL;
 
   cfg = GC_create_C_impl();
   if (-1 == GC_parse_configuration(cfg,
@@ -230,17 +232,17 @@
                                  2,
                                  (const char**)keywords);
   waitForEvent = FSUI_upload_complete;
-  CHECK(NULL !=
-       FSUI_startUpload(ctx,
-                        fn,
-                        0,
-                        0,
-                        YES,
-                        NO,
-                        NO,
-                        meta,
-                        kuri,
-                        kuri));
+  upload = FSUI_startUpload(ctx,
+                           fn,
+                           0,
+                           0,
+                           YES,
+                           NO,
+                           NO,
+                           meta,
+                           kuri,
+                           kuri);
+  CHECK(upload != NULL);
   ECRS_freeUri(kuri);
   kuri = NULL;
   ECRS_freeMetaData(meta);
@@ -249,7 +251,9 @@
     prog++;
     CHECK(prog < 1000);
     PTHREAD_SLEEP(50 * cronMILLIS);
+    printf("U\n");
   }
+  FSUI_stopUpload(ctx, upload);
   SNPRINTF(keyword,
           40,
           "%s %s %s",
@@ -289,17 +293,20 @@
 #endif
       suspendRestart--;
     }
+    printf("R\n");
   }
   CHECK(OK == FSUI_stopSearch(ctx,
                              search));
   waitForEvent = FSUI_unindex_complete;
-  CHECK(NULL != FSUI_unindex(ctx, fn));
+  unindex = FSUI_unindex(ctx, fn);
+  CHECK(unindex != NULL);
   prog = 0;
   while (lastEvent != FSUI_unindex_complete) {
     prog++;
     CHECK(prog < 1000);
     PTHREAD_SLEEP(50 * cronMILLIS);
     CHECK(lastEvent != FSUI_unindex_error);
+    printf("D\n");
   }
   CHECK(lastEvent == FSUI_unindex_complete);
   /* END OF TEST CODE */
@@ -309,13 +316,15 @@
     FREE(fn);
   }
   if (ctx != NULL) {
-    FSUI_stopSearch(ctx,
-                   search);
-    fn = makeName(43);
+    if (search != NULL)
+      FSUI_stopSearch(ctx,
+                     search);
+    if (unindex != NULL)
+      FSUI_stopUnindex(ctx,
+                      unindex);
     if (download != NULL)
       FSUI_stopDownload(ctx,
                        download);
-    FREE(fn);
     FSUI_stop(ctx);
   }
   if (uri != NULL)

Modified: GNUnet/src/applications/fs/fsui/fsui.h
===================================================================
--- GNUnet/src/applications/fs/fsui/fsui.h      2006-09-29 05:23:26 UTC (rev 
3419)
+++ GNUnet/src/applications/fs/fsui/fsui.h      2006-09-29 20:15:17 UTC (rev 
3420)
@@ -327,6 +327,8 @@
 
   cron_t start_time;
 
+  int force_termination;
+
 } FSUI_UnindexList;
 
 /**

Modified: GNUnet/src/applications/fs/fsui/unindex.c
===================================================================
--- GNUnet/src/applications/fs/fsui/unindex.c   2006-09-29 05:23:26 UTC (rev 
3419)
+++ GNUnet/src/applications/fs/fsui/unindex.c   2006-09-29 20:15:17 UTC (rev 
3420)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2001, 2002, 2003, 2004, 2005 Christian Grothoff (and other 
contributing authors)
+     (C) 2001, 2002, 2003, 2004, 2005, 2006 Christian Grothoff (and other 
contributing authors)
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -50,6 +50,13 @@
                &event);
 }
 
+static int tt(void * cls) {
+  FSUI_UnindexList * utc = cls;
+  if (utc->force_termination == YES)
+    return SYSERR;
+  return OK;
+}
+
 /**
  * Thread that does the unindex.
  */
@@ -63,8 +70,8 @@
                         utc->filename,
                         &progressCallback,
                         utc,
-                        NULL,
-                        NULL);
+                        &tt,
+                        utc);
   if (ret == OK) {
     event.type = FSUI_unindex_complete;
     if (OK != disk_file_size(utc->ctx->ectx,
@@ -113,6 +120,7 @@
   utc->ctx = ctx;
   utc->filename = STRDUP(filename);
   utc->start_time = get_time();
+  utc->force_termination = NO;
   utc->handle = PTHREAD_CREATE(&unindexThread,
                               utc,
                               32 * 1024);
@@ -131,4 +139,53 @@
   return utc;
 }
 
+
+/**
+ * Abort a deletion operation.
+ *
+ * @return SYSERR if no such unindex is pending
+ */
+int FSUI_stopUnindex(struct FSUI_Context * ctx,
+                    struct FSUI_UnindexList * dl) {
+  FSUI_UnindexList * prev;
+  struct GE_Context * ectx;
+  unsigned int backup;
+  void * unused;
+
+  ectx = ctx->ectx;
+  if (dl == NULL) {
+    GE_BREAK(ectx, 0);
+    return SYSERR;
+  }
+  GE_LOG(ectx,
+        GE_DEBUG | GE_REQUEST | GE_USER,
+        "FSUI_stopUnindex called.\n");
+  MUTEX_LOCK(ctx->lock);
+  prev = ctx->unindexOperations;
+  while ( (prev != dl) &&
+         (prev != NULL) &&
+         (prev->next != dl) ) 
+    prev = prev->next;
+  if (prev == NULL) {
+    MUTEX_UNLOCK(ctx->lock);
+    GE_LOG(ectx, 
+          GE_DEBUG | GE_REQUEST | GE_USER,
+          "FSUI_stopUnindex failed to locate deletion operation.\n");
+    return SYSERR;
+  }
+  if (prev == dl) {
+    ctx->unindexOperations = dl->next;
+  } else {
+    prev->next = dl->next;
+  }
+  MUTEX_UNLOCK(ctx->lock);
+  dl->force_termination = YES;
+  PTHREAD_STOP_SLEEP(dl->handle);
+  PTHREAD_JOIN(dl->handle,
+              &unused);
+  FREE(dl->filename);
+  FREE(dl);
+  return OK;
+}
+
 /* end of unindex.c */





reply via email to

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