2009-03-17 [colin] 3.7.1cvs18
authorColin Leroy <colin@colino.net>
Tue, 17 Mar 2009 07:58:20 +0000 (07:58 +0000)
committerColin Leroy <colin@colino.net>
Tue, 17 Mar 2009 07:58:20 +0000 (07:58 +0000)
* src/msgcache.c
* src/prefs_common.c
* src/prefs_common.h
* src/prefs_other.c
* src/common/prefs.c
Add preference for fsyncing metadata

ChangeLog
PATCHSETS
configure.ac
src/common/prefs.c
src/msgcache.c
src/prefs_common.c
src/prefs_common.h
src/prefs_other.c

index 54afb69ee2b049e91f453da177f995cb77391db3..19a84fa31ea5edee2e429ed9cfae51689f0ada54 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2009-03-17 [colin]     3.7.1cvs18
+
+       * src/msgcache.c
+       * src/prefs_common.c
+       * src/prefs_common.h
+       * src/prefs_other.c
+       * src/common/prefs.c
+               Add preference for fsyncing metadata
+
 2009-03-16 [paul]      3.7.1cvs17
 
        * src/prefs_customheader.c
index 6746f47c4717397b6afbb8be9242a258711dd89f..97c7ac74232e9a28eedd7f6dfc65688d83f28c9a 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.16.2.34 -r 1.16.2.35 src/prefs_customheader.c;  ) > 3.7.1cvs15.patchset
 ( cvs diff -u -r 1.16.2.35 -r 1.16.2.36 src/prefs_customheader.c;  ) > 3.7.1cvs16.patchset
 ( cvs diff -u -r 1.16.2.36 -r 1.16.2.37 src/prefs_customheader.c;  ) > 3.7.1cvs17.patchset
+( cvs diff -u -r 1.16.2.66 -r 1.16.2.67 src/msgcache.c;  cvs diff -u -r 1.204.2.188 -r 1.204.2.189 src/prefs_common.c;  cvs diff -u -r 1.103.2.122 -r 1.103.2.123 src/prefs_common.h;  cvs diff -u -r 1.1.2.36 -r 1.1.2.37 src/prefs_other.c;  cvs diff -u -r 1.5.2.16 -r 1.5.2.17 src/common/prefs.c;  ) > 3.7.1cvs18.patchset
index 28f88d7229637b446390129a7f3fc285cf688dff..ae8239747f0055d54aecfb632caafdccddbc7277 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=7
 MICRO_VERSION=1
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=17
+EXTRA_VERSION=18
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 5b420419e06b91b1905ccfc368144940877adc99..c2970a55d3baf4db2f0f6d7ed8c78fe9fb0b1a04 100644 (file)
@@ -101,6 +101,8 @@ PrefFile *prefs_write_open(const gchar *path)
        return pfile;
 }
 
+gboolean prefs_common_get_flush_metadata (void);
+
 /*!
  *\brief       Close and free preferences file
  *             Creates final file from temp, creates backup
@@ -164,7 +166,7 @@ gint prefs_file_close(PrefFile *pfile)
        tmppath = g_strconcat(path, ".tmp", NULL);
 
        
-       if (fsync(fileno(fp)) < 0) {
+       if (prefs_common_get_flush_metadata() && fsync(fileno(fp)) < 0) {
                FILE_OP_ERROR(tmppath, "fsync");
                fclose(fp);
                claws_unlink(tmppath);
index 798f95833644a5f1456cd56799de94a4eb55ac39..b34a47cf7245456eee6f2adf4be308b630e01ee7 100644 (file)
@@ -45,6 +45,7 @@
 #include "codeconv.h"
 #include "timing.h"
 #include "tags.h"
+#include "prefs_common.h"
 
 #ifdef HAVE_FWRITE_UNLOCKED
 #define SC_FWRITE fwrite_unlocked
@@ -1194,11 +1195,11 @@ gint msgcache_write(const gchar *cache_file, const gchar *mark_file, const gchar
                write_fps.error |= (fflush(write_fps.tags_fp) != 0);
 
        /* sync to filesystem */
-       if (write_fps.cache_fp)
+       if (prefs_common.flush_metadata && write_fps.cache_fp)
                write_fps.error |= (fsync(fileno(write_fps.cache_fp)) != 0);
-       if (write_fps.mark_fp)
+       if (prefs_common.flush_metadata && write_fps.mark_fp)
                write_fps.error |= (fsync(fileno(write_fps.mark_fp)) != 0);
-       if (write_fps.tags_fp)
+       if (prefs_common.flush_metadata && write_fps.tags_fp)
                write_fps.error |= (fsync(fileno(write_fps.tags_fp)) != 0);
 
        /* close files */
index b19c4510dd3ef949654f786041e8d97ad0c8f327..c5387dc9028ac27e4964b1fdbc8186e34a0d650e 100644 (file)
@@ -1129,6 +1129,9 @@ static PrefParam param[] = {
        {"inherit_folder_properties", "FALSE", &prefs_common.inherit_folder_props, P_BOOL,
         NULL, NULL, NULL},
 
+       {"flush_metadata", "TRUE", &prefs_common.flush_metadata, P_BOOL,
+        NULL, NULL, NULL},
+
        {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
 };
 
@@ -1572,6 +1575,11 @@ gboolean prefs_common_get_use_shred(void)
        return prefs_common.use_shred;
 }
 
+gboolean prefs_common_get_flush_metadata (void)
+{
+       return prefs_common.flush_metadata;
+}
+
 PrefsCommon *prefs_common_get_prefs(void)
 {
        return &prefs_common;
index 329250c6df2b573cc44c087015d6a1ab528c9879..13346401fca5e7a83666c4198ab2131ebdebc085 100644 (file)
@@ -389,10 +389,10 @@ struct _PrefsCommon
        gboolean enable_filtering_debug_folder_proc;
        gboolean enable_filtering_debug_pre_proc;
        gboolean enable_filtering_debug_post_proc;
-    gboolean filtering_debug_cliplog;
-    guint filtering_debug_loglength;
+       gboolean filtering_debug_cliplog;
+       guint filtering_debug_loglength;
 
-    gboolean confirm_on_exit;
+       gboolean confirm_on_exit;
        gboolean session_passwords;
        gboolean clean_on_exit;
        gboolean ask_on_clean;
@@ -478,10 +478,10 @@ struct _PrefsCommon
        
        gchar *print_paper_type;
        gint print_paper_orientation;
-  gint print_margin_top;
-  gint print_margin_bottom;
-  gint print_margin_left;
-  gint print_margin_right;
+       gint print_margin_top;
+       gint print_margin_bottom;
+       gint print_margin_left;
+       gint print_margin_right;
   
        gint print_use_color;
        gint print_use_collate;
@@ -495,6 +495,7 @@ struct _PrefsCommon
        gboolean use_shred;
        gboolean two_line_vert;
        gboolean inherit_folder_props;
+       gboolean flush_metadata;
 
 };
 
index d29a364dba5ac6d2b2aa3ccc746e075d72b15db0..94936088961a28b71d1c33899333507bbad7564a 100644 (file)
@@ -59,6 +59,8 @@ typedef struct _OtherPage
        GtkWidget *checkbtn_askonfilter;
        GtkWidget *checkbtn_use_shred;
        GtkWidget *checkbtn_real_time_sync;
+       GtkWidget *flush_metadata_faster_radiobtn;
+       GtkWidget *flush_metadata_safer_radiobtn;
 } OtherPage;
 
 static struct KeybindDialog {
@@ -452,6 +454,12 @@ static void prefs_other_create_widget(PrefsPage *_page, GtkWindow *window,
        GtkWidget *checkbtn_use_shred;
        GtkWidget *checkbtn_real_time_sync;
 
+       GtkWidget *frame_metadata;
+       GtkWidget *vbox_metadata;
+       GtkWidget *metadata_label;
+       GtkWidget *flush_metadata_faster_radiobtn;
+       GtkWidget *flush_metadata_safer_radiobtn;
+
        gchar *shred_binary = NULL;
        CLAWS_TIP_DECL();
 
@@ -503,6 +511,28 @@ static void prefs_other_create_widget(PrefsPage *_page, GtkWindow *window,
        g_signal_connect (G_OBJECT (button_keybind), "clicked",
                          G_CALLBACK (prefs_keybind_select), NULL);
 
+
+       vbox_metadata = gtkut_get_options_frame(vbox1, &frame_metadata, _("Metadata handling"));
+       metadata_label = gtk_label_new(_("Safer mode asks the OS to write metadata to disk directly;\n"
+                                        "it avoids data loss after crashes but can take some time."));
+       gtk_misc_set_alignment(GTK_MISC(metadata_label), 0, 0);
+       gtk_box_pack_start (GTK_BOX (vbox_metadata), metadata_label, FALSE, FALSE, 0);
+       flush_metadata_safer_radiobtn = gtk_radio_button_new_with_label(NULL, _("Safer"));
+       flush_metadata_faster_radiobtn = gtk_radio_button_new_with_label_from_widget(
+                                          GTK_RADIO_BUTTON(flush_metadata_safer_radiobtn), _("Faster"));
+       hbox1 = gtk_hbox_new (FALSE, 8);
+       gtk_widget_show (hbox1);
+       gtk_box_pack_start (GTK_BOX (vbox_metadata), hbox1, FALSE, FALSE, 0);
+       gtk_box_pack_start (GTK_BOX (hbox1), flush_metadata_safer_radiobtn, FALSE, FALSE, 0);
+       gtk_box_pack_start (GTK_BOX (hbox1), flush_metadata_faster_radiobtn, FALSE, FALSE, 0);
+       
+       if (prefs_common.flush_metadata)
+               gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(flush_metadata_safer_radiobtn), TRUE);
+       else
+               gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(flush_metadata_faster_radiobtn), TRUE);
+
+       gtk_widget_show_all(frame_metadata);
+
        hbox1 = gtk_hbox_new (FALSE, 8);
        gtk_widget_show (hbox1);
        gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
@@ -584,7 +614,8 @@ static void prefs_other_create_widget(PrefsPage *_page, GtkWindow *window,
        prefs_other->checkbtn_askonfilter = checkbtn_askonfilter;
        prefs_other->checkbtn_use_shred = checkbtn_use_shred;
        prefs_other->checkbtn_real_time_sync = checkbtn_real_time_sync;
-
+       prefs_other->flush_metadata_safer_radiobtn = flush_metadata_safer_radiobtn;
+       prefs_other->flush_metadata_faster_radiobtn = flush_metadata_faster_radiobtn;
        prefs_other->page.widget = vbox1;
 }
 
@@ -605,6 +636,8 @@ static void prefs_other_save(PrefsPage *_page)
                GTK_TOGGLE_BUTTON(page->checkbtn_warnqueued)); 
        prefs_common.io_timeout_secs = gtk_spin_button_get_value_as_int(
                GTK_SPIN_BUTTON(page->spinbtn_iotimeout));
+       prefs_common.flush_metadata = gtk_toggle_button_get_active(
+               GTK_TOGGLE_BUTTON(page->flush_metadata_safer_radiobtn));
        sock_set_io_timeout(prefs_common.io_timeout_secs);
 #ifdef HAVE_LIBETPAN
        imap_main_set_timeout(prefs_common.io_timeout_secs);