projects
/
project
/
procd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Parse only init_debug option with non-empty argument.
[project/procd.git]
/
service.c
diff --git
a/service.c
b/service.c
index 8aae975cc4cb5f3354c2ab384371dd3f6f7bc5ff..561c76c5de8e8a86b8bf8a2fa32e407b6e4f371c 100644
(file)
--- a/
service.c
+++ b/
service.c
@@
-12,6
+12,7
@@
* GNU General Public License for more details.
*/
* GNU General Public License for more details.
*/
+#include <libubox/blobmsg_json.h>
#include <libubox/avl-cmp.h>
#include "procd.h"
#include "service.h"
#include <libubox/avl-cmp.h>
#include "procd.h"
#include "service.h"
@@
-100,7
+101,13
@@
service_update(struct service *s, struct blob_attr *config, struct blob_attr **t
struct blob_attr *cur;
int rem;
struct blob_attr *cur;
int rem;
- s->trigger = tb[SERVICE_SET_TRIGGER];
+ if (s->trigger)
+ trigger_del(s);
+
+ if (tb[SERVICE_SET_TRIGGER] && blobmsg_data_len(tb[SERVICE_SET_TRIGGER])) {
+ s->trigger = tb[SERVICE_SET_TRIGGER];
+ trigger_add(s->trigger, s);
+ }
if (tb[SERVICE_SET_INSTANCES]) {
if (!add)
if (tb[SERVICE_SET_INSTANCES]) {
if (!add)
@@
-120,6
+127,7
@@
service_delete(struct service *s)
{
vlist_flush_all(&s->instances);
avl_delete(&services, &s->avl);
{
vlist_flush_all(&s->instances);
avl_delete(&services, &s->avl);
+ trigger_del(s);
free(s->config);
free(s);
}
free(s->config);
free(s);
}
@@
-212,13
+220,13
@@
service_dump(struct service *s, int verbose)
struct service_instance *in;
void *c, *i;
struct service_instance *in;
void *c, *i;
- if (avl_is_empty(&s->instances.avl))
+ if (avl_is_empty(&s->instances.avl)
&& !verbose
)
return;
c = blobmsg_open_table(&b, s->name);
return;
c = blobmsg_open_table(&b, s->name);
- i = blobmsg_open_table(&b, "instances");
if (verbose && s->trigger)
blobmsg_add_blob(&b, s->trigger);
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);
vlist_for_each_element(&s->instances, in, node)
instance_dump(&b, in, verbose);
blobmsg_close_table(&b, i);