From f2580902d5f27a982dc4da4b2fc390433edcb4f3 Mon Sep 17 00:00:00 2001 From: aajwy-gitee <13051180828@163.com> Date: Mon, 18 Oct 2021 05:59:06 +0000 Subject: [PATCH] Signed-off-by: aajwy <13051180828@163.com> --- services/hilogd/log_compress.cpp | 4 +++- services/hilogd/log_querier.cpp | 11 ++++++++--- services/hilogtool/main.cpp | 1 + 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/services/hilogd/log_compress.cpp b/services/hilogd/log_compress.cpp index 1860f6b..d3eb74e 100644 --- a/services/hilogd/log_compress.cpp +++ b/services/hilogd/log_compress.cpp @@ -34,9 +34,11 @@ void LogCompress::DeleteZData() int NoneCompress::Compress(LogPersisterBuffer* &buffer, LogPersisterBuffer* &compressBuffer) { - if (memcpy_s(compressBuffer->content, compressBuffer->offset, buffer->content, buffer->offset) != 0) { + if (memcpy_s(compressBuffer->content + compressBuffer->offset, MAX_PERSISTER_BUFFER_SIZE - compressBuffer->offset, + buffer->content, buffer->offset) != 0) { return -1; } + compressBuffer->offset += buffer->offset; return 0; } diff --git a/services/hilogd/log_querier.cpp b/services/hilogd/log_querier.cpp index a3fee3f..f6d8393 100644 --- a/services/hilogd/log_querier.cpp +++ b/services/hilogd/log_querier.cpp @@ -106,10 +106,15 @@ int JobLauncher(const LogPersistStartMsg& pMsg, const HilogBuffer& buffer, bool persister.reset(); return persistRes; } - if (saveInfoRes == RET_FAIL || rotatorRes == RET_FAIL) { - cout << "LogPersister failed to initialize!" << endl; + if (rotatorRes != 0) { + cout << "failed to open info file!" << endl; + persister.reset(); + return rotatorRes; + } + if (saveInfoRes != 0) { + cout << "Failed to save persister file path!" << endl; persister.reset(); - return RET_FAIL; + return saveInfoRes; } if (!restore) rotator->WriteRecoveryInfo(); persister->Start(); diff --git a/services/hilogtool/main.cpp b/services/hilogtool/main.cpp index 9d3c0eb..f0d9bd6 100644 --- a/services/hilogtool/main.cpp +++ b/services/hilogtool/main.cpp @@ -510,6 +510,7 @@ int HilogEntry(int argc, char* argv[]) } else if (context.logFileCtrlArgs == "query") { ret = LogPersistOp(controller, MC_REQ_LOG_PERSIST_QUERY, &logPersistParam); } else { + cout << "Invalid log persist parameter" << endl; exit(-1); } if (ret == RET_FAIL) { -- Gitee