Skip to content

Commit

Permalink
Fix: Ensure process is able to exit when history file import is ever …
Browse files Browse the repository at this point in the history
…used (#1369)
  • Loading branch information
yyuuttaaoo authored Feb 26, 2024
1 parent f039b00 commit 4469148
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion core/event_handler/HistoryFileImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace logtail {

HistoryFileImporter::HistoryFileImporter() {
LOG_INFO(sLogger, ("HistoryFileImporter", "init"));
static auto _doNotQuitThread = CreateThread([this]() { Run(); });
mThread = CreateThread([this]() { Run(); });
}

void HistoryFileImporter::PushEvent(const HistoryFileEvent& event) {
Expand Down
7 changes: 4 additions & 3 deletions core/event_handler/HistoryFileImporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

#pragma once
#include <string>
#include <vector>
#include <unordered_map>
#include "common/StringTools.h"
#include "common/CircularBuffer.h"
#include "common/Thread.h"
#include "input/InputFile.h"

namespace logtail {
Expand Down Expand Up @@ -47,8 +47,8 @@ class HistoryFileImporter {
HistoryFileImporter();

static HistoryFileImporter* GetInstance() {
static HistoryFileImporter sFileImporter;
return &sFileImporter;
static HistoryFileImporter* sFileImporter = new HistoryFileImporter;
return sFileImporter;
}

void PushEvent(const HistoryFileEvent& event);
Expand All @@ -66,6 +66,7 @@ class HistoryFileImporter {
CircularBufferSem<HistoryFileEvent, HISTORY_EVENT_MAX> mEventQueue;
std::unordered_map<std::string, int64_t> mCheckPoints;
FILE* mCheckPointPtr;
ThreadPtr mThread;
};

} // namespace logtail

0 comments on commit 4469148

Please # to comment.