Skip to content

Commit decaca6

Browse files
committed
output: Unwind instance on the new alias-rewrite on exception
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
1 parent 70a8217 commit decaca6

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

src/flb_output.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -832,9 +832,17 @@ struct flb_output_instance *flb_output_new(struct flb_config *config,
832832
if (plugin->flags & FLB_OUTPUT_NET) {
833833
output_uri = flb_plugin_alias_rewrite(FLB_PLUGIN_OUTPUT, output_name);
834834
if (output_uri == FLB_PLUGIN_ALIAS_ERR) {
835-
if (instance->flags & FLB_OUTPUT_SYNCHRONOUS) {
835+
if ((instance->flags & FLB_OUTPUT_SYNCHRONOUS) &&
836+
instance->singleplex_queue != NULL) {
836837
flb_task_queue_destroy(instance->singleplex_queue);
837838
}
839+
if (instance->callback != NULL) {
840+
flb_callback_destroy(instance->callback);
841+
}
842+
if (plugin->type != FLB_OUTPUT_PLUGIN_CORE &&
843+
instance->context != NULL) {
844+
flb_free(instance->context);
845+
}
838846
flb_free(instance->http_server_config);
839847
flb_free(instance);
840848
return NULL;
@@ -849,9 +857,17 @@ struct flb_output_instance *flb_output_new(struct flb_config *config,
849857
}
850858

851859
if (ret != 0) {
852-
if (instance->flags & FLB_OUTPUT_SYNCHRONOUS) {
860+
if ((instance->flags & FLB_OUTPUT_SYNCHRONOUS) &&
861+
instance->singleplex_queue != NULL) {
853862
flb_task_queue_destroy(instance->singleplex_queue);
854863
}
864+
if (instance->callback != NULL) {
865+
flb_callback_destroy(instance->callback);
866+
}
867+
if (plugin->type != FLB_OUTPUT_PLUGIN_CORE &&
868+
instance->context != NULL) {
869+
flb_free(instance->context);
870+
}
855871
flb_free(instance->http_server_config);
856872
flb_free(instance);
857873
return NULL;

0 commit comments

Comments
 (0)