Skip to content

Fix: Ensure process is able to exit when history file import is ever used #1369

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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