Skip to content

Commit 1fa1a27

Browse files
Leonardo Alminananourdouf
authored andcommitted
task: added task map growth
Signed-off-by: Leonardo Alminana <[email protected]>
1 parent 6cfff5a commit 1fa1a27

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/flb_task.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,36 +33,42 @@
3333

3434
/*
3535
* Every task created must have an unique ID, this function lookup the
36-
* lowest number available in the tasks_map.
36+
* lowest number available in the task_map.
3737
*
3838
* This 'id' is used by the task interface to communicate with the engine event
3939
* loop about some action.
4040
*/
4141

4242
static inline int map_get_task_id(struct flb_config *config)
4343
{
44+
int result;
4445
int i;
45-
int map_size = (sizeof(config->tasks_map) / sizeof(struct flb_task_map));
4646

47-
for (i = 0; i < map_size; i++) {
48-
if (config->tasks_map[i].task == NULL) {
47+
for (i = 0; i < config->task_map_size ; i++) {
48+
if (config->task_map[i].task == NULL) {
4949
return i;
5050
}
5151
}
5252

53+
result = flb_config_task_map_grow(config);
54+
55+
if (result == 0) {
56+
return i;
57+
}
58+
5359
return -1;
5460
}
5561

5662
static inline void map_set_task_id(int id, struct flb_task *task,
5763
struct flb_config *config)
5864
{
59-
config->tasks_map[id].task = task;
65+
config->task_map[id].task = task;
6066

6167
}
6268

6369
static inline void map_free_task_id(int id, struct flb_config *config)
6470
{
65-
config->tasks_map[id].task = NULL;
71+
config->task_map[id].task = NULL;
6672
}
6773

6874
void flb_task_retry_destroy(struct flb_task_retry *retry)
@@ -250,6 +256,7 @@ static struct flb_task *task_alloc(struct flb_config *config)
250256
flb_free(task);
251257
return NULL;
252258
}
259+
253260
map_set_task_id(task_id, task, config);
254261

255262
flb_trace("[task %p] created (id=%i)", task, task_id);

0 commit comments

Comments
 (0)