1 /* SPDX-License-Identifier: LGPL-2.1+ */
4 #include "nscd-flush.h"
7 static int on_nscd_cache_flush_event(sd_event_source
*s
, void *userdata
) {
8 /* Let's ask glibc's nscd daemon to flush its caches. We request this for the three database machines may show
9 * up in: the hosts database (for resolvable machine names) and the user and group databases (for the user ns
12 (void) nscd_flush_cache(STRV_MAKE("passwd", "group", "hosts"));
16 int manager_enqueue_nscd_cache_flush(Manager
*m
) {
21 if (!m
->nscd_cache_flush_event
) {
22 r
= sd_event_add_defer(m
->event
, &m
->nscd_cache_flush_event
, on_nscd_cache_flush_event
, m
);
24 return log_error_errno(r
, "Failed to allocate NSCD cache flush event: %m");
26 sd_event_source_set_description(m
->nscd_cache_flush_event
, "nscd-cache-flush");
29 r
= sd_event_source_set_enabled(m
->nscd_cache_flush_event
, SD_EVENT_ONESHOT
);
31 m
->nscd_cache_flush_event
= sd_event_source_unref(m
->nscd_cache_flush_event
);
32 return log_error_errno(r
, "Failed to enable NSCD cache flush event: %m");