}
static dbus_bool_t
+list_concat_new (DBusList **a,
+ DBusList **b,
+ DBusList **result)
+{
+ DBusList *link;
+
+ *result = NULL;
+
+ link = _dbus_list_get_first_link (a);
+ for (link = _dbus_list_get_first_link (a); link; link = _dbus_list_get_next_link (a, link))
+ {
+ if (!_dbus_list_append (result, link->data))
+ goto oom;
+ }
+ for (link = _dbus_list_get_first_link (b); link; link = _dbus_list_get_next_link (b, link))
+ {
+ if (!_dbus_list_append (result, link->data))
+ goto oom;
+ }
+
+ return TRUE;
+oom:
+ _dbus_list_clear (result);
+ return FALSE;
+}
+
+static dbus_bool_t
process_config_postinit (BusContext *context,
BusConfigParser *parser,
DBusError *error)
{
DBusHashTable *service_context_table;
+ DBusList *watched_dirs = NULL;
service_context_table = bus_config_parser_steal_service_context_table (parser);
if (!bus_registry_set_service_context_table (context->registry,
_dbus_hash_table_unref (service_context_table);
- /* Watch all conf directories */
- bus_set_watched_dirs (context, bus_config_parser_get_conf_dirs (parser));
+ /* We need to monitor both the configuration directories and directories
+ * containing .service files.
+ */
+ if (!list_concat_new (bus_config_parser_get_conf_dirs (parser),
+ bus_config_parser_get_service_dirs (parser),
+ &watched_dirs))
+ {
+ BUS_SET_OOM (error);
+ return FALSE;
+ }
+
+ bus_set_watched_dirs (context, &watched_dirs);
+
+ _dbus_list_clear (&watched_dirs);
return TRUE;
}
wd = inotify_add_watch (inotify_fd, new_dirs[i], IN_CLOSE_WRITE | IN_DELETE | IN_MOVED_TO | IN_MOVED_FROM);
if (wd < 0)
{
- _dbus_warn ("Cannot setup inotify for '%s'; error '%s'\n", new_dirs[i], _dbus_strerror (errno));
- goto out;
+ /* Not all service directories need to exist. */
+ if (errno != ENOENT)
+ {
+ _dbus_warn ("Cannot setup inotify for '%s'; error '%s'\n", new_dirs[i], _dbus_strerror (errno));
+ goto out;
+ }
+ else
+ {
+ new_wds[i] = -1;
+ new_dirs[i] = NULL;
+ continue;
+ }
}
new_wds[i] = wd;
new_dirs[i] = _dbus_strdup (new_dirs[i]);
* we may need to sleep.
*/
fd = open (new_dirs[i], O_RDONLY);
- if (fd < 0)
+ if (fd < 0)
{
- _dbus_warn ("Cannot open directory '%s'; error '%s'\n", new_dirs[i], _dbus_strerror (errno));
- goto out;
- }
+ if (errno != ENOENT)
+ {
+ _dbus_warn ("Cannot open directory '%s'; error '%s'\n", new_dirs[i], _dbus_strerror (errno));
+ goto out;
+ }
+ else
+ {
+ new_fds[i] = -1;
+ new_dirs[i] = NULL;
+ continue;
+ }
+ }
EV_SET (&ev, fd, EVFILT_VNODE, EV_ADD | EV_ENABLE | EV_CLEAR,
NOTE_DELETE | NOTE_EXTEND | NOTE_WRITE | NOTE_RENAME, 0, 0);