forked from pool/systemd
38fe6dfa6d
- Make baselibs.conf aware to use the appropiate %post and %postun scriptlets which includes pam-config (bnc#877674) - Add upstram patches 0001-core-close-socket-fds-asynchronously.patch 0002-logind-bring-polkit-policy-for-hibernate-in-line-wit.patch 0003-core-make-sure-to-serialize-jobs-for-all-units.patch - Add upstram patches 0001-replace-more-dup-by-F_DUPFD_CLOEXEC.patch 0002-pam_systemd-use-F_DUPFD_CLOEXEC-when-dupping-session.patch to avoid that in pam session unwanted file descriptors are inherited - Make baselibs.conf aware to use the appropiate %post and %postun scriptlets which includes pam-config (bnc#877674) - Add upstram patches 0001-core-close-socket-fds-asynchronously.patch 0002-logind-bring-polkit-policy-for-hibernate-in-line-wit.patch 0003-core-make-sure-to-serialize-jobs-for-all-units.patch - Add upstram patches 0001-replace-more-dup-by-F_DUPFD_CLOEXEC.patch 0002-pam_systemd-use-F_DUPFD_CLOEXEC-when-dupping-session.patch to avoid that in pam session unwanted file descriptors are inherited OBS-URL: https://build.opensuse.org/request/show/234299 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/systemd?expand=0&rev=187
75 lines
2.3 KiB
Diff
75 lines
2.3 KiB
Diff
Based on 574634bcacb01efe15ca2742effd461a5b7afb5f Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
|
Date: Tue, 13 May 2014 23:22:13 +0200
|
|
Subject: [PATCH] core: close socket fds asynchronously
|
|
|
|
http://lists.freedesktop.org/archives/systemd-devel/2014-April/018928.html
|
|
---
|
|
src/core/async.c | 22 ++++++++++++++++++++++
|
|
src/core/service.c | 5 +++--
|
|
2 files changed, 25 insertions(+), 2 deletions(-)
|
|
|
|
--- src/core/service.c
|
|
+++ src/core/service.c 2014-05-16 11:41:50.150735247 +0000
|
|
@@ -25,6 +25,7 @@
|
|
#include <unistd.h>
|
|
#include <sys/reboot.h>
|
|
|
|
+#include "async.h"
|
|
#include "manager.h"
|
|
#include "unit.h"
|
|
#include "service.h"
|
|
@@ -240,7 +241,7 @@ static void service_close_socket_fd(Serv
|
|
if (s->socket_fd < 0)
|
|
return;
|
|
|
|
- close_nointr_nofail(s->socket_fd);
|
|
+ asynchronous_close(s->socket_fd);
|
|
s->socket_fd = -1;
|
|
}
|
|
|
|
@@ -2767,7 +2768,7 @@ static int service_deserialize_item(Unit
|
|
else {
|
|
|
|
if (s->socket_fd >= 0)
|
|
- close_nointr_nofail(s->socket_fd);
|
|
+ asynchronous_close(s->socket_fd);
|
|
s->socket_fd = fdset_remove(fds, fd);
|
|
}
|
|
} else if (streq(key, "main-exec-status-pid")) {
|
|
--- src/core/async.c
|
|
+++ src/core/async.c 2014-05-07 09:40:35.000000000 +0000
|
|
@@ -24,6 +24,7 @@
|
|
|
|
#include "async.h"
|
|
#include "log.h"
|
|
+#include "util.h"
|
|
|
|
int asynchronous_job(void* (*func)(void *p), void *arg) {
|
|
pthread_attr_t a;
|
|
@@ -70,3 +71,24 @@ int asynchronous_sync(void) {
|
|
|
|
return asynchronous_job(sync_thread, NULL);
|
|
}
|
|
+
|
|
+static void *close_thread(void *p) {
|
|
+ close_nointr_nofail(PTR_TO_INT(p));
|
|
+ return NULL;
|
|
+}
|
|
+
|
|
+int asynchronous_close(int fd) {
|
|
+ int r;
|
|
+
|
|
+ /* This is supposed to behave similar to safe_close(), but
|
|
+ * actually invoke close() asynchronously, so that it will
|
|
+ * never block. Ideally the kernel would have an API for this,
|
|
+ * but it doesn't, so we work around it, and hide this as a
|
|
+ * far away as we can. */
|
|
+
|
|
+ r = asynchronous_job(close_thread, INT_TO_PTR(fd));
|
|
+ if (r < 0)
|
|
+ close_nointr_nofail(fd);
|
|
+
|
|
+ return -1;
|
|
+}
|