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
This commit is contained in:
Colin Leroy 2009-03-17 07:58:20 +00:00
parent 4025a23349
commit c064ef0fde
8 changed files with 68 additions and 13 deletions

View file

@ -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

View file

@ -3757,3 +3757,4 @@
( 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

View 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=

View 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);

View 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 */

View 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;

View 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;
};

View 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);