Get rid of the registry saving level hack.
Make periodic saving the default behavior.
This commit is contained in:
parent
04db693ea7
commit
dcab706fa0
@ -6,7 +6,6 @@ WINE REGISTRY Version 2
|
|||||||
;; grep -v "^;" ~/.wine/config | grep '.'
|
;; grep -v "^;" ~/.wine/config | grep '.'
|
||||||
|
|
||||||
[wine]
|
[wine]
|
||||||
"Windows" = "c:\\windows"
|
|
||||||
"GraphicsDriver" = "x11drv"
|
"GraphicsDriver" = "x11drv"
|
||||||
;"ShowDirSymlinks" = "1"
|
;"ShowDirSymlinks" = "1"
|
||||||
;"ShowDotFiles" = "1"
|
;"ShowDotFiles" = "1"
|
||||||
@ -146,10 +145,6 @@ WINE REGISTRY Version 2
|
|||||||
;"GlobalRegistryDir" = "/etc";
|
;"GlobalRegistryDir" = "/etc";
|
||||||
; Global registries (stored in /etc)
|
; Global registries (stored in /etc)
|
||||||
"LoadGlobalRegistryFiles" = "Y"
|
"LoadGlobalRegistryFiles" = "Y"
|
||||||
; Registry periodic save timeout in seconds
|
|
||||||
; "PeriodicSave" = "600"
|
|
||||||
; Save only modified keys
|
|
||||||
"SaveOnlyUpdatedKeys" = "Y"
|
|
||||||
|
|
||||||
[Clipboard]
|
[Clipboard]
|
||||||
"UsePrimary" = "0"
|
"UsePrimary" = "0"
|
||||||
|
@ -507,7 +507,6 @@ void SHELL_LoadRegistry( void )
|
|||||||
DWORD count;
|
DWORD count;
|
||||||
ULONG dispos;
|
ULONG dispos;
|
||||||
BOOL res;
|
BOOL res;
|
||||||
int all, period;
|
|
||||||
char tmp[1024];
|
char tmp[1024];
|
||||||
|
|
||||||
static const WCHAR MachineW[] = {'M','a','c','h','i','n','e',0};
|
static const WCHAR MachineW[] = {'M','a','c','h','i','n','e',0};
|
||||||
@ -520,8 +519,6 @@ void SHELL_LoadRegistry( void )
|
|||||||
'C','o','n','f','i','g','\\',
|
'C','o','n','f','i','g','\\',
|
||||||
'R','e','g','i','s','t','r','y',0};
|
'R','e','g','i','s','t','r','y',0};
|
||||||
static const WCHAR load_global_reg_filesW[] = {'L','o','a','d','G','l','o','b','a','l','R','e','g','i','s','t','r','y','F','i','l','e','s',0};
|
static const WCHAR load_global_reg_filesW[] = {'L','o','a','d','G','l','o','b','a','l','R','e','g','i','s','t','r','y','F','i','l','e','s',0};
|
||||||
static const WCHAR SaveOnlyUpdatedKeysW[] = {'S','a','v','e','O','n','l','y','U','p','d','a','t','e','d','K','e','y','s',0};
|
|
||||||
static const WCHAR PeriodicSaveW[] = {'P','e','r','i','o','d','i','c','S','a','v','e',0};
|
|
||||||
static const WCHAR GlobalRegistryDirW[] = {'G','l','o','b','a','l','R','e','g','i','s','t','r','y','D','i','r',0};
|
static const WCHAR GlobalRegistryDirW[] = {'G','l','o','b','a','l','R','e','g','i','s','t','r','y','D','i','r',0};
|
||||||
|
|
||||||
TRACE("(void)\n");
|
TRACE("(void)\n");
|
||||||
@ -597,32 +594,11 @@ void SHELL_LoadRegistry( void )
|
|||||||
load_wine_registry( hkey_local_machine, configfile );
|
load_wine_registry( hkey_local_machine, configfile );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* setup registry saving */
|
/* load home registries */
|
||||||
|
|
||||||
all = FALSE;
|
|
||||||
RtlInitUnicodeString( &nameW, SaveOnlyUpdatedKeysW );
|
|
||||||
if (!NtQueryValueKey( hkey_config, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &count ))
|
|
||||||
{
|
|
||||||
WCHAR *str = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data;
|
|
||||||
all = IS_OPTION_FALSE(str[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
period = 0;
|
|
||||||
RtlInitUnicodeString( &nameW, PeriodicSaveW );
|
|
||||||
if (!NtQueryValueKey( hkey_config, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &count ))
|
|
||||||
{
|
|
||||||
WCHAR *str = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data;
|
|
||||||
period = (int)strtolW(str, NULL, 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* load home registry and set saving level (0 for saving everything,
|
|
||||||
* 1 for saving only modified keys) */
|
|
||||||
|
|
||||||
SERVER_START_REQ( load_user_registries )
|
SERVER_START_REQ( load_user_registries )
|
||||||
{
|
{
|
||||||
req->hkey = hkey_current_user;
|
req->hkey = hkey_current_user;
|
||||||
req->saving = !all;
|
|
||||||
req->period = period * 1000;
|
|
||||||
wine_server_call( req );
|
wine_server_call( req );
|
||||||
}
|
}
|
||||||
SERVER_END_REQ;
|
SERVER_END_REQ;
|
||||||
|
@ -72,8 +72,7 @@ struct key
|
|||||||
int last_value; /* last in use value */
|
int last_value; /* last in use value */
|
||||||
int nb_values; /* count of allocated values in array */
|
int nb_values; /* count of allocated values in array */
|
||||||
struct key_value *values; /* values array */
|
struct key_value *values; /* values array */
|
||||||
short flags; /* flags */
|
unsigned int flags; /* flags */
|
||||||
short level; /* saving level */
|
|
||||||
time_t modif; /* last modification time */
|
time_t modif; /* last modification time */
|
||||||
struct list notify_list; /* list of notifications */
|
struct list notify_list; /* list of notifications */
|
||||||
};
|
};
|
||||||
@ -99,16 +98,11 @@ struct key_value
|
|||||||
/* the root of the registry tree */
|
/* the root of the registry tree */
|
||||||
static struct key *root_key;
|
static struct key *root_key;
|
||||||
|
|
||||||
/* keys saving level */
|
static const int save_period = 30000; /* delay between periodic saves (in ms) */
|
||||||
/* current_level is the level that is put into all newly created or modified keys */
|
|
||||||
/* saving_level is the minimum level that a key needs in order to get saved */
|
|
||||||
static int current_level;
|
|
||||||
static int saving_level;
|
|
||||||
|
|
||||||
static struct timeval next_save_time; /* absolute time of next periodic save */
|
|
||||||
static int save_period; /* delay between periodic saves (ms) */
|
|
||||||
static struct timeout_user *save_timeout_user; /* saving timer */
|
static struct timeout_user *save_timeout_user; /* saving timer */
|
||||||
|
|
||||||
|
static void set_periodic_save_timer(void);
|
||||||
|
|
||||||
/* information about where to save a registry branch */
|
/* information about where to save a registry branch */
|
||||||
struct save_branch_info
|
struct save_branch_info
|
||||||
{
|
{
|
||||||
@ -235,9 +229,9 @@ static void save_subkeys( const struct key *key, const struct key *base, FILE *f
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (key->flags & KEY_VOLATILE) return;
|
if (key->flags & KEY_VOLATILE) return;
|
||||||
/* save key if it has the proper level, and has either some values or no subkeys */
|
/* save key if it has either some values or no subkeys */
|
||||||
/* keys with no values but subkeys are saved implicitly by saving the subkeys */
|
/* keys with no values but subkeys are saved implicitly by saving the subkeys */
|
||||||
if ((key->level >= saving_level) && ((key->last_value >= 0) || (key->last_subkey == -1)))
|
if ((key->last_value >= 0) || (key->last_subkey == -1))
|
||||||
{
|
{
|
||||||
fprintf( f, "\n[" );
|
fprintf( f, "\n[" );
|
||||||
if (key != base) dump_path( key, base, f );
|
if (key != base) dump_path( key, base, f );
|
||||||
@ -419,7 +413,6 @@ static struct key *alloc_key( const WCHAR *name, time_t modif )
|
|||||||
key->nb_values = 0;
|
key->nb_values = 0;
|
||||||
key->last_value = -1;
|
key->last_value = -1;
|
||||||
key->values = NULL;
|
key->values = NULL;
|
||||||
key->level = current_level;
|
|
||||||
key->modif = modif;
|
key->modif = modif;
|
||||||
key->parent = NULL;
|
key->parent = NULL;
|
||||||
list_init( &key->notify_list );
|
list_init( &key->notify_list );
|
||||||
@ -473,7 +466,6 @@ static void touch_key( struct key *key, unsigned int change )
|
|||||||
struct key *k;
|
struct key *k;
|
||||||
|
|
||||||
key->modif = time(NULL);
|
key->modif = time(NULL);
|
||||||
key->level = max( key->level, current_level );
|
|
||||||
make_dirty( key );
|
make_dirty( key );
|
||||||
|
|
||||||
/* do notifications */
|
/* do notifications */
|
||||||
@ -1290,8 +1282,6 @@ static int load_value( struct key *key, const char *buffer, struct file_load_inf
|
|||||||
value->data = newptr;
|
value->data = newptr;
|
||||||
value->len = len;
|
value->len = len;
|
||||||
value->type = type;
|
value->type = type;
|
||||||
/* update the key level but not the modification time */
|
|
||||||
key->level = max( key->level, current_level );
|
|
||||||
make_dirty( key );
|
make_dirty( key );
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
@ -1472,6 +1462,9 @@ static void load_user_registries( struct key *key_current_user )
|
|||||||
load_init_registry_from_file( filename, key_current_user );
|
load_init_registry_from_file( filename, key_current_user );
|
||||||
|
|
||||||
free( filename );
|
free( filename );
|
||||||
|
|
||||||
|
/* start the periodic save timer */
|
||||||
|
set_periodic_save_timer();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* registry initialisation */
|
/* registry initialisation */
|
||||||
@ -1507,20 +1500,6 @@ void init_registry(void)
|
|||||||
free( filename );
|
free( filename );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* update the level of the parents of a key (only needed for the old format) */
|
|
||||||
static int update_level( struct key *key )
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
int max = key->level;
|
|
||||||
for (i = 0; i <= key->last_subkey; i++)
|
|
||||||
{
|
|
||||||
int sub = update_level( key->subkeys[i] );
|
|
||||||
if (sub > max) max = sub;
|
|
||||||
}
|
|
||||||
key->level = max;
|
|
||||||
return max;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* save a registry branch to a file */
|
/* save a registry branch to a file */
|
||||||
static void save_all_subkeys( struct key *key, FILE *f )
|
static void save_all_subkeys( struct key *key, FILE *f )
|
||||||
{
|
{
|
||||||
@ -1652,10 +1631,22 @@ done:
|
|||||||
static void periodic_save( void *arg )
|
static void periodic_save( void *arg )
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
save_timeout_user = NULL;
|
||||||
for (i = 0; i < save_branch_count; i++)
|
for (i = 0; i < save_branch_count; i++)
|
||||||
save_branch( save_branch_info[i].key, save_branch_info[i].path );
|
save_branch( save_branch_info[i].key, save_branch_info[i].path );
|
||||||
add_timeout( &next_save_time, save_period );
|
set_periodic_save_timer();
|
||||||
save_timeout_user = add_timeout_user( &next_save_time, periodic_save, 0 );
|
}
|
||||||
|
|
||||||
|
/* start the periodic save timer */
|
||||||
|
static void set_periodic_save_timer(void)
|
||||||
|
{
|
||||||
|
struct timeval next;
|
||||||
|
|
||||||
|
gettimeofday( &next, 0 );
|
||||||
|
add_timeout( &next, save_period );
|
||||||
|
if (save_timeout_user) remove_timeout_user( save_timeout_user );
|
||||||
|
save_timeout_user = add_timeout_user( &next, periodic_save, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* save the modified registry branches to disk */
|
/* save the modified registry branches to disk */
|
||||||
@ -1679,6 +1670,8 @@ void close_registry(void)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
if (save_timeout_user) remove_timeout_user( save_timeout_user );
|
||||||
|
save_timeout_user = NULL;
|
||||||
for (i = 0; i < save_branch_count; i++) release_object( save_branch_info[i].key );
|
for (i = 0; i < save_branch_count; i++) release_object( save_branch_info[i].key );
|
||||||
release_object( root_key );
|
release_object( root_key );
|
||||||
}
|
}
|
||||||
@ -1879,29 +1872,11 @@ DECL_HANDLER(load_user_registries)
|
|||||||
{
|
{
|
||||||
struct key *key;
|
struct key *key;
|
||||||
|
|
||||||
current_level = 1;
|
|
||||||
saving_level = req->saving;
|
|
||||||
|
|
||||||
if ((key = get_hkey_obj( req->hkey, KEY_SET_VALUE | KEY_CREATE_SUB_KEY )))
|
if ((key = get_hkey_obj( req->hkey, KEY_SET_VALUE | KEY_CREATE_SUB_KEY )))
|
||||||
{
|
{
|
||||||
load_user_registries( key );
|
load_user_registries( key );
|
||||||
release_object( key );
|
release_object( key );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set periodic save timer */
|
|
||||||
|
|
||||||
if (save_timeout_user)
|
|
||||||
{
|
|
||||||
remove_timeout_user( save_timeout_user );
|
|
||||||
save_timeout_user = NULL;
|
|
||||||
}
|
|
||||||
if ((save_period = req->period))
|
|
||||||
{
|
|
||||||
if (save_period < 10000) save_period = 10000; /* limit rate */
|
|
||||||
gettimeofday( &next_save_time, 0 );
|
|
||||||
add_timeout( &next_save_time, save_period );
|
|
||||||
save_timeout_user = add_timeout_user( &next_save_time, periodic_save, 0 );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add a registry key change notification */
|
/* add a registry key change notification */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user