Properly manage lifecycle for ClientInfo.

This commit is contained in:
2026-01-10 00:06:54 -05:00
parent c3a9c536a3
commit d791913a7f
+7 -8
View File
@@ -66,14 +66,15 @@
#define FILE_ERR 16 /* Operation error */
typedef enum {
enum FileState
{
st_start = 10,
st_dpip,
st_http,
st_content,
st_done,
st_err
} FileState;
};
struct FileInfo {
std::string full_path;
@@ -891,9 +892,7 @@ static void termination_handler(int signum)
*/
static ClientInfo *File_add_client(int sock_fd)
{
ClientInfo *new_client;
new_client = new ClientInfo;
auto new_client = std::make_unique< ClientInfo >();
new_client->sh = a_Dpip_dsh_new(sock_fd, sock_fd, 8*1024);
new_client->orig_url = NULL;
new_client->filename = NULL;
@@ -905,9 +904,9 @@ static ClientInfo *File_add_client(int sock_fd)
new_client->flags = FILE_READ;
new_client->old_style = OLD_STYLE;
dList_append(Clients, new_client);
dList_append(Clients, new_client.get());
return new_client;
return new_client.release();
}
/*
@@ -925,7 +924,7 @@ static void File_remove_client(ClientInfo *client)
dFree(client->filename);
File_dillodir_free(client->d_dir);
dFree(client);
delete client;
}
/*