#include <stdio.h>
static void
-_set_watched_dirs_internal (DBusList **directories)
+_set_watched_dirs_internal (BusContext *context,
+ DBusList **directories)
{
int new_wds[MAX_DIRS_TO_WATCH];
char *new_dirs[MAX_DIRS_TO_WATCH];
DBusList *link;
int i, j, wd;
+ /* Callers must provide a context, except during shutdown, at which
+ * point the list of directories must be empty. */
+ _dbus_assert (context != NULL || *directories == NULL);
+
for (i = 0; i < MAX_DIRS_TO_WATCH; i++)
{
new_wds[i] = -1;
link = _dbus_list_get_next_link (directories, link);
}
- if (link != NULL)
+ if (link != NULL && context != NULL)
{
- _dbus_warn ("Too many directories to watch them all, only watching first %d.", MAX_DIRS_TO_WATCH);
+ bus_context_log (context, DBUS_SYSTEM_LOG_WARNING,
+ "Too many directories to watch them all, only watching first %d.",
+ MAX_DIRS_TO_WATCH);
}
/* Look for directories in both the old and new sets, if
/* Not all service directories need to exist. */
if (errno != ENOENT)
{
- _dbus_warn ("Cannot setup inotify for '%s'; error '%s'", new_dirs[i], _dbus_strerror (errno));
+ /* We only have context == NULL during shutdown, at which
+ * point we are not adding directories */
+ _dbus_assert (context != NULL);
+ bus_context_log (context, DBUS_SYSTEM_LOG_WARNING,
+ "Cannot set up inotify for '%s': %s",
+ new_dirs[i], _dbus_strerror (errno));
goto out;
}
else
if (inotify_fd == -1)
return;
- _set_watched_dirs_internal (&empty);
+ _set_watched_dirs_internal (NULL, &empty);
if (watch != NULL)
{
#endif
if (inotify_fd < 0)
{
- _dbus_warn ("Cannot initialize inotify: %s", _dbus_strerror (errno));
+ bus_context_log (context, DBUS_SYSTEM_LOG_WARNING,
+ "Cannot initialize inotify: %s",
+ _dbus_strerror (errno));
goto out;
}
if (watch == NULL)
{
- _dbus_warn ("Unable to create inotify watch");
+ bus_context_log (context, DBUS_SYSTEM_LOG_WARNING,
+ "Unable to create inotify watch");
goto out;
}
if (!_dbus_loop_add_watch (loop, watch))
{
- _dbus_warn ("Unable to add reload watch to main loop");
+ bus_context_log (context, DBUS_SYSTEM_LOG_WARNING,
+ "Unable to add reload watch to main loop");
_dbus_watch_unref (watch);
watch = NULL;
goto out;
if (!_dbus_register_shutdown_func (_shutdown_inotify, NULL))
{
- _dbus_warn ("Unable to register shutdown func");
+ bus_context_log (context, DBUS_SYSTEM_LOG_WARNING,
+ "Unable to register shutdown func");
_dbus_watch_unref (watch);
watch = NULL;
goto out;
if (!_init_inotify (context))
return;
- _set_watched_dirs_internal (directories);
+ _set_watched_dirs_internal (context, directories);
}