core: add new logic for services to store file descriptors in PID 1
With this change it is possible to send file descriptors to PID 1, via sd_pid_notify_with_fds() which PID 1 will store individually for each service, and pass via the usual fd passing logic on next invocation. This is useful for enable daemon reload schemes where daemons serialize their state to /run, push their fds into PID 1 and terminate, restoring their state on next start from the data in /run and passed in from PID 1. The fds are kept by PID 1 as long as no POLLHUP or POLLERR is seen on them, and the service they belong to are either not dead or failed, or have a job queued.
This commit is contained in:
+8
-3
@@ -27,25 +27,30 @@
|
||||
typedef struct FDSet FDSet;
|
||||
|
||||
FDSet* fdset_new(void);
|
||||
void fdset_free(FDSet *s);
|
||||
FDSet* fdset_free(FDSet *s);
|
||||
|
||||
int fdset_put(FDSet *s, int fd);
|
||||
int fdset_put_dup(FDSet *s, int fd);
|
||||
int fdset_consume(FDSet *s, int fd);
|
||||
|
||||
bool fdset_contains(FDSet *s, int fd);
|
||||
int fdset_remove(FDSet *s, int fd);
|
||||
|
||||
int fdset_new_fill(FDSet **_s);
|
||||
int fdset_new_listen_fds(FDSet **_s, bool unset);
|
||||
int fdset_new_array(FDSet **ret, int *fds, unsigned n_fds);
|
||||
int fdset_new_fill(FDSet **ret);
|
||||
int fdset_new_listen_fds(FDSet **ret, bool unset);
|
||||
|
||||
int fdset_cloexec(FDSet *fds, bool b);
|
||||
|
||||
int fdset_close_others(FDSet *fds);
|
||||
|
||||
unsigned fdset_size(FDSet *fds);
|
||||
bool fdset_isempty(FDSet *fds);
|
||||
|
||||
int fdset_iterate(FDSet *s, Iterator *i);
|
||||
|
||||
int fdset_steal_first(FDSet *fds);
|
||||
|
||||
#define FDSET_FOREACH(fd, fds, i) \
|
||||
for ((i) = ITERATOR_FIRST, (fd) = fdset_iterate((fds), &(i)); (fd) >= 0; (fd) = fdset_iterate((fds), &(i)))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user