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

Add exit on eof flag to logreader #351

Merged
merged 1 commit into from
Nov 5, 2024
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
6 changes: 6 additions & 0 deletions lib/logreader.c
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,11 @@ log_reader_work_finished(void *s, gpointer arg)

self->notify_code = 0;
log_pipe_notify(self->control, notify_code, self);

if (notify_code == NC_CLOSE && (self->options->flags & LR_EXIT_ON_EOF))
{
cfg_shutdown(log_pipe_get_config(s));
}
}
if ((self->super.super.flags & PIF_INITIALIZED) && self->proto)
{
Expand Down Expand Up @@ -868,6 +873,7 @@ CfgFlagHandler log_reader_flag_handlers[] =
{ "empty-lines", CFH_SET, offsetof(LogReaderOptions, flags), LR_EMPTY_LINES },
{ "threaded", CFH_SET, offsetof(LogReaderOptions, flags), LR_THREADED },
{ "ignore-aux-data", CFH_SET, offsetof(LogReaderOptions, flags), LR_IGNORE_AUX_DATA },
{ "exit-on-eof", CFH_SET, offsetof(LogReaderOptions, flags), LR_EXIT_ON_EOF },
{ NULL },
};

Expand Down
1 change: 1 addition & 0 deletions lib/logreader.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#define LR_EMPTY_LINES 0x0004
#define LR_IGNORE_AUX_DATA 0x0008
#define LR_THREADED 0x0040
#define LR_EXIT_ON_EOF 0x0080

/* options */

Expand Down
2 changes: 0 additions & 2 deletions modules/affile/file-reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,6 @@ file_reader_notify_method(LogPipe *s, gint notify_code, gpointer user_data)
switch (notify_code)
{
case NC_CLOSE:
if (self->options->exit_on_eof)
cfg_shutdown(log_pipe_get_config(s));
break;

case NC_FILE_MOVED:
Expand Down
1 change: 0 additions & 1 deletion modules/affile/file-reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ typedef struct _FileReaderOptions
gint multi_line_timeout;
gboolean restore_state;
LogReaderOptions reader_options;
gboolean exit_on_eof;
} FileReaderOptions;

typedef struct _FileReader
Expand Down
2 changes: 1 addition & 1 deletion modules/affile/stdin.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ stdin_sd_new(GlobalConfig *cfg)
{
AFFileSourceDriver *self = affile_sd_new_instance("-", cfg);

self->file_reader_options.exit_on_eof = TRUE;
self->file_reader_options.reader_options.flags |= LR_EXIT_ON_EOF;
self->file_reader_options.reader_options.super.stats_source = stats_register_type("stdin");
self->file_opener = file_opener_for_stdin_new();
affile_sd_set_transport_name(self, "local+stdin");
Expand Down
Loading