SHA256
1
0
forked from pool/systemd
systemd/0008-core-correctly-unregister-PIDs-from-PID-hashtables.patch
Stephan Kulow bbba62be60 Accepting request 225408 from Base:System
- Add or port upstream bugfix patches: 
  0001-Fix-systemd-stdio-bridge-symlink.patch
  0002-execute-free-directory-path-if-we-fail-to-remove-it-.patch
  0003-Do-not-print-invalid-UTF-8-in-error-messages.patch
  0004-man-document-missing-options-of-systemd-run.patch
  0005-systemd-run-add-some-extra-safety-checks.patch
  0006-journal-assume-that-next-entry-is-after-previous-ent.patch
  0007-journal-forget-file-after-encountering-an-error.patch
  0008-core-correctly-unregister-PIDs-from-PID-hashtables.patch
  0009-logind-fix-reference-to-systemd-user-sessions.servic.patch
  0010-man-update-link-to-LSB.patch
  0011-man-systemd-bootchart-fix-spacing-in-command.patch
  0012-man-add-missing-comma.patch
  0013-units-Do-not-unescape-instance-name-in-systemd-backl.patch

- Add linker scripts as place holder of the old systemd shared
  libraries now all included in libsystemd.so  (bnc#867128)

- Make patch 1006-udev-always-rename-network.patch work again
  and add it again. 

- address missing owner functionality in systemd-tmpfiles (fate#314974)
  1022-systemd-tmpfiles-ownerkeep.patch

- Generate the bash completion files on the fly for the case of
  not having the package bash-completion around 
- Add or port upstream bugfix patches:
  0001-nspawn-fix-detection-of-missing-proc-self-loginuid.patch
  0002-cdrom_id-use-the-old-MMC-fallback.patch
  0003-journalctl-refuse-extra-arguments-with-verify-and-si.patch

OBS-URL: https://build.opensuse.org/request/show/225408
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/systemd?expand=0&rev=177
2014-03-11 08:24:11 +00:00

103 lines
3.2 KiB
Diff

From bd44e61b0480712ec5585ff7b0295362a5f9dd36 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Thu, 6 Mar 2014 02:19:42 +0100
Subject: [PATCH] core: correctly unregister PIDs from PID hashtables
---
src/core/unit.c | 42 ++++++++++++++++++------------------------
1 file changed, 18 insertions(+), 24 deletions(-)
diff --git src/core/unit.c src/core/unit.c
index 2437ee3..85250ca 100644
--- src/core/unit.c
+++ src/core/unit.c
@@ -1704,11 +1704,11 @@ int unit_watch_pid(Unit *u, pid_t pid) {
/* Watch a specific PID. We only support one or two units
* watching each PID for now, not more. */
- r = hashmap_ensure_allocated(&u->manager->watch_pids1, trivial_hash_func, trivial_compare_func);
+ r = set_ensure_allocated(&u->pids, trivial_hash_func, trivial_compare_func);
if (r < 0)
return r;
- r = set_ensure_allocated(&u->pids, trivial_hash_func, trivial_compare_func);
+ r = hashmap_ensure_allocated(&u->manager->watch_pids1, trivial_hash_func, trivial_compare_func);
if (r < 0)
return r;
@@ -1737,7 +1737,17 @@ void unit_unwatch_pid(Unit *u, pid_t pid) {
set_remove(u->pids, LONG_TO_PTR(pid));
}
-static int watch_pids_in_path(Unit *u, const char *path) {
+void unit_unwatch_all_pids(Unit *u) {
+ assert(u);
+
+ while (!set_isempty(u->pids))
+ unit_unwatch_pid(u, PTR_TO_LONG(set_first(u->pids)));
+
+ set_free(u->pids);
+ u->pids = NULL;
+}
+
+static int unit_watch_pids_in_path(Unit *u, const char *path) {
_cleanup_closedir_ DIR *d = NULL;
_cleanup_fclose_ FILE *f = NULL;
int ret = 0, r;
@@ -1775,7 +1785,7 @@ static int watch_pids_in_path(Unit *u, const char *path) {
if (!p)
return -ENOMEM;
- r = watch_pids_in_path(u, p);
+ r = unit_watch_pids_in_path(u, p);
if (r < 0 && ret >= 0)
ret = r;
}
@@ -1788,31 +1798,15 @@ static int watch_pids_in_path(Unit *u, const char *path) {
return ret;
}
-
int unit_watch_all_pids(Unit *u) {
assert(u);
- if (!u->cgroup_path)
- return -ENOENT;
-
/* Adds all PIDs from our cgroup to the set of PIDs we watch */
- return watch_pids_in_path(u, u->cgroup_path);
-}
-
-void unit_unwatch_all_pids(Unit *u) {
- Iterator i;
- void *e;
-
- assert(u);
-
- SET_FOREACH(e, u->pids, i) {
- hashmap_remove_value(u->manager->watch_pids1, e, u);
- hashmap_remove_value(u->manager->watch_pids2, e, u);
- }
+ if (!u->cgroup_path)
+ return -ENOENT;
- set_free(u->pids);
- u->pids = NULL;
+ return unit_watch_pids_in_path(u, u->cgroup_path);
}
void unit_tidy_watch_pids(Unit *u, pid_t except1, pid_t except2) {
@@ -1830,7 +1824,7 @@ void unit_tidy_watch_pids(Unit *u, pid_t except1, pid_t except2) {
continue;
if (!pid_is_unwaited(pid))
- set_remove(u->pids, e);
+ unit_unwatch_pid(u, pid);
}
}
--
1.7.9.2