1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-09 19:23:13 +02:00

core: add option weechat.look.save_config_with_fsync (closes #1083)

This makes the save of all configuration files about 20 to 200x slower
(according to the storage device speed); so this is disabled by default.
This commit is contained in:
Sébastien Helleu
2017-10-14 07:56:02 +02:00
parent d427fc0549
commit 0db48c7291
23 changed files with 157 additions and 14 deletions
+11
View File
@@ -2455,6 +2455,17 @@ config_file_write_internal (struct t_config_file *config_file,
if (fflush (config_file->file) != 0)
goto error;
/*
* ensure the file is really written on the storage device;
* this is disabled by default because it is really slow
* (about 20 to 200x slower)
*/
if (CONFIG_BOOLEAN(config_look_save_config_with_fsync))
{
if (fsync (fileno (config_file->file)) != 0)
goto error;
}
/* close temp file */
fclose (config_file->file);
config_file->file = NULL;
+12
View File
@@ -178,6 +178,7 @@ struct t_config_option *config_look_read_marker;
struct t_config_option *config_look_read_marker_always_show;
struct t_config_option *config_look_read_marker_string;
struct t_config_option *config_look_save_config_on_exit;
struct t_config_option *config_look_save_config_with_fsync;
struct t_config_option *config_look_save_layout_on_exit;
struct t_config_option *config_look_scroll_amount;
struct t_config_option *config_look_scroll_bottom_after_switch;
@@ -3347,6 +3348,17 @@ config_weechat_init_options ()
NULL, NULL, NULL,
&config_change_save_config_on_exit, NULL, NULL,
NULL, NULL, NULL);
config_look_save_config_with_fsync = config_file_new_option (
weechat_config_file, ptr_section,
"save_config_with_fsync", "boolean",
N_("use fsync to synchronize the configuration file with the storage "
"device (see man fsync); this is slower but should prevent any "
"data loss in case of power failure during the save of "
"configuration file"),
NULL, 0, 0, "off", NULL, 0,
NULL, NULL, NULL,
&config_change_save_config_on_exit, NULL, NULL,
NULL, NULL, NULL);
config_look_save_layout_on_exit = config_file_new_option (
weechat_config_file, ptr_section,
"save_layout_on_exit", "integer",
+1
View File
@@ -229,6 +229,7 @@ extern struct t_config_option *config_look_read_marker;
extern struct t_config_option *config_look_read_marker_always_show;
extern struct t_config_option *config_look_read_marker_string;
extern struct t_config_option *config_look_save_config_on_exit;
extern struct t_config_option *config_look_save_config_with_fsync;
extern struct t_config_option *config_look_save_layout_on_exit;
extern struct t_config_option *config_look_scroll_amount;
extern struct t_config_option *config_look_scroll_bottom_after_switch;