Skip to content

Commit

Permalink
correctly free thread_data options at the topmost parent process
Browse files Browse the repository at this point in the history
for non-threaded mode: since thread_data::eo is a pointer within shared 
memory between the topmost fio parent process and its children let the 
fio parent process set the pointer to NULL as just it frees its copy of 
'eo' as memory previously allocated by means of 'malloc' meaning that 
each child and the parent process itself must free it

for threaded mode we leave it as it has always been

also we do not need to check td->io_ops for being able to free td->io in
 fio_options_free()

Signed-off-by: Denis Pronin <dannftk@yandex.ru>
  • Loading branch information
dpronin committed Jul 27, 2023
1 parent 45eb1cf commit 21cf431
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
4 changes: 0 additions & 4 deletions backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -2494,10 +2494,7 @@ static void run_threads(struct sk_out *sk_out)
strerror(ret));
} else {
pid_t pid;
void *eo;
dprint(FD_PROCESS, "will fork\n");
eo = td->eo;
read_barrier();
pid = fork();
if (!pid) {
int ret;
Expand All @@ -2506,7 +2503,6 @@ static void run_threads(struct sk_out *sk_out)
_exit(ret);
} else if (__td_index == fio_debug_jobno)
*fio_debug_jobp = pid;
free(eo);
free(fd);
fd = NULL;
}
Expand Down
3 changes: 2 additions & 1 deletion ioengines.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,8 @@ void free_ioengine(struct thread_data *td)
if (td->eo && td->io_ops->options) {
options_free(td->io_ops->options, td->eo);
free(td->eo);
td->eo = NULL;
if (td->o.use_thread)
td->eo = NULL;
}

if (td->io_ops->dlhandle) {
Expand Down
4 changes: 2 additions & 2 deletions options.c
Original file line number Diff line number Diff line change
Expand Up @@ -5829,9 +5829,9 @@ void fio_options_free(struct thread_data *td)
options_free(fio_options, &td->o);
if (td->eo && td->io_ops && td->io_ops->options) {
options_free(td->io_ops->options, td->eo);
free(td->eo);
td->eo = NULL;
}
free(td->eo);
td->eo = NULL;
}

void fio_dump_options_free(struct thread_data *td)
Expand Down

0 comments on commit 21cf431

Please sign in to comment.