Manager *m = ASSERT_PTR(userdata);
_cleanup_(pidref_done) PidRef pidref = PIDREF_NULL;
struct ucred ucred;
- _cleanup_free_ char *buf = NULL;
_cleanup_(fdset_free_asyncp) FDSet *fds = NULL;
int r;
return 0;
}
- r = notify_recv_with_fds(m->notify_fd, &buf, &ucred, &pidref, &fds);
+ _cleanup_strv_free_ char **tags = NULL;
+ r = notify_recv_with_fds_strv(m->notify_fd, &tags, &ucred, &pidref, &fds);
if (r == -EAGAIN)
return 0;
if (r < 0)
* socket. */
return r;
- _cleanup_strv_free_ char **tags = strv_split_newlines(buf);
- if (!tags) {
- log_oom_warning();
- return 0;
- }
-
/* Possibly a barrier fd, let's see. */
if (manager_process_barrier_fd(tags, fds)) {
log_debug("Received barrier notification message from PID " PID_FMT ".", pidref.pid);
assert(userdata);
_cleanup_(pidref_done) PidRef sender_pid = PIDREF_NULL;
- _cleanup_free_ char *buf = NULL;
- r = notify_recv(fd, &buf, /* ret_ucred= */ NULL, &sender_pid);
+ _cleanup_strv_free_ char **tags = NULL;
+ r = notify_recv_strv(fd, &tags, /* ret_ucred= */ NULL, &sender_pid);
if (r == -EAGAIN)
return 0;
if (r < 0)
return 0;
}
- _cleanup_strv_free_ char **tags = strv_split(buf, "\n\r");
- if (!tags)
- return log_oom();
-
if (DEBUG_LOGGING) {
_cleanup_free_ char *joined = strv_join(tags, " ");
#include "fd-util.h"
#include "notify-recv.h"
#include "socket-util.h"
+#include "strv.h"
+#include "user-util.h"
int notify_recv_with_fds(
int fd,
return 0;
}
+
+int notify_recv_with_fds_strv(
+ int fd,
+ char ***ret_list,
+ struct ucred *ret_ucred,
+ PidRef *ret_pidref,
+ FDSet **ret_fds) {
+
+ _cleanup_(pidref_done) PidRef pidref = PIDREF_NULL;
+ _cleanup_(fdset_free_asyncp) FDSet *fds = NULL;
+ struct ucred ucred = UCRED_INVALID;
+ _cleanup_free_ char *text = NULL;
+ int r;
+
+ r = notify_recv_with_fds(
+ fd,
+ ret_list ? &text : NULL,
+ ret_ucred ? &ucred : NULL,
+ ret_pidref ? &pidref : NULL,
+ ret_fds ? &fds : NULL);
+ if (r < 0)
+ return r;
+
+ if (ret_list) {
+ char **l = strv_split_newlines(text);
+ if (!l) {
+ log_oom_warning();
+ return -EAGAIN;
+ }
+
+ *ret_list = l;
+ }
+
+ if (ret_ucred)
+ *ret_ucred = ucred;
+ if (ret_pidref)
+ *ret_pidref = TAKE_PIDREF(pidref);
+ if (ret_fds)
+ *ret_fds = TAKE_PTR(fds);
+
+ return 0;
+}
static inline int notify_recv(int fd, char **ret_text, struct ucred *ret_ucred, PidRef *ret_pidref) {
return notify_recv_with_fds(fd, ret_text, ret_ucred, ret_pidref, NULL);
}
+
+int notify_recv_with_fds_strv(
+ int fd,
+ char ***ret_list,
+ struct ucred *ret_ucred,
+ PidRef *ret_pidref,
+ FDSet **ret_fds);
+
+static inline int notify_recv_strv(int fd, char ***ret_list, struct ucred *ret_ucred, PidRef *ret_pidref) {
+ return notify_recv_with_fds_strv(fd, ret_list, ret_ucred, ret_pidref, NULL);
+}