feat: sendfile works with -m, error on -f + -c/-s

- load_files_multithreaded skips file_load_data when sendfile is active
- -f + -m works: sendfile bypasses loader, sender uses sendfile directly
- -f combined with -c or -s prints error and exits with rc=1
- Add Sendfile + Multithreading test case
This commit is contained in:
2026-07-05 16:31:08 +02:00
parent 01045d7d14
commit 2fb7203c82
3 changed files with 11 additions and 8 deletions
+9 -7
View File
@@ -86,8 +86,10 @@ int load_files_multithreaded(void *pipeline_context) {
mtx_unlock(&context->mutex_loader);
return thrd_success;
}
for (int i = 0; i < chunk->element_count; i++)
file_load_data(chunk->items[i]);
if (!context->config->use_sendfile) {
for (int i = 0; i < chunk->element_count; i++)
file_load_data(chunk->items[i]);
}
queue_enqueue_multithreaded(context->queue_loader, chunk,
&context->mutex_loader,
&context->condition_not_empty_loader,
@@ -152,11 +154,6 @@ int send_files(Config *config) {
}
int send_files_multithreaded(Config *config) {
if (config->use_sendfile) {
log_message(LOG_LEVEL_INFO, "Sendfile enabled, falling back to single-threaded");
return send_files(config);
}
PipelineContextSender *context =
pipeline_context_sender_create(config, queue_create(100, chunk_destroy),
queue_create(100, chunk_destroy));
@@ -238,6 +235,11 @@ int main(int argc, char *argv[]) {
}
}
if (config->use_sendfile && (config->use_chunk_serialization || config->use_compression)) {
fprintf(stderr, "Error: -f/--sendfile cannot be combined with -c (compression) or -s (chunk serialization)\n");
return 1;
}
if (config->use_multithreading)
return send_files_multithreaded(config);
return send_files(config);