summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Crispin <blogic@openwrt.org>2013-09-03 16:03:29 +0200
committerJohn Crispin <blogic@openwrt.org>2013-09-03 19:44:57 +0200
commit392ad3ba793f44a343026d5d49f7b8dc1435a2b8 (patch)
tree38afd1dd4afae3555509ed559f1b124ffcba347c
parented0464dbda4125cc857d8a06b84fa695d0b29251 (diff)
downloadunitd-392ad3ba793f44a343026d5d49f7b8dc1435a2b8.tar
unitd-392ad3ba793f44a343026d5d49f7b8dc1435a2b8.zip
fixup service_dump logic
Signed-off-by: John Crispin <blogic@openwrt.org>
-rw-r--r--service.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/service.c b/service.c
index c80402c..e485c53 100644
--- a/service.c
+++ b/service.c
@@ -220,16 +220,19 @@ service_dump(struct service *s, int verbose)
struct service_instance *in;
void *c, *i;
- if (avl_is_empty(&s->instances.avl) && !verbose)
+ c = blobmsg_open_table(&b, s->name);
+
+ if (avl_is_empty(&s->instances.avl)) {
+ blobmsg_close_table(&b, c);
return;
+ }
- c = blobmsg_open_table(&b, s->name);
- if (verbose && s->trigger)
- blobmsg_add_blob(&b, s->trigger);
i = blobmsg_open_table(&b, "instances");
vlist_for_each_element(&s->instances, in, node)
instance_dump(&b, in, verbose);
blobmsg_close_table(&b, i);
+ if (verbose && s->trigger)
+ blobmsg_add_blob(&b, s->trigger);
blobmsg_close_table(&b, c);
}