summaryrefslogtreecommitdiff
path: root/engine
Commit message (Collapse)AuthorAgeFilesLines
* engine: fix race in match rule addingRyan Lortie2014-02-211-7/+11
| | | | | | | | | | | | | Due to the usual way async in dconf works, we can start getting replies immediately (without returning to the mainloop). For this reason, we must be sure that we do not modify the OutstandingWatch structure at any point after we've issued even one call because the results may already be coming in. For this reason, we must add up the 'pending' count in a separate loop run before we start making the calls. https://bugzilla.gnome.org/show_bug.cgi?id=724929
* file-db: don't install match rules on no busRyan Lortie2014-02-111-8/+15
| | | | | | | file-db databases don't have an associated D-Bus bus type, so don't try to install match rules for them. https://bugzilla.gnome.org/show_bug.cgi?id=723553
* Updated FSF's addressDaniel Mustieles2014-01-3111-33/+11
|
* engine: add support for 'file-db'Ryan Lortie2014-01-135-7/+92
| | | | | | | | This is a new database type that is simply an absolute path to a gvdb anywhere on the filesystem. Change notification is not supported. This is intended to be used by things like gdm that wish to install databases (somewhere in /usr) as part of the software.
* profiles: allow profiles in XDG_DATA_DIRSRyan Lortie2014-01-131-11/+55
| | | | | If we can't find a given profile in /etc then look for it in the XDG_DATA_DIRS.
* engine: reject junk signalsRyan Lortie2013-11-271-0/+36
| | | | | | | Check incoming signals for non-sense before bubbling them up to higher layers. This will avoid dconf APIs feeding invalid key names to applications during change notifications in the case that we're fed invalid data over D-Bus.
* engine: fix a case of variable shadowingRyan Lortie2013-11-271-3/+3
| | | | | | | | | Testing uncovered a case of a shadowed variable in the signal handling code of the engine: the object path on which a signal arrived was being shadowed by the 'path' variable used when deserialising the content of the signal, causing the signal to fail to be delivered. Rename the D-Bus path variable to 'object_path' to avoid the issue.
* engine: filter change signals properlyRyan Lortie2013-11-271-2/+23
| | | | | | | | | | | Testing revealed that we were transmitting any change signal that came in from the bus up to user code, even if the engine in question was not interested in receiving the signal. This is a problem in the case that two DConfClient objects exist for different profiles. In that case, we'd get crosstalk between the subscriptions that each client had made and change notifications would appear in both clients even if the change only affected one.
* engine: add support for WritabilityNotifyRyan Lortie2013-11-262-4/+24
| | | | | Wire through WritabilityNotify signals from the engine. This has been unimplemented for a very long time...
* engine: add 'profile' argument to constructorRyan Lortie2013-11-262-4/+6
| | | | | | | Allow specifying a profile when calling dconf_engine_new(). This will allow us to avoid setting/unsetting the DCONF_PROFILE environment in testcases from contexts where other threads may be reading from the environment.
* engine: allow NULL handleRyan Lortie2013-11-251-1/+4
| | | | | | We use a NULL handle in case we don't care about the return value. In that case, we certainly don't care about the return type either, so use NULL for expected_type in this case.
* engine: issue warnings once per sourceRyan Lortie2013-11-253-6/+5
| | | | | | | | | | | | | | | | | On failure to open a gvdb file in /etc/dconf/db we would issue a warning once per process -- even if multiple files were missing. This was enforced using a static variable. An unfortunate side effect of this global state is that the testcases couldn't reliably know if to expect the error or not. This issue was side-stepped by running any cases that may emit the warning under a fork, but that made it difficult to debug some of the cases. Rework the backends not to use global state for the flag and instead store it per-source. Remove a use of g_test_trap_fork().
* engine: fix locking bugRyan Lortie2013-11-251-0/+2
| | | | | | | Make sure we actually acquire the sources lock on entry to dconf_engine_read_user_value(). Uncovered during testing.
* Add DCONF_ERROR error domainRyan Lortie2013-11-252-8/+1
| | | | | | | | | Add a DCONF_ERROR error domain with associated DConfError enum type. Use this instead of the adhoc approach that we've been taking up to this point. https://bugzilla.gnome.org/show_bug.cgi?id=704638
* engine: restructure a bit to improve testabilityRyan Lortie2013-11-252-12/+17
| | | | | | | | | Don't use the access() system call from the service source because this bypasses the mocking layer in the testsuite. Use gvdb_table_new() instead. This also avoids an extra syscall. Also: change a couple of criticals to warnings because they are not programmer errors.
* Add missing "config.h" include everywhereRyan Lortie2013-11-246-0/+12
| | | | We ought to be including this from each .c file.
* GSettings: implement _read_user_value()Ryan Lortie2013-10-282-0/+50
| | | | | | | | | | | | Implement g_settings_backend_read_user_value() in DConfSettingsBackend. This will help us support g_settings_get_user_value() properly. We add a new engine API to support this as well. It takes a read_through queue, even though we don't bother using that from DConfSettingsBackend. https://bugzilla.gnome.org/show_bug.cgi?id=668233
* engine: seal changesets on changesRyan Lortie2013-06-251-0/+4
| | | | | | | | | | | When we do change operations, make sure we seal our DConfChangeset before sharing it between threads. This will ensure it gets sealed in only one thread instead of being implicitly sealed in two different threads at the same time when each of them calls dconf_changeset_describe(). https://bugzilla.gnome.org/show_bug.cgi?id=703073
* Use G_LOG_DOMAIN in all library componentsRyan Lortie2013-02-211-1/+1
|
* engine, gsettings: prevent empty changesetsRyan Lortie2013-02-111-0/+11
| | | | | | | | We should not send empty changesets to the service so just ignore them when we get them. This now means that an empty 'dconf load' will not send any D-Bus messages (and will not cause D-Bus activation).
* docs/comments: make some corrections/updatesRyan Lortie2013-02-111-3/+3
| | | | | Many fixes for typos but also some adjustments for the recent refactoring (particularly updating HACKING).
* engine: accept out-of-order error reply messagesRyan Lortie2013-01-241-3/+20
| | | | | | | | | | | | | | | Due to a quirk of the implementation of the D-Bus daemon (see upstream bug https://bugs.freedesktop.org/show_bug.cgi?id=59780 for details) error messages can arrive out of sequence with repsect to the order of the method calls that they are in reply to. This may or may not be a violation of the strict-ordering principle of D-Bus (which does not actually appear to be written into the spec) but either way, we should dial down our assumptions about ordering since the D-Bus implementation that everyone is using does not currently work this way. https://bugzilla.gnome.org/show_bug.cgi?id=687120
* engine: only Init the service when neededRyan Lortie2013-01-111-3/+7
| | | | | Instead of calling Init() blindly on startup for any service-db, only do it if the file is missing when we go to open it.
* engine: add a new database type: "service-db"Ryan Lortie2013-01-094-1/+94
| | | | | | | | | | | | | | service-db databases are based on a gvdb in the user runtime dir maintained by the dconf-service. On startup, the client will send an Init message to the service to ensure that the database is properly initialised. After that, things are pretty much the same except that the values are read from the file in the runtime dir instead of from the home directory. We also drop the "shm" signalling mechanism for this case and instead use the same invalidation trick that system databases use (ie: overwriting the old gvdb header after writing the new file).
* adjust to new gvdb APIsRyan Lortie2012-11-091-4/+4
|
* engine/: drop DConfChangesetListRyan Lortie2012-10-024-45/+6
| | | | | | It's really just a GQueue... https://bugzilla.gnome.org/show_bug.cgi?id=685316
* engine: improve robustness of profile parsingRyan Lortie2012-07-192-20/+43
| | | | | | | | | Checking for 'u' or 's' is really insanely silly from a robustness standpoint. Ensure that we properly have "user-db:" or "system-db:" and that a non-empty database name is given, warning if not. This was specifically causing annoying problems with the profile file that gdm was installing, so add a copy of that file to our testcases.
* engine: fix dconf_engine_list() with empty dbRyan Lortie2012-07-151-0/+3
| | | | | | | | If we opened an empty database file (like on first login) and did a 'dconf list' on it then we would crash (due to accessing the GVDB without checking for NULL). Add a check.
* engine: bring back origin_tag logicRyan Lortie2012-07-152-6/+10
| | | | | | | | | The GSettings backend still wants to use this and it does us no harm to have it on the engine API (which is only visible internally). Adjust the various consumers of the engine to the new API. Thanks to Rui Matos for reminding me about this...
* engine: fix arguments in fast watch race caseRyan Lortie2012-07-151-1/+3
| | | | | | In the case we do a fast watch and hit the race condition of a change occuring before our watch is established we need to emit a change signal on "/". The arguments for that were incorrect, so fix them.
* engine/: don't check for writability on resetRyan Lortie2012-07-121-1/+4
| | | | | Resetting keys should absolutely always succeed, so don't check for key writability in that case.
* DConfEngineSource: return FALSE from NULL refreshRyan Lortie2012-07-121-1/+14
| | | | | | | | | | In the case that we call dconf_engine_source_refresh() on a source that had a NULL database and the result is that we still have a NULL database, return FALSE. This will prevent the unnecessary bumping of the state counter when there was really no change. This happens in the case of a missing system database file.
* DConfEngineSource: remove the external init callRyan Lortie2012-07-123-13/+2
| | | | | Always do init as part of the process of dconf_engine_source_new() to avoid the consumer from having to call it for themselves.
* DConfEngineUserSource: don't open on initRyan Lortie2012-07-121-5/+0
| | | | | Don't open the database file on _init(). This makes us match the system source better.
* engine/: source init can never failRyan Lortie2012-07-125-12/+7
| | | | | Stop returning a boolean here (since all of the sources always returned TRUE all the time anyway).
* engine/: fix refcounting errorRyan Lortie2012-07-121-1/+1
| | | | | | | | | | | The new supposedly-threadsafe implementation of refcounting in the engine still had a bug in it: in the event that we were going to remove the last reference and we discovered that the refcount was not 1 after taking the lock, we would return (under the assumption that someone else had increased the count). This is the wrong thing to do. No matter what, we need to drop our reference -- instead of return, we should goto again.
* Remove workaround for GCC's obnoxious behaviourRyan Lortie2012-07-111-7/+2
| | | | The workaround is in GLib now, so we don't have to do it.
* dbus test: add function to initialise for testingRyan Lortie2012-07-111-0/+2
| | | | | | | We were hardcoding g_type_init() in the D-Bus testcase because the GDBus backend depended on that happening. That is not true for the libdbus-1 backend, so split it out into a separate function implemeneted by the backend.
* engine: add dconf_call_handle_get_expected_type()Ryan Lortie2012-07-112-0/+8
| | | | | | We were storing the expected type of the reply in the call handle already but not really doing anything with it. Provide an API to access it.
* Reimplement sync() functionalityRyan Lortie2012-07-102-1/+42
| | | | | | | | | Add dconf_engine_sync() that does the same thing as the code in the GSettings backend used to do, in a cleaner way. Update the GSettings backend to use the new call. Add a new call to DConfClient wrapping the engine call as well.
* engine: fix dconf_engine_unref() thread safetyRyan Lortie2012-07-101-31/+17
| | | | | | | | | | | | | | | | | | | | | | | There was a very slim race condition in the implementation of dconf_engine_unref(). In order to check if the engine should be freed (to avoid double-freeing in two separate threads) the code was checking if the engine was still in the global list of engines. It is possible, however, that this thread could have unrefed the engine at exactly the same time as another thread, that thread won the race and freed the engine (removing it from the list) and then a third thread created another engine at the same time and it happened to have the same pointer address as the engine that was just freed. In this case, the first engine would still see "itself" in the global list and free again. It's unlikely that this would ever happen in the real world but the regression tests picked it up. The new implementation should avoid that issue by not depending on the engine finding itself in the list as part of the decision about if it should be freed or not.
* clean up C compiler warningsRyan Lortie2012-07-081-1/+1
| | | | | | | Disable C compiler warnings entirely while building Vala code. Fix-up a couple of legitimate issues plus one false-positive (in service.c).
* massive Makefile reorganisationRyan Lortie2012-07-086-9/+10
| | | | | | | | | | Clean up the Makefiles and make them as similar as possible. Move CFLAGS to a common point of definition and stop using -I so much. Replace the 'dbus stub' with libdconf-mock.a in tests/. Fill in some stubs for future mock code for shm and gvdb (just to get things compiling for now).
* user source: change approach to shmRyan Lortie2012-07-081-12/+3
| | | | | | | | | | Use dconf_shm_is_flagged() instead of direct access. Change the semantics of what happens when we fail to open the shm file. We used to refuse to initialise at all in that case -- now we initialise but will try again every time to reopen ourselves. The error case will now be slower but closer to the correct behaviour.
* clean up and factor out the 'shm' codeRyan Lortie2012-07-082-57/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* engine/: mark some structs 'extern' in a headerRyan Lortie2012-07-081-2/+2
| | | | | | | | | | | | This should have been done in the first place but it went unnoticed because the linker has an odd habit of permitting two structs with the same name to be defined. It only became a problem when optimisation was turned on and GCC noticed that nobody was writing to one particular copy of that struct and assumed that its contents would always be all-zeros (which is an assumption that later became untrue once the linker had done its strange magic).
* profile parser: firm up and document semanticsRyan Lortie2012-07-085-31/+126
| | | | | | | | | Clean up the profile parser, firming up the semantics of exactly what happens in all cases. Document it. There are now no more cases of aborting due to failures caused while opening, parsing or initialising the profile. Lines of arbitrary length are also supported.
* sources: don't leak bus name and object pathRyan Lortie2012-07-061-0/+2
| | | | On finalize, we weren't freeing these properly.
* user source: use threadsafe init for shmdirRyan Lortie2012-07-061-2/+2
| | | | | | | | Otherwise it's possible for multiple threads to initialise it at the same time. Each thread will come up with the same value anyway, but it's a string, so we will leak all but one of them.
* fix various 'make distcheck' issuesRyan Lortie2012-07-061-1/+3
|