Fix mem leak

This commit is contained in:
2026-05-25 17:37:16 -07:00
parent 0a534ac0c0
commit 58b80a10d1
3 changed files with 28 additions and 3 deletions
+14 -1
View File
@@ -1,3 +1,12 @@
/*
* Design Doc:
* The server is broken into the following files:
* - main.c: Argument parsing and high-level control
* - http.c: HTTP request parsing and response formatting
* - server.c: Abstraction over sockets
* - threadpool.c: Thread pool and wokr queue implementation
* - util.c: Misc. utility functions
*/
#include "http.h"
#include "server.h"
#include "threadpool.h"
@@ -327,6 +336,10 @@ static void handle_connection(void *arg) {
fclose(conn);
}
static void fclose_free_func(void *file) {
fclose(file);
}
int main(int argc, const char **argv) {
setenv("POSIXLY_CORRECT", "1", true);
GlobalFlags flags = DEFAULT_FLAGS;
@@ -367,7 +380,7 @@ int main(int argc, const char **argv) {
close(conn_fd);
continue;
}
thread_pool_enqueue(pool, handle_connection, conn);
thread_pool_enqueue(pool, handle_connection, conn, fclose_free_func);
}
destroy_thread_pool(pool);
destroy_server(server);