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:
@@ -46,7 +46,7 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
|
||||
Config *config = config_create(str_dup("1.0.0"), NULL, NULL,
|
||||
save_to_disk, false, false, false, false, 5, 20, false);
|
||||
save_to_disk, false, false, false, false, 5, false);
|
||||
|
||||
int positional_args[2];
|
||||
int positional_count = 0;
|
||||
|
||||
@@ -171,10 +171,11 @@ int send_files_multithreaded(Config *config) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int sender_result;
|
||||
thrd_join(scanner, NULL);
|
||||
thrd_join(loader, NULL);
|
||||
thrd_join(sender, NULL);
|
||||
thrd_join(sender, &sender_result);
|
||||
|
||||
pipeline_context_sender_destroy(context);
|
||||
return 0;
|
||||
return sender_result == thrd_success ? 0 : -1;
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ Chunk *directory_scanner_next(DirectoryScanner *scanner) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!S_ISREG(stats.st_mode)) {
|
||||
if (S_ISDIR(stats.st_mode)) {
|
||||
queue_enqueue(scanner->directories, (void *)cur_path);
|
||||
} else {
|
||||
File *file = file_create(cur_path);
|
||||
@@ -99,8 +99,10 @@ Chunk *directory_scanner_next(DirectoryScanner *scanner) {
|
||||
file->metadata = file_metadata_create(&stats);
|
||||
array_list_add(chunk_data, file);
|
||||
chunk_data_size += file->data->size;
|
||||
if (chunk_data_size > DESIRED_CHUNK_SIZE)
|
||||
if (chunk_data_size > DESIRED_CHUNK_SIZE) {
|
||||
free(cur_path);
|
||||
return chunk_data_to_chunk(chunk_data);
|
||||
}
|
||||
free(cur_path);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user