diff options
author | Ryan Lortie <desrt@desrt.ca> | 2012-07-08 14:41:33 -0400 |
---|---|---|
committer | Ryan Lortie <desrt@desrt.ca> | 2012-07-08 14:52:03 -0400 |
commit | dd9c1a0cad35082724bba59235af031246c06ce5 (patch) | |
tree | d87fae1e6ce41e19ca1b8506424c1801faf8cc7a /service/dconf-writer.c | |
parent | 4228ef3194fff11dcdcdce0b61aa0474fffb066d (diff) | |
download | dconf-dd9c1a0cad35082724bba59235af031246c06ce5.tar.gz |
clean up and factor out the 'shm' code
Remove the shm code from the engine and the service and put it in a
separate convenience library in shm/.
Remove the vestigial shmdir weirdness from the service (since shmdir is
now always relative to XDG_RUNTIME_DIR and has been for some time).
The purpose of this is so that dconf-engine can be properly unit-tested.
dconf-engine now has five points of contact with the world (excluding
the users of the engine themselves):
- the DCONF_PROFILE environment variable
- fopen() of profile files
- shm
- gvdb
- dbus
The environment variable is quite easily controlled. fopen() is
intercepted in the engine testcase with a interpose of the libc symbol.
With this commit now each of dbus, gvdb and shm are implemented in
separate utility modules that can be mocked from the testcases.
Diffstat (limited to 'service/dconf-writer.c')
-rw-r--r-- | service/dconf-writer.c | 29 |
1 files changed, 4 insertions, 25 deletions
diff --git a/service/dconf-writer.c b/service/dconf-writer.c index 4218977..6c44c40 100644 --- a/service/dconf-writer.c +++ b/service/dconf-writer.c @@ -23,6 +23,7 @@ #include "dconf-rebuilder.h" #include "dconf-state.h" +#include "dconf-shm.h" #include <stdlib.h> #include <unistd.h> @@ -35,7 +36,6 @@ struct OPAQUE_TYPE__DConfWriter DConfState *state; gchar *name; gchar *path; - gchar *shm; }; /* Each element must only contain the ASCII characters "[A-Z][a-z][0-9]_" @@ -77,26 +77,6 @@ dconf_writer_list_existing (void) return (gchar **) g_ptr_array_free (array, FALSE); } -static void -dconf_writer_touch_shm (DConfWriter *writer) -{ - gchar one = 1; - gint fd; - - fd = open (writer->shm, O_WRONLY); - - if (fd >= 0) - { - write (fd, &one, sizeof one); - close (fd); - - unlink (writer->shm); - } - - else if (errno != ENOENT) - unlink (writer->shm); -} - gboolean dconf_writer_write (DConfWriter *writer, const gchar *name, @@ -106,7 +86,7 @@ dconf_writer_write (DConfWriter *writer, if (!dconf_rebuilder_rebuild (writer->path, "", &name, &value, 1, error)) return FALSE; - dconf_writer_touch_shm (writer); + dconf_shm_flag (writer->name); return TRUE; } @@ -123,7 +103,7 @@ dconf_writer_write_many (DConfWriter *writer, values, n_items, error)) return FALSE; - dconf_writer_touch_shm (writer); + dconf_shm_flag (writer->name); return TRUE; } @@ -146,7 +126,7 @@ dconf_writer_change (DConfWriter *writer, if (!dconf_rebuilder_rebuild (writer->path, prefix, keys, values, n_items, error)) return FALSE; - dconf_writer_touch_shm (writer); + dconf_shm_flag (writer->name); return TRUE; } @@ -172,7 +152,6 @@ dconf_writer_new (DConfState *state, writer = g_slice_new (DConfWriter); writer->state = state; writer->path = g_build_filename (state->db_dir, name, NULL); - writer->shm = g_build_filename (state->shm_dir, name, NULL); writer->name = g_strdup (name); return writer; |