Skip to content

Commit 7931211

Browse files
committed
input_log: recompute per-output storage accounting
Signed-off-by: Eduardo Silva <[email protected]>
1 parent f9c1fb7 commit 7931211

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

src/flb_input_log.c

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ static int route_payload_apply_outputs(struct flb_input_instance *ins,
101101
int ret;
102102
int routes_found = 0;
103103
size_t out_size = 0;
104+
size_t chunk_size_sz = 0;
104105
ssize_t chunk_size;
105106
struct cfl_list *head;
106107
struct flb_input_chunk *chunk = NULL;
@@ -123,6 +124,52 @@ static int route_payload_apply_outputs(struct flb_input_instance *ins,
123124
return -1;
124125
}
125126

127+
if (chunk->fs_counted == FLB_TRUE) {
128+
chunk_size = flb_input_chunk_get_real_size(chunk);
129+
if (chunk_size > 0) {
130+
chunk_size_sz = (size_t) chunk_size;
131+
}
132+
else {
133+
chunk_size = 0;
134+
}
135+
}
136+
else {
137+
chunk_size = 0;
138+
}
139+
140+
if (chunk_size_sz > 0) {
141+
cfl_list_foreach(head, &ins->routes_direct) {
142+
route_path = cfl_list_entry(head, struct flb_router_path, _head);
143+
144+
if (!route_path->ins) {
145+
continue;
146+
}
147+
148+
if (flb_routes_mask_get_bit(chunk->routes_mask,
149+
route_path->ins->id,
150+
ins->config) == 0) {
151+
continue;
152+
}
153+
154+
if (route_path->route == payload->route) {
155+
continue;
156+
}
157+
158+
if (route_path->ins->total_limit_size != -1) {
159+
if (route_path->ins->fs_chunks_size > chunk_size_sz) {
160+
route_path->ins->fs_chunks_size -= chunk_size_sz;
161+
}
162+
else {
163+
route_path->ins->fs_chunks_size = 0;
164+
}
165+
}
166+
167+
flb_routes_mask_clear_bit(chunk->routes_mask,
168+
route_path->ins->id,
169+
ins->config);
170+
}
171+
}
172+
126173
memset(chunk->routes_mask, 0, sizeof(flb_route_mask_element) * ins->config->route_mask_size);
127174
cfl_list_foreach(head, &ins->routes_direct) {
128175
route_path = cfl_list_entry(head, struct flb_router_path, _head);

0 commit comments

Comments
 (0)