[systemd-commits] 10 commits - 99-systemd.rules dbus-job.c dbus-unit.c job.c manager.c mount.c service.c socket.c systemadm.vala systemctl.vala unit.c util.c util.h
Lennart Poettering
lennart at kemper.freedesktop.org
Sat May 15 19:34:11 PDT 2010
99-systemd.rules | 2
dbus-job.c | 4 +
dbus-unit.c | 4 +
job.c | 5 +
manager.c | 20 +++----
mount.c | 2
service.c | 2
socket.c | 2
systemadm.vala | 146 ++++++++++++++++++++++++++++++++++++++++++++++++-------
systemctl.vala | 31 +++++++++++
unit.c | 7 ++
util.c | 21 +++++++
util.h | 2
13 files changed, 213 insertions(+), 35 deletions(-)
New commits:
commit ed42e037bc93f8f6b54ee7b0b692c1200d2f4903
Author: Lennart Poettering <lennart at poettering.net>
Date: Sun May 16 04:31:42 2010 +0200
systemadm: add UI for loading new units
diff --git a/systemadm.vala b/systemadm.vala
index 6ea464f..b5985fa 100644
--- a/systemadm.vala
+++ b/systemadm.vala
@@ -66,6 +66,9 @@ public class MainWindow : Window {
private Button reload_button;
private Button cancel_button;
+ private Entry unit_load_entry;
+ private Button unit_load_button;
+
private Button server_snapshot_button;
private Button server_reload_button;
@@ -126,7 +129,19 @@ public class MainWindow : Window {
unit_type_combo_box.set_active(1);
unit_type_combo_box.changed += unit_type_changed;
- server_snapshot_button = new Button.with_mnemonic("Take _Snapshot");
+ unit_load_entry = new Entry();
+ unit_load_button = new Button.with_mnemonic("_Load");
+ unit_load_button.set_sensitive(false);
+
+ unit_load_entry.changed += on_unit_load_entry_changed;
+ unit_load_entry.activate += on_unit_load;
+ unit_load_button.clicked += on_unit_load;
+
+ Gtk.Alignment unit_load_button_alignment = new Gtk.Alignment(0.5f, 0.5f, 1f, 1f);
+ unit_load_button_alignment.right_padding = 24;
+ unit_load_button_alignment.add(unit_load_button);
+
+ server_snapshot_button = new Button.with_mnemonic("Take S_napshot");
server_reload_button = new Button.with_mnemonic("Reload _Configuration");
server_snapshot_button.clicked += on_server_snapshot;
@@ -134,6 +149,8 @@ public class MainWindow : Window {
type_hbox.pack_end(server_snapshot_button, false, true, 0);
type_hbox.pack_end(server_reload_button, false, true, 0);
+ type_hbox.pack_end(unit_load_button_alignment, false, true, 0);
+ type_hbox.pack_end(unit_load_entry, false, true, 0);
unit_model = new ListStore(7, typeof(string), typeof(string), typeof(string), typeof(string), typeof(string), typeof(string), typeof(Unit));
job_model = new ListStore(6, typeof(string), typeof(string), typeof(string), typeof(string), typeof(Job), typeof(uint32));
@@ -768,11 +785,39 @@ public class MainWindow : Window {
}
}
+ public void on_unit_load() {
+ try {
+ var path = manager.load_unit(unit_load_entry.get_text());
+
+ Unit u = bus.get_object(
+ "org.freedesktop.systemd1",
+ path,
+ "org.freedesktop.systemd1.Unit") as Unit;
+
+ var m = new MessageDialog(this,
+ DialogFlags.DESTROY_WITH_PARENT,
+ MessageType.INFO,
+ ButtonsType.CLOSE,
+ "Unit available as id %s", u.id);
+ m.title = "Unit";
+ m.run();
+ m.destroy();
+
+ } catch (DBus.Error e) {
+ show_error(e.message);
+ }
+ }
+
+ public void on_unit_load_entry_changed() {
+ unit_load_button.set_sensitive(unit_load_entry.get_text() != "");
+ }
+
public void show_error(string e) {
var m = new MessageDialog(this,
DialogFlags.DESTROY_WITH_PARENT,
MessageType.ERROR,
ButtonsType.CLOSE, "%s", e);
+ m.title = "Error";
m.run();
m.destroy();
}
commit 949061f0d6f5ae8aecb5e1fc711f336e4ba48ca2
Author: Lennart Poettering <lennart at poettering.net>
Date: Sun May 16 04:31:07 2010 +0200
manager: add newly created units to gc queue
diff --git a/manager.c b/manager.c
index 81af07b..688d9fa 100644
--- a/manager.c
+++ b/manager.c
@@ -1582,6 +1582,7 @@ int manager_load_unit_prepare(Manager *m, const char *name, const char *path, Un
unit_add_to_load_queue(ret);
unit_add_to_dbus_queue(ret);
+ unit_add_to_gc_queue(ret);
if (_ret)
*_ret = ret;
commit 413d6313d82ef4f50a4186cfadd8a6b1e4e65164
Author: Lennart Poettering <lennart at poettering.net>
Date: Sun May 16 04:30:45 2010 +0200
manager: don't dispatch load queue if we don't have to
diff --git a/manager.c b/manager.c
index 89b210d..81af07b 100644
--- a/manager.c
+++ b/manager.c
@@ -1563,7 +1563,7 @@ int manager_load_unit_prepare(Manager *m, const char *name, const char *path, Un
if ((ret = manager_get_unit(m, name))) {
*_ret = ret;
- return 0;
+ return 1;
}
if (!(ret = unit_new(m)))
@@ -1590,7 +1590,6 @@ int manager_load_unit_prepare(Manager *m, const char *name, const char *path, Un
}
int manager_load_unit(Manager *m, const char *name, const char *path, Unit **_ret) {
- Unit *ret;
int r;
assert(m);
@@ -1598,13 +1597,13 @@ int manager_load_unit(Manager *m, const char *name, const char *path, Unit **_re
/* This will load the service information files, but not actually
* start any services or anything. */
- if ((r = manager_load_unit_prepare(m, name, path, &ret)) < 0)
+ if ((r = manager_load_unit_prepare(m, name, path, _ret)) != 0)
return r;
manager_dispatch_load_queue(m);
if (_ret)
- *_ret = unit_follow_merge(ret);
+ *_ret = unit_follow_merge(*_ret);
return 0;
}
commit dd28669fc734941fffbba233ed69243a36daa0ac
Author: Lennart Poettering <lennart at poettering.net>
Date: Sun May 16 03:58:16 2010 +0200
systemadm: update UI when jobs/units change
diff --git a/systemadm.vala b/systemadm.vala
index 92ee503..6ea464f 100644
--- a/systemadm.vala
+++ b/systemadm.vala
@@ -297,6 +297,8 @@ public class MainWindow : Window {
i.unit_path,
"org.freedesktop.systemd1.Unit") as Unit;
+ u.changed += on_unit_changed;
+
unit_model.append(out iter);
unit_model.set(iter,
0, i.id,
@@ -322,6 +324,8 @@ public class MainWindow : Window {
i.job_path,
"org.freedesktop.systemd1.Job") as Job;
+ j.changed += on_job_changed;
+
job_model.append(out iter);
job_model.set(iter,
0, "%u".printf(i.id),
@@ -542,11 +546,7 @@ public class MainWindow : Window {
}
}
- public void on_unit_new(string id, ObjectPath path) {
- Unit u = bus.get_object(
- "org.freedesktop.systemd1",
- path,
- "org.freedesktop.systemd1.Unit") as Unit;
+ public void update_unit_iter(TreeIter iter, string id, Unit u) {
string t = "";
Unit.JobLink jl = u.job;
@@ -560,8 +560,6 @@ public class MainWindow : Window {
t = j.job_type;
}
- TreeIter iter;
- unit_model.append(out iter);
unit_model.set(iter,
0, id,
1, u.description,
@@ -572,16 +570,22 @@ public class MainWindow : Window {
6, u);
}
- public void on_job_new(uint32 id, ObjectPath path) {
- Job j = bus.get_object(
+ public void on_unit_new(string id, ObjectPath path) {
+ Unit u = bus.get_object(
"org.freedesktop.systemd1",
path,
- "org.freedesktop.systemd1.Job") as Job;
+ "org.freedesktop.systemd1.Unit") as Unit;
+
+ u.changed += on_unit_changed;
TreeIter iter;
- job_model.append(out iter);
+ unit_model.append(out iter);
+ update_unit_iter(iter, id, u);
+ }
+
+ public void update_job_iter(TreeIter iter, uint32 id, Job j) {
job_model.set(iter,
- 0, "%u".printf(j.id),
+ 0, "%u".printf(id),
1, j.unit.id,
2, "â %s".printf(j.job_type),
3, j.state,
@@ -589,6 +593,19 @@ public class MainWindow : Window {
5, id);
}
+ public void on_job_new(uint32 id, ObjectPath path) {
+ Job j = bus.get_object(
+ "org.freedesktop.systemd1",
+ path,
+ "org.freedesktop.systemd1.Job") as Job;
+
+ j.changed += on_job_changed;
+
+ TreeIter iter;
+ job_model.append(out iter);
+ update_job_iter(iter, id, j);
+ }
+
public void on_unit_removed(string id, ObjectPath path) {
TreeIter iter;
if (!(unit_model.get_iter_first(out iter)))
@@ -632,6 +649,58 @@ public class MainWindow : Window {
} while (job_model.iter_next(ref iter));
}
+ public void on_unit_changed(Unit u) {
+ TreeIter iter;
+ string id;
+
+ if (!(unit_model.get_iter_first(out iter)))
+ return;
+
+ id = u.id;
+
+ do {
+ string name;
+
+ unit_model.get(iter, 0, out name);
+
+ if (id == name) {
+ update_unit_iter(iter, id, u);
+
+ if (current_unit_id == id)
+ show_unit(u);
+
+ break;
+ }
+
+ } while (unit_model.iter_next(ref iter));
+ }
+
+ public void on_job_changed(Job j) {
+ TreeIter iter;
+ uint32 id;
+
+ if (!(job_model.get_iter_first(out iter)))
+ return;
+
+ id = j.id;
+
+ do {
+ uint32 k;
+
+ job_model.get(iter, 5, out k);
+
+ if (id == k) {
+ update_job_iter(iter, id, j);
+
+ if (current_job_id == id)
+ show_job(j);
+
+ break;
+ }
+
+ } while (job_model.iter_next(ref iter));
+ }
+
public bool unit_filter(TreeModel model, TreeIter iter) {
string id, active_state, job;
commit 37a8e6831650bdf6439038d802775b182fa599e7
Author: Lennart Poettering <lennart at poettering.net>
Date: Sun May 16 03:57:56 2010 +0200
manager: rearrange order of mainloop, put gc/cleanup last to maximize reusing
diff --git a/manager.c b/manager.c
index 7675334..89b210d 100644
--- a/manager.c
+++ b/manager.c
@@ -1949,19 +1949,19 @@ int manager_loop(Manager *m) {
sleep(1);
}
- if (manager_dispatch_cleanup_queue(m) > 0)
+ if (manager_dispatch_load_queue(m) > 0)
continue;
- if (manager_dispatch_gc_queue(m) > 0)
+ if (manager_dispatch_run_queue(m) > 0)
continue;
- if (manager_dispatch_load_queue(m) > 0)
+ if (bus_dispatch(m) > 0)
continue;
- if (manager_dispatch_run_queue(m) > 0)
+ if (manager_dispatch_cleanup_queue(m) > 0)
continue;
- if (bus_dispatch(m) > 0)
+ if (manager_dispatch_gc_queue(m) > 0)
continue;
if (manager_dispatch_dbus_queue(m) > 0)
commit 94b6dfa24f84bd8854c1dc566413b0719dce9e0d
Author: Lennart Poettering <lennart at poettering.net>
Date: Sun May 16 03:57:07 2010 +0200
unit,job: when we suppress a D-Bus signal because nobody is listening, don't delay it until later
diff --git a/dbus-job.c b/dbus-job.c
index f14f92f..3a6e715 100644
--- a/dbus-job.c
+++ b/dbus-job.c
@@ -152,8 +152,10 @@ void bus_job_send_change_signal(Job *j) {
LIST_REMOVE(Job, dbus_queue, j->manager->dbus_job_queue, j);
j->in_dbus_queue = false;
- if (set_isempty(j->manager->subscribed))
+ if (set_isempty(j->manager->subscribed)) {
+ j->sent_dbus_new_signal = true;
return;
+ }
if (!(p = job_dbus_path(j)))
goto oom;
diff --git a/dbus-unit.c b/dbus-unit.c
index ccaaef9..0c311ea 100644
--- a/dbus-unit.c
+++ b/dbus-unit.c
@@ -348,8 +348,10 @@ void bus_unit_send_change_signal(Unit *u) {
LIST_REMOVE(Meta, dbus_queue, u->meta.manager->dbus_unit_queue, &u->meta);
u->meta.in_dbus_queue = false;
- if (set_isempty(u->meta.manager->subscribed))
+ if (set_isempty(u->meta.manager->subscribed)) {
+ u->meta.sent_dbus_new_signal = true;
return;
+ }
if (!(p = unit_dbus_path(u)))
goto oom;
diff --git a/job.c b/job.c
index 1d59bcb..887de92 100644
--- a/job.c
+++ b/job.c
@@ -541,6 +541,11 @@ void job_add_to_dbus_queue(Job *j) {
if (j->in_dbus_queue)
return;
+ if (set_isempty(j->manager->subscribed)) {
+ j->sent_dbus_new_signal = true;
+ return;
+ }
+
LIST_PREPEND(Job, dbus_queue, j->manager->dbus_job_queue, j);
j->in_dbus_queue = true;
}
diff --git a/manager.c b/manager.c
index 4cc7d30..7675334 100644
--- a/manager.c
+++ b/manager.c
@@ -57,7 +57,7 @@
#define GC_QUEUE_ENTRIES_MAX 16
/* As soon as 5s passed since a unit was added to our GC queue, make sure to run a gc sweep */
-#define GC_QUEUE_USEC_MAX (5*USEC_PER_SEC)
+#define GC_QUEUE_USEC_MAX (10*USEC_PER_SEC)
static int enable_special_signals(Manager *m) {
char fd;
diff --git a/unit.c b/unit.c
index 1757af3..ee0c120 100644
--- a/unit.c
+++ b/unit.c
@@ -272,9 +272,14 @@ void unit_add_to_dbus_queue(Unit *u) {
assert(u);
assert(u->meta.type != _UNIT_TYPE_INVALID);
- if (u->meta.load_state == UNIT_STUB || u->meta.in_dbus_queue || set_isempty(u->meta.manager->subscribed))
+ if (u->meta.load_state == UNIT_STUB || u->meta.in_dbus_queue)
return;
+ if (set_isempty(u->meta.manager->subscribed)) {
+ u->meta.sent_dbus_new_signal = true;
+ return;
+ }
+
LIST_PREPEND(Meta, dbus_queue, u->meta.manager->dbus_unit_queue, &u->meta);
u->meta.in_dbus_queue = true;
}
commit c1b94fda55e6e29e388a30f846b62650b5e60f7e
Author: Lennart Poettering <lennart at poettering.net>
Date: Sun May 16 03:55:52 2010 +0200
systemctl: log whenever a unit/job changes
diff --git a/systemctl.vala b/systemctl.vala
index ddbede9..821be5a 100644
--- a/systemctl.vala
+++ b/systemctl.vala
@@ -24,6 +24,7 @@ static string type = null;
static bool all = false;
static bool replace = false;
static bool session = false;
+static Connection bus = null;
public static int job_info_compare(void* key1, void* key2) {
Manager.JobInfo *j1 = (Manager.JobInfo*) key1;
@@ -43,12 +44,40 @@ public static int unit_info_compare(void* key1, void* key2) {
return Posix.strcmp(u1->id, u2->id);
}
+public void on_unit_changed(Unit u) {
+ stdout.printf("Unit %s changed.\n", u.id);
+}
+
public void on_unit_new(string id, ObjectPath path) {
stdout.printf("Unit %s added.\n", id);
+
+ Unit u = bus.get_object(
+ "org.freedesktop.systemd1",
+ path,
+ "org.freedesktop.systemd1.Unit") as Unit;
+
+ u.changed += on_unit_changed;
+
+ /* FIXME: We leak memory here */
+ u.ref();
+}
+
+public void on_job_changed(Job j) {
+ stdout.printf("Job %u changed.\n", j.id);
}
public void on_job_new(uint32 id, ObjectPath path) {
stdout.printf("Job %u added.\n", id);
+
+ Job j = bus.get_object(
+ "org.freedesktop.systemd1",
+ path,
+ "org.freedesktop.systemd1.Job") as Job;
+
+ j.changed += on_job_changed;
+
+ /* FIXME: We leak memory here */
+ j.ref();
}
public void on_unit_removed(string id, ObjectPath path) {
@@ -100,7 +129,7 @@ int main (string[] args) {
}
try {
- Connection bus = Bus.get(session ? BusType.SESSION : BusType.SYSTEM);
+ bus = Bus.get(session ? BusType.SESSION : BusType.SYSTEM);
Manager manager = bus.get_object (
"org.freedesktop.systemd1",
commit cb8a8f78a11cedb8cba1abfa9a63b0d3ea8eef93
Author: Lennart Poettering <lennart at poettering.net>
Date: Sun May 16 03:55:19 2010 +0200
service: consider a process exiting with SIGTERM a clean exit
diff --git a/mount.c b/mount.c
index 2b24ea5..ec03a52 100644
--- a/mount.c
+++ b/mount.c
@@ -900,7 +900,7 @@ static void mount_sigchld_event(Unit *u, pid_t pid, int code, int status) {
assert(m);
assert(pid >= 0);
- success = code == CLD_EXITED && status == 0;
+ success = is_clean_exit(code, status);
m->failure = m->failure || !success;
assert(m->control_pid == pid);
diff --git a/service.c b/service.c
index ca25248..bf91561 100644
--- a/service.c
+++ b/service.c
@@ -1890,7 +1890,7 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) {
assert(s);
assert(pid >= 0);
- success = code == CLD_EXITED && status == 0;
+ success = is_clean_exit(code, status);
s->failure = s->failure || !success;
if (s->main_pid == pid) {
diff --git a/socket.c b/socket.c
index aafe439..259f273 100644
--- a/socket.c
+++ b/socket.c
@@ -1204,7 +1204,7 @@ static void socket_sigchld_event(Unit *u, pid_t pid, int code, int status) {
assert(s);
assert(pid >= 0);
- success = code == CLD_EXITED && status == 0;
+ success = is_clean_exit(code, status);
s->failure = s->failure || !success;
assert(s->control_pid == pid);
diff --git a/util.c b/util.c
index 95791f9..5e3654d 100644
--- a/util.c
+++ b/util.c
@@ -1910,6 +1910,23 @@ int make_stdio(int fd) {
return 0;
}
+bool is_clean_exit(int code, int status) {
+
+ if (code == CLD_EXITED)
+ return status == 0;
+
+ /* If a daemon does not implement handlers for some of the
+ * signals that's not considered an unclean shutdown */
+ if (code == CLD_KILLED)
+ return
+ status == SIGHUP ||
+ status == SIGINT ||
+ status == SIGTERM ||
+ status == SIGPIPE;
+
+ return false;
+}
+
static const char *const ioprio_class_table[] = {
[IOPRIO_CLASS_NONE] = "none",
[IOPRIO_CLASS_RT] = "realtime",
diff --git a/util.h b/util.h
index ba27c75..d0fc319 100644
--- a/util.h
+++ b/util.h
@@ -181,6 +181,8 @@ char *format_timestamp(char *buf, size_t l, usec_t t);
int make_stdio(int fd);
+bool is_clean_exit(int code, int status);
+
#define DEFINE_STRING_TABLE_LOOKUP(name,type) \
const char *name##_to_string(type i) { \
if (i < 0 || i >= (type) ELEMENTSOF(name##_table)) \
commit ca139f94c8de427616f54ab38262a47c4a636ffd
Author: Lennart Poettering <lennart at poettering.net>
Date: Sun May 16 03:54:40 2010 +0200
util: add gfs to list of network filesystems
diff --git a/util.c b/util.c
index 5df811d..95791f9 100644
--- a/util.c
+++ b/util.c
@@ -1359,7 +1359,9 @@ bool fstype_is_network(const char *fstype) {
"smbfs",
"ncpfs",
"nfs",
- "nfs4"
+ "nfs4",
+ "gfs",
+ "gfs2"
};
unsigned i;
commit a1d821025a51e119a5959fb8b3fb976e41260f1a
Author: Lennart Poettering <lennart at poettering.net>
Date: Sun May 16 02:37:59 2010 +0200
systemadm: consider units with a job live
diff --git a/99-systemd.rules b/99-systemd.rules
index c5c330f..e88f10a 100644
--- a/99-systemd.rules
+++ b/99-systemd.rules
@@ -22,7 +22,7 @@ KERNEL=="ttyS*", ENV{SYSTEMD_EXPOSE}="1"
SUBSYSTEM=="block", ENV{SYSTEMD_EXPOSE}="1"
-# We need a hardware independant way to identify network devices. We
+# We need a hardware independent way to identify network devices. We
# use the /sys/subsystem path for this. Current vanilla kernels don't
# actually support that hierarchy right now, however upcoming kernels
# will. HAL and udev internally support /sys/subsystem already, hence
diff --git a/systemadm.vala b/systemadm.vala
index d4b760a..92ee503 100644
--- a/systemadm.vala
+++ b/systemadm.vala
@@ -633,9 +633,9 @@ public class MainWindow : Window {
}
public bool unit_filter(TreeModel model, TreeIter iter) {
- string id, active_state;
+ string id, active_state, job;
- model.get(iter, 0, out id, 3, out active_state);
+ model.get(iter, 0, out id, 3, out active_state, 5, out job);
if (id == null)
return false;
@@ -646,7 +646,7 @@ public class MainWindow : Window {
return true;
case 1:
- return active_state != "inactive";
+ return active_state != "inactive" || job != "";
case 2:
return id.has_suffix(".service");
More information about the systemd-commits
mailing list