return 0;
r = restrict_ifaces_install_impl(u);
- fdset_close(crt->initial_restrict_ifaces_link_fds);
+ fdset_close(crt->initial_restrict_ifaces_link_fds, /* async= */ false);
return r;
}
return 0;
r = socket_bind_install_impl(u);
- fdset_close(crt->initial_socket_bind_link_fds);
+ fdset_close(crt->initial_socket_bind_link_fds, /* async= */ false);
return r;
}
barrier_set_role(&barrier, BARRIER_PARENT);
- fdset_close(fds);
+ fdset_close(fds, /* async= */ false);
fd_inner_socket_pair[1] = safe_close(fd_inner_socket_pair[1]);
fd_outer_socket_pair[1] = safe_close(fd_outer_socket_pair[1]);
#include "sd-daemon.h"
#include "alloc-util.h"
+#include "async.h"
#include "dirent-util.h"
#include "fd-util.h"
#include "fdset.h"
return 0;
}
-void fdset_close(FDSet *s) {
+void fdset_close(FDSet *s, bool async) {
void *p;
while ((p = set_steal_first(MAKE_SET(s)))) {
log_debug("Closing set fd %i (%s)", fd, strna(path));
}
- (void) close(fd);
+ if (async)
+ (void) asynchronous_close(fd);
+ else
+ (void) close(fd);
}
}
FDSet* fdset_free(FDSet *s) {
- fdset_close(s);
+ fdset_close(s, /* async= */ false);
+ set_free(MAKE_SET(s));
+ return NULL;
+}
+
+FDSet* fdset_free_async(FDSet *s) {
+ fdset_close(s, /* async= */ true);
set_free(MAKE_SET(s));
return NULL;
}
FDSet* fdset_new(void);
FDSet* fdset_free(FDSet *s);
+FDSet* fdset_free_async(FDSet *s);
int fdset_put(FDSet *s, int fd);
int fdset_consume(FDSet *s, int fd);
int fdset_steal_first(FDSet *fds);
-void fdset_close(FDSet *fds);
+void fdset_close(FDSet *fds, bool async);
#define _FDSET_FOREACH(fd, fds, i) \
for (Iterator i = ITERATOR_FIRST; ((fd) = fdset_iterate((fds), &i)) >= 0; )
DEFINE_TRIVIAL_CLEANUP_FUNC(FDSet*, fdset_free);
#define _cleanup_fdset_free_ _cleanup_(fdset_freep)
+
+DEFINE_TRIVIAL_CLEANUP_FUNC(FDSet*, fdset_free_async);