@@ -931,7 +931,7 @@
static int create_stack_start_instances(struct ulogd_pluginstance_stack *stack)
{
int ret;
- struct ulogd_pluginstance *pi;
+ struct ulogd_pluginstance *pi, *stop;
/* start from input to output plugin */
llist_for_each_entry(pi, &stack->list, list) {
@@ -945,11 +945,27 @@
ulogd_log(ULOGD_ERROR,
"error starting `%s'\n",
pi->id);
- return ret;
+ goto cleanup_fail;
}
}
}
return 0;
+cleanup_fail:
+ stop = pi;
+ llist_for_each_entry(pi, &stack->list, list) {
+ if (pi == stop)
+ /* the one that failed, stops the cleanup here */
+ break;
+ if (!pi->plugin->stop)
+ continue;
+ ret = pi->plugin->stop(pi);
+ if (ret < 0) {
+ ulogd_log(ULOGD_ERROR,
+ "error stopping `%s'\n",
+ pi->id);
+ }
+ }
+ return -1;
}
/* create a new stack of plugins */