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 committed Feb 27, 2024
1 parent a385396 commit 1b031a4
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,11 +16,11 @@

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

namespace logtail {

Expand All @@ -44,8 +44,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 @@ -63,6 +63,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 1b031a4

Please sign in to comment.