CLEANUP: chunks: release trash also in deinit

Tim reported in issue #1676 that just like startup_logs, trash buffers
are not released on deinit since they're thread-local, but valgrind
notices it when quitting before creating threads like "-c -f ...". Let's
just subscribe the function to deinit in addition to threads' end.

The two "free(x);x=NULL;" in free_trash_buffers_per_thread() were
also simplified using ha_free().
This commit is contained in:
Willy Tarreau 2022-04-27 17:55:41 +02:00
parent 032e700e8b
commit d941146583

View File

@ -82,10 +82,8 @@ static int alloc_trash_buffers_per_thread()
static void free_trash_buffers_per_thread()
{
chunk_destroy(&trash);
free(trash_buf2);
free(trash_buf1);
trash_buf2 = NULL;
trash_buf1 = NULL;
ha_free(&trash_buf2);
ha_free(&trash_buf1);
}
/* Initialize the trash buffers. It returns 0 if an error occurred. */
@ -309,6 +307,7 @@ int chunk_strcasecmp(const struct buffer *chk, const char *str)
REGISTER_PER_THREAD_ALLOC(alloc_trash_buffers_per_thread);
REGISTER_PER_THREAD_FREE(free_trash_buffers_per_thread);
REGISTER_POST_DEINIT(free_trash_buffers_per_thread);
/*
* Local variables: