gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r35841 - gnunet/src/fs gnunet/src/util gnunet-gtk/src/fs


From: gnunet
Subject: [GNUnet-SVN] r35841 - gnunet/src/fs gnunet/src/util gnunet-gtk/src/fs
Date: Fri, 29 May 2015 15:06:33 +0200

Author: grothoff
Date: 2015-05-29 15:06:33 +0200 (Fri, 29 May 2015)
New Revision: 35841

Modified:
   gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c
   gnunet/src/fs/fs_api.h
   gnunet/src/fs/fs_publish.c
   gnunet/src/fs/gnunet-publish.c
   gnunet/src/util/client.c
   gnunet/src/util/os_priority.c
Log:
fixing #3799: only unindex if DB operations succeeded previously in the first 
place, and when unindexing do proper shutdown handling

Modified: gnunet/src/fs/fs_api.h
===================================================================
--- gnunet/src/fs/fs_api.h      2015-05-29 13:01:33 UTC (rev 35840)
+++ gnunet/src/fs/fs_api.h      2015-05-29 13:06:33 UTC (rev 35841)
@@ -1325,6 +1325,12 @@
   int rid;
 
   /**
+   * Set to #GNUNET_YES if we were able to publish any block.
+   * (and thus unindexing on error might make sense).
+   */
+  int any_done;
+
+  /**
    * Set to #GNUNET_YES if all processing has completed.
    */
   int all_done;

Modified: gnunet/src/fs/fs_publish.c
===================================================================
--- gnunet/src/fs/fs_publish.c  2015-05-29 13:01:33 UTC (rev 35840)
+++ gnunet/src/fs/fs_publish.c  2015-05-29 13:06:33 UTC (rev 35841)
@@ -112,7 +112,8 @@
  * @param msg error message (or NULL)
  */
 static void
-ds_put_cont (void *cls, int success,
+ds_put_cont (void *cls,
+             int success,
             struct GNUNET_TIME_Absolute min_expiration,
             const char *msg)
 {
@@ -130,14 +131,19 @@
     pi.value.publish.specifics.error.message = pc->fi_pos->emsg;
     pc->fi_pos->client_info =
         GNUNET_FS_publish_make_status_ (&pi, pc, pc->fi_pos, 0);
-    if ((pc->fi_pos->is_directory != GNUNET_YES) &&
-        (pc->fi_pos->filename != NULL) &&
-        (pc->fi_pos->data.file.do_index == GNUNET_YES))
+    if ((GNUNET_YES != pc->fi_pos->is_directory) &&
+        (NULL != pc->fi_pos->filename) &&
+        (GNUNET_YES == pc->any_done) &&
+        (GNUNET_YES == pc->fi_pos->data.file.do_index))
     {
       /* run unindex to clean up */
-      GNUNET_FS_unindex_start (pc->h, pc->fi_pos->filename, NULL);
+      GNUNET_FS_unindex_start (pc->h,
+                               pc->fi_pos->filename,
+                               NULL);
     }
+    return;
   }
+  pc->any_done = GNUNET_YES;
   GNUNET_assert (NULL == pc->upload_task);
   pc->upload_task =
       GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND,
@@ -506,26 +512,40 @@
     odb.file_id = p->data.file.file_id;
     GNUNET_assert (pc->qre == NULL);
     pc->qre =
-        GNUNET_DATASTORE_put (pc->dsh, (p->is_directory == GNUNET_YES) ? 0 : 
pc->rid,
-                              &chk->query, sizeof (struct OnDemandBlock), &odb,
+        GNUNET_DATASTORE_put (pc->dsh,
+                              (p->is_directory == GNUNET_YES) ? 0 : pc->rid,
+                              &chk->query,
+                              sizeof (struct OnDemandBlock),
+                              &odb,
                               GNUNET_BLOCK_TYPE_FS_ONDEMAND,
-                              p->bo.content_priority, p->bo.anonymity_level,
-                              p->bo.replication_level, p->bo.expiration_time,
-                              -2, 1, GNUNET_CONSTANTS_SERVICE_TIMEOUT,
+                              p->bo.content_priority,
+                              p->bo.anonymity_level,
+                              p->bo.replication_level,
+                              p->bo.expiration_time,
+                              -2, 1,
+                              GNUNET_CONSTANTS_SERVICE_TIMEOUT,
                               &ds_put_cont, pc);
     return;
   }
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Publishing block `%s' for offset %llu with size %u\n",
-              GNUNET_h2s (&chk->query), (unsigned long long) offset,
+              GNUNET_h2s (&chk->query),
+              (unsigned long long) offset,
               (unsigned int) block_size);
   GNUNET_assert (pc->qre == NULL);
   pc->qre =
       GNUNET_DATASTORE_put (pc->dsh, (p->is_directory == GNUNET_YES) ? 0 : 
pc->rid,
-                            &chk->query, block_size, block, type,
-                            p->bo.content_priority, p->bo.anonymity_level,
-                            p->bo.replication_level, p->bo.expiration_time, -2,
-                            1, GNUNET_CONSTANTS_SERVICE_TIMEOUT, &ds_put_cont,
+                            &chk->query,
+                            block_size,
+                            block,
+                            type,
+                            p->bo.content_priority,
+                            p->bo.anonymity_level,
+                            p->bo.replication_level,
+                            p->bo.expiration_time,
+                            -2, 1,
+                            GNUNET_CONSTANTS_SERVICE_TIMEOUT,
+                            &ds_put_cont,
                             pc);
 }
 

Modified: gnunet/src/fs/gnunet-publish.c
===================================================================
--- gnunet/src/fs/gnunet-publish.c      2015-05-29 13:01:33 UTC (rev 35840)
+++ gnunet/src/fs/gnunet-publish.c      2015-05-29 13:06:33 UTC (rev 35841)
@@ -293,15 +293,29 @@
   case GNUNET_FS_STATUS_PUBLISH_STOPPED:
     GNUNET_break (NULL == pc);
     return NULL;
+  case GNUNET_FS_STATUS_UNINDEX_START:
+    FPRINTF (stderr,
+             "%s",
+             _("Starting cleanup after abort\n"));
+    return NULL;
   case GNUNET_FS_STATUS_UNINDEX_PROGRESS:
     return NULL;
   case GNUNET_FS_STATUS_UNINDEX_COMPLETED:
     FPRINTF (stderr,
              "%s",
-             _("Cleanup after abort complete.\n"));
+             _("Cleanup after abort completed.\n"));
+    GNUNET_FS_unindex_stop (info->value.unindex.uc);
     return NULL;
+  case GNUNET_FS_STATUS_UNINDEX_ERROR:
+    FPRINTF (stderr,
+             "%s",
+             _("Cleanup after abort failed.\n"));
+    GNUNET_FS_unindex_stop (info->value.unindex.uc);
+    return NULL;
   default:
-    FPRINTF (stderr, _("Unexpected status: %d\n"), info->status);
+    FPRINTF (stderr,
+             _("Unexpected status: %d\n"),
+             info->status);
     return NULL;
   }
   return "";                    /* non-null */
@@ -316,7 +330,7 @@
  * @param plugin_name name of the plugin that generated the meta data
  * @param type type of the meta data
  * @param format format of data
- * @param data_mime_type mime type of data
+ * @param data_mime_type mime type of @a data
  * @param data value of the meta data
  * @param data_size number of bytes in @a data
  * @return always 0

Modified: gnunet/src/util/client.c
===================================================================
--- gnunet/src/util/client.c    2015-05-29 13:01:33 UTC (rev 35840)
+++ gnunet/src/util/client.c    2015-05-29 13:06:33 UTC (rev 35841)
@@ -70,7 +70,7 @@
    * If we are re-trying and are delaying to do so,
    * handle to the scheduled task managing the delay.
    */
-  struct GNUNET_SCHEDULER_Task * reconnect_task;
+  struct GNUNET_SCHEDULER_Task *reconnect_task;
 
   /**
    * Timeout for the operation overall.
@@ -1108,6 +1108,7 @@
          "Transmission failed %u times, trying again in %s.\n",
          MAX_ATTEMPTS - th->attempts_left,
          GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES));
+    GNUNET_assert (NULL == th->th);
     GNUNET_assert (NULL == th->reconnect_task);
     th->reconnect_task =
         GNUNET_SCHEDULER_add_delayed (delay, &client_delayed_retry, th);
@@ -1191,6 +1192,7 @@
          GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES));
     client->th = th;
     GNUNET_assert (NULL == th->reconnect_task);
+    GNUNET_assert (NULL == th->th);
     th->reconnect_task =
         GNUNET_SCHEDULER_add_delayed (delay, &client_delayed_retry, th);
     return 0;
@@ -1259,6 +1261,7 @@
   client->th = th;
   if (NULL == client->connection)
   {
+    GNUNET_assert (NULL == th->th);
     GNUNET_assert (NULL == th->reconnect_task);
     th->reconnect_task =
         GNUNET_SCHEDULER_add_delayed (client->back_off,

Modified: gnunet/src/util/os_priority.c
===================================================================
--- gnunet/src/util/os_priority.c       2015-05-29 13:01:33 UTC (rev 35840)
+++ gnunet/src/util/os_priority.c       2015-05-29 13:06:33 UTC (rev 35841)
@@ -492,6 +492,7 @@
  *        (when they are non-NULL).
  * @param pipe_stdin pipe to use to send input to child process (or NULL)
  * @param pipe_stdout pipe to use to get output from child process (or NULL)
+ * @param pipe_stderr pipe to use for stderr for child process (or NULL)
  * @param lsocks array of listen sockets to dup systemd-style (or NULL);
  *         must be NULL on platforms where dup is not supported
  * @param filename name of the binary

Modified: gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c     2015-05-29 13:01:33 UTC 
(rev 35840)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c     2015-05-29 13:06:33 UTC 
(rev 35841)
@@ -4047,18 +4047,30 @@
     GNUNET_FS_GTK_unindex_handle_stop_ (info->value.unindex.cctx);
     return NULL;
   case GNUNET_FS_STATUS_UNINDEX_PROGRESS:
-    GNUNET_FS_GTK_unindex_handle_progress_ (info->value.unindex.cctx,
-                                           info->value.unindex.completed);
+    /* info->value.unindex.cctx is NULL if the unindexing was
+       triggered by a *failed* publishing operation; in this case
+       we don't do anything in the GUI but just clean up when
+       the operation is complete (or fails) */
+    if (NULL != info->value.unindex.cctx)
+      GNUNET_FS_GTK_unindex_handle_progress_ (info->value.unindex.cctx,
+                                              info->value.unindex.completed);
     return info->value.unindex.cctx;
   case GNUNET_FS_STATUS_UNINDEX_ERROR:
-    GNUNET_FS_GTK_unindex_handle_error_ (info->value.unindex.cctx,
-                                        
info->value.unindex.specifics.error.message);
+    if (NULL != info->value.unindex.cctx)
+      GNUNET_FS_GTK_unindex_handle_error_ (info->value.unindex.cctx,
+                                           
info->value.unindex.specifics.error.message);
+    else
+      GNUNET_FS_unindex_stop (info->value.unindex.uc);
     return info->value.unindex.cctx;
   case GNUNET_FS_STATUS_UNINDEX_COMPLETED:
-    GNUNET_FS_GTK_unindex_handle_completed_ (info->value.unindex.cctx);
+    if (NULL != info->value.unindex.cctx)
+      GNUNET_FS_GTK_unindex_handle_completed_ (info->value.unindex.cctx);
+    else
+      GNUNET_FS_unindex_stop (info->value.unindex.uc);
     return info->value.unindex.cctx;
   case GNUNET_FS_STATUS_UNINDEX_STOPPED:
-    GNUNET_FS_GTK_unindex_handle_stop_ (info->value.unindex.cctx);
+    if (NULL != info->value.unindex.cctx)
+      GNUNET_FS_GTK_unindex_handle_stop_ (info->value.unindex.cctx);
     return NULL;
   default:
     GNUNET_break (0);




reply via email to

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