Phase 1+2: bug fixes and dead code cleanup

Phase 1 — Bugs:
- receive_data: fix unsigned long long vs size_t mismatch
- chunk_deserialize: add NULL check in multiprocessing.c and server.c
- file_content_to_buffer: add missing fclose on error path
- send_files_multithreaded: propagate sender thread result
- server: add SIGPIPE handler
- to_disk: check fwrite return value
- scanner: use S_ISDIR instead of !S_ISREG
- scanner: free cur_path before early return

Phase 2 — Cleanup:
- Remove unused chunk_decompress function
- Remove unused array_list_clear function
- Remove unused num_connections config field
- Remove duplicate FILE_METADATA_WIRE_SIZE macro
- Update tests for removed APIs
This commit is contained in:
2026-07-16 12:08:09 +02:00
parent 81800fa661
commit 8f4ea62ae7
17 changed files with 43 additions and 69 deletions
+7
View File
@@ -11,6 +11,7 @@
#include "transport_tcp.h"
#include "unistd.h"
#include "utils.h"
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -27,6 +28,11 @@ int receive_files(Config *config, int file_descriptor) {
}
Chunk *chunk = chunk_deserialize(data_to_process, config->use_metadata);
data_destroy(data_to_process);
if (chunk == NULL) {
log_message(LOG_LEVEL_ERROR, "Failed to deserialize chunk, skipping");
send_status(file_descriptor, STATUS_ERROR);
return -1;
}
for (int i = 0; i < chunk->element_count; i++) {
if (config->save_to_disk) {
@@ -79,6 +85,7 @@ void handler(int file_descriptor) {
}
int main(int argc, char *argv[]) {
signal(SIGPIPE, SIG_IGN);
for (int i = 1; i < argc; i++) {
if (strcmp(argv[i], "--stdio") == 0) {
io_set_fds(STDIN_FILENO, STDOUT_FILENO);