Fix mem leak
This commit is contained in:
+14
-1
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user