activation: Put activation directories in an ordered list
authorSimon McVittie <simon.mcvittie@collabora.co.uk>
Fri, 17 Feb 2017 12:21:46 +0000 (12:21 +0000)
committerSimon McVittie <simon.mcvittie@collabora.co.uk>
Mon, 20 Feb 2017 12:52:31 +0000 (12:52 +0000)
commit6980c17220da2446614f55f7898edbf5bf2af65a
tree3538c08435b2373b25613ab2e13bbe9b37583e0d
parent84c8403197c95272a7112eb1fddb84ad2b7474be
activation: Put activation directories in an ordered list

There are two circumstances in which we load .service files. The first
is bus_activation_reload(), which is given an ordered list of directory
paths, and reads each one in its correct order, highest-precedence
first (normally ~/.local/share > /usr/local/share > /usr/share). This
seems correct.

However, if we are asked to activate a service for which we do not know
of a .service file, we opportunistically reload the search path and
try again, in the hope that it was recently-installed and not yet
discovered by inotify. Prior to this commit, this would iterate through
the hash table in arbitrary hash order, so we might load a service
from /usr/share even though it was meant to be masked by a
higher-priority service file in ~/.local/share or /usr/local/share.

Before I add more elements to the search path, we should make sure
it is always searched in the expected order.

We do not actually make use of the hash table's faster-than-O(n)
lookup by directory path anywhere, so there is no point in using a
hash table, and we can safely replace it with an ordered data structure.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=99825
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
bus/activation.c