gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r3907 - in gnunet-gtk: . src/plugins/fs


From: grothoff
Subject: [GNUnet-SVN] r3907 - in gnunet-gtk: . src/plugins/fs
Date: Sat, 9 Dec 2006 21:56:55 -0800 (PST)

Author: grothoff
Date: 2006-12-09 21:56:51 -0800 (Sat, 09 Dec 2006)
New Revision: 3907

Modified:
   gnunet-gtk/TODO
   gnunet-gtk/src/plugins/fs/download.c
   gnunet-gtk/src/plugins/fs/search.c
   gnunet-gtk/src/plugins/fs/upload.c
Log:
fixing deadlock, more remaining


Modified: gnunet-gtk/TODO
===================================================================
--- gnunet-gtk/TODO     2006-12-10 05:35:55 UTC (rev 3906)
+++ gnunet-gtk/TODO     2006-12-10 05:56:51 UTC (rev 3907)
@@ -1,4 +1,6 @@
 0.7.1:
+- deadlock: FSUI_startDownload/Upload
+  must NOT be done in main thread [pre2]
 - fix addition of previews for uploads [pre2]
 - create directory from known file IDs [ medium ] [pre2]
   in Assemble Directory's Files Available/Selected
@@ -14,9 +16,6 @@
   + collection abortion
 
 ODD BUGS TO WATCH OUT FOR (seen, possibly fixed, hard to reproduce):
-- deadlock (download directory, download files in
-  directory, clear (multiple) completed downloads
-  => strange deadlock)
 - Assertion failed at download.c:264 in fs_download_started.
 
 0.7.2:

Modified: gnunet-gtk/src/plugins/fs/download.c
===================================================================
--- gnunet-gtk/src/plugins/fs/download.c        2006-12-10 05:35:55 UTC (rev 
3906)
+++ gnunet-gtk/src/plugins/fs/download.c        2006-12-10 05:56:51 UTC (rev 
3907)
@@ -99,7 +99,10 @@
   unsigned long long size;
   char * data;
   int fd;
+  char * fn;
   struct ECRS_MetaData * meta;
+  struct stat buf;
+  const char * f;
 
   if ( (list->is_directory != YES) ||
        (list->searchList == NULL) ||
@@ -107,18 +110,37 @@
        (! gtk_tree_row_reference_valid(list->searchViewRowReference)) )
     return;
 
-  if (OK != disk_file_size(ectx,
-                          list->filename,
-                          &size,
-                          YES))
+  if (0 != stat(list->filename,
+               &buf)) 
     return;
-  if (size == 0)
+  if (S_ISDIR(buf.st_mode)) {
+    fn = MALLOC(strlen(list->filename) + strlen(GNUNET_DIRECTORY_EXT) + 1);
+    strcpy(fn, list->filename);
+    if (fn[strlen(fn)-1] == '/') 
+      fn[strlen(fn)-1] = '\0';
+    strcat(fn, GNUNET_DIRECTORY_EXT);   
+    if (0 != stat(list->filename,
+                 &buf)) {
+      FREE(fn);
+      return;
+    }
+    f = fn;
+  } else {
+    fn = NULL;
+    f = list->filename;
+  }
+  size = buf.st_size;
+  if (size == 0) {
+    FREENONNULL(fn);
     return;
+  }
   fd = disk_file_open(ectx,
                      list->filename,
                      O_RDONLY);
-  if (fd == -1)
+  if (fd == -1) {
+    FREENONNULL(fn);
     return;
+  }
   data = MMAP(NULL,
              size,
              PROT_READ,
@@ -130,10 +152,12 @@
     GE_LOG_STRERROR_FILE(ectx,
                         GE_ERROR | GE_ADMIN | GE_BULK,
                         "mmap",
-                        list->filename);
+                        f);
     CLOSE(fd);
+    FREENONNULL(fn);
     return;
   }
+  FREENONNULL(fn);
   meta = NULL;
   ECRS_listDirectory(ectx,
                     data,
@@ -613,6 +637,7 @@
                          NULL)) {
     addLogEntry(_("Downloading `%s'"),
                idc_name);
+    /* FIXME! DEADLOCK! */
     FSUI_startDownload(ctx,
                       getSpinButtonValue(searchContext->searchXML,
                                          "downloadAnonymitySpinButton"),

Modified: gnunet-gtk/src/plugins/fs/search.c
===================================================================
--- gnunet-gtk/src/plugins/fs/search.c  2006-12-10 05:35:55 UTC (rev 3906)
+++ gnunet-gtk/src/plugins/fs/search.c  2006-12-10 05:56:51 UTC (rev 3907)
@@ -636,6 +636,7 @@
     }
     list = list->next;
   }
+  /* FIXME: deadlock! */
   FSUI_startSearch(ctx,
                   getSpinButtonValue(getMainXML(),
                                      "searchAnonymitySelectionSpinButton"),    
@@ -696,6 +697,7 @@
 void on_abortSearchButton_clicked_fs(GtkWidget * searchPage,
                                     GtkWidget * closeButton) {
   SearchList * list;
+  struct FCBC fcbc;
 
   list = search_head;
   while (list != NULL) {
@@ -704,8 +706,11 @@
     list = list->next;
   }
   GE_ASSERT(ectx, list != NULL);
-  FSUI_abortSearch(ctx,
-                  list->fsui_list);
+
+  fcbc.method = &FSUI_abortSearch;
+  fcbc.argument = list->fsui_list;
+  run_with_save_calls(&fsui_callback,
+                     &fcbc);
 }
 
 static void stopSearch(GtkTreeModel * model,

Modified: gnunet-gtk/src/plugins/fs/upload.c
===================================================================
--- gnunet-gtk/src/plugins/fs/upload.c  2006-12-10 05:35:55 UTC (rev 3906)
+++ gnunet-gtk/src/plugins/fs/upload.c  2006-12-10 05:56:51 UTC (rev 3907)
@@ -405,6 +405,7 @@
     gkeywordURI = ECRS_stringToUri(ectx,
                                   ECRS_URI_PREFIX
                                   ECRS_SEARCH_INFIX);
+    /* FIXME: DEADLOCK! */
     FSUI_startUpload(ctx,
                     filename,
                     (DirectoryScanCallback) &disk_directory_scan,





reply via email to

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