1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
diff --git a/lib/logsource.c b/lib/logsource.c
index 3f38b66e8b..83c61a8e93 100644
--- a/lib/logsource.c
+++ b/lib/logsource.c
@@ -633,7 +633,20 @@ log_source_queue(LogPipe *s, LogMessage *msg, const LogPathOptions *path_options
evt_tag_printf("msg", "%p", msg));
msg_set_context(NULL);
+}
+
+static void
+_initialize_window(LogSource *self, gint init_window_size)
+{
+ self->window_initialized = TRUE;
+ window_size_counter_set(&self->window_size, init_window_size);
+ self->full_window_size = init_window_size;
+}
+static gboolean
+_is_window_initialized(LogSource *self)
+{
+ return self->window_initialized;
}
void
@@ -645,11 +658,9 @@ log_source_set_options(LogSource *self, LogSourceOptions *options,
* configuration and we received a SIGHUP. This means that opened
* connections will not have their window_size changed. */
- if ((gint)window_size_counter_get(&self->window_size, NULL) == -1)
- {
- window_size_counter_set(&self->window_size, options->init_window_size);
- self->full_window_size = options->init_window_size;
- }
+ if (!_is_window_initialized(self))
+ _initialize_window(self, options->init_window_size);
+
self->options = options;
if (self->stats_id)
g_free(self->stats_id);
@@ -679,7 +690,7 @@ log_source_init_instance(LogSource *self, GlobalConfig *cfg)
self->super.free_fn = log_source_free;
self->super.init = log_source_init;
self->super.deinit = log_source_deinit;
- window_size_counter_set(&self->window_size, (gsize)-1);
+ self->window_initialized = FALSE;
self->ack_tracker = NULL;
}
@@ -696,7 +707,9 @@ log_source_free(LogPipe *s)
ack_tracker_free(self->ack_tracker);
self->ack_tracker = NULL;
- _release_dynamic_window(self);
+
+ if (G_UNLIKELY(dynamic_window_is_enabled(&self->dynamic_window)))
+ _release_dynamic_window(self);
}
void
diff --git a/lib/logsource.h b/lib/logsource.h
index 370842efc2..75d4926046 100644
--- a/lib/logsource.h
+++ b/lib/logsource.h
@@ -71,6 +71,7 @@ struct _LogSource
gchar *stats_instance;
WindowSizeCounter window_size;
DynamicWindow dynamic_window;
+ gboolean window_initialized;
/* full_window_size = static + dynamic */
gsize full_window_size;
atomic_gssize window_size_to_be_reclaimed;
|