From 355f259b8c78fdb8bc77574f616d129cb13b0f85 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Sun, 22 Jan 2023 08:29:43 +0100 Subject: [PATCH] output/filedata: trunc file in output again --- src/output-filedata.c | 10 +++++----- src/output-filedata.h | 2 +- src/output-tx.c | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/output-filedata.c b/src/output-filedata.c index 6d8a5e3ed0..a9890769a7 100644 --- a/src/output-filedata.c +++ b/src/output-filedata.c @@ -127,13 +127,13 @@ static void CloseFile(const Packet *p, Flow *f, File *file, void *txv) } void OutputFiledataLogFfc(ThreadVars *tv, OutputFiledataLoggerThreadData *td, Packet *p, - FileContainer *ffc, void *txv, const uint64_t tx_id, AppLayerTxData *txd, + AppLayerGetFileState files, void *txv, const uint64_t tx_id, AppLayerTxData *txd, const uint8_t call_flags, const bool file_close, const bool file_trunc, const uint8_t dir) { - SCLogDebug("ffc %p", ffc); + SCLogDebug("ffc %p", files.fc); OutputLoggerThreadStore *store = td->store; - for (File *ff = ffc->head; ff != NULL; ff = ff->next) { + for (File *ff = files.fc->head; ff != NULL; ff = ff->next) { FileApplyTxFlags(txd, dir, ff); FilePrintFlags(ff); @@ -162,7 +162,7 @@ void OutputFiledataLogFfc(ThreadVars *tv, OutputFiledataLoggerThreadData *td, Pa * close the logger(s) */ if (FileDataSize(ff) == ff->content_stored && (file_trunc || file_close)) { if (ff->state < FILE_STATE_CLOSED) { - ff->state = FILE_STATE_TRUNCATED; + FileCloseFilePtr(ff, files.cfg, NULL, 0, FILE_TRUNCATED); } file_flags |= OUTPUT_FILEDATA_FLAG_CLOSE; CallLoggers(tv, store, p, ff, txv, tx_id, NULL, 0, file_flags, dir); @@ -173,7 +173,7 @@ void OutputFiledataLogFfc(ThreadVars *tv, OutputFiledataLoggerThreadData *td, Pa /* if file needs to be closed or truncated, inform * loggers */ if ((file_close || file_trunc) && ff->state < FILE_STATE_CLOSED) { - ff->state = FILE_STATE_TRUNCATED; + FileCloseFilePtr(ff, files.cfg, NULL, 0, FILE_TRUNCATED); } /* tell the logger we're closing up */ diff --git a/src/output-filedata.h b/src/output-filedata.h index 6d2d544664..58764aa81e 100644 --- a/src/output-filedata.h +++ b/src/output-filedata.h @@ -42,7 +42,7 @@ TmEcode OutputFiledataLogThreadInit(ThreadVars *tv, OutputFiledataLoggerThreadDa TmEcode OutputFiledataLogThreadDeinit(ThreadVars *tv, OutputFiledataLoggerThreadData *thread_data); void OutputFiledataLogFfc(ThreadVars *tv, OutputFiledataLoggerThreadData *td, Packet *p, - FileContainer *ffc, void *txv, const uint64_t tx_id, AppLayerTxData *txd, + AppLayerGetFileState files, void *txv, const uint64_t tx_id, AppLayerTxData *txd, const uint8_t call_flags, const bool file_close, const bool file_trunc, const uint8_t dir); /** filedata logger function pointer type */ diff --git a/src/output-tx.c b/src/output-tx.c index 1fd4a1a2a9..6ddbdd1f62 100644 --- a/src/output-tx.c +++ b/src/output-tx.c @@ -194,8 +194,8 @@ static inline void OutputTxLogFiles(ThreadVars *tv, OutputFileLoggerThreadData * SCLogDebug("tx: calling files: ffc %p head %p file_close %d file_trunc %d", ffc, ffc->head, file_close, file_trunc); if (filedata_td && txd->files_opened > txd->files_stored) - OutputFiledataLogFfc(tv, filedata_td, p, ffc, tx, tx_id, txd, packet_dir, file_close, - file_trunc, packet_dir); + OutputFiledataLogFfc(tv, filedata_td, p, app_files, tx, tx_id, txd, packet_dir, + file_close, file_trunc, packet_dir); if (file_td && txd->files_opened > txd->files_logged) OutputFileLogFfc( tv, file_td, p, ffc, tx, tx_id, txd, file_close, file_trunc, packet_dir); @@ -208,8 +208,8 @@ static inline void OutputTxLogFiles(ThreadVars *tv, OutputFileLoggerThreadData * SCLogDebug("tx: calling for opposing direction files: file_close:%s file_trunc:%s", file_close ? "true" : "false", file_trunc ? "true" : "false"); if (filedata_td && txd->files_opened > txd->files_stored) - OutputFiledataLogFfc(tv, filedata_td, p, ffc_opposing, tx, tx_id, txd, opposing_dir, - file_close, file_trunc, opposing_dir); + OutputFiledataLogFfc(tv, filedata_td, p, app_files_opposing, tx, tx_id, txd, + opposing_dir, file_close, file_trunc, opposing_dir); if (file_td && txd->files_opened > txd->files_logged) OutputFileLogFfc(tv, file_td, p, ffc_opposing, tx, tx_id, txd, file_close, file_trunc, opposing_dir); -- 2.47.2