Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

in_forward: Recreate connection when resumed #9605

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions plugins/in_forward/fw.c
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,8 @@ static int in_fw_init(struct flb_input_instance *ins,

ctx->coll_fd = ret;

pthread_mutex_init(&ctx->conn_mutex, NULL);

return 0;
}

Expand All @@ -365,8 +367,11 @@ static void in_fw_pause(void *data, struct flb_config *config)
* and wait for the ingestion to resume.
*/
flb_input_collector_pause(ctx->coll_fd, ctx->ins);
fw_conn_del_all(ctx);
ctx->is_paused = FLB_TRUE;
if (pthread_mutex_lock(&ctx->conn_mutex)) {
fw_conn_del_all(ctx);
ctx->is_paused = FLB_TRUE;
}
pthread_mutex_unlock(&ctx->conn_mutex);
}

/*
Expand All @@ -385,8 +390,11 @@ static void in_fw_pause(void *data, struct flb_config *config)
static void in_fw_resume(void *data, struct flb_config *config) {
struct flb_in_fw_config *ctx = data;
if (config->is_running == FLB_TRUE) {
ctx->is_paused = FLB_FALSE;
flb_input_collector_resume(ctx->coll_fd, ctx->ins);
if (pthread_mutex_lock(&ctx->conn_mutex)) {
ctx->is_paused = FLB_FALSE;
}
pthread_mutex_unlock(&ctx->conn_mutex);
}
}

Expand Down
2 changes: 2 additions & 0 deletions plugins/in_forward/fw.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ struct flb_in_fw_config {
struct flb_log_event_decoder *log_decoder;
struct flb_log_event_encoder *log_encoder;

pthread_mutex_t conn_mutex;

/* Plugin is paused */
int is_paused;
};
Expand Down
Loading