Skip to content

Commit

Permalink
Fix: Delete mSourceKeyOverwritten in processorParseApsaraNative to pr…
Browse files Browse the repository at this point in the history
…event concurrency issues. (#1305)

This submission resolves an issue in ProcessorParseApsaraNative. mSourceKeyOverwritten is no longer needed, and a local variable sourceKeyOverwritten has been defined to prevent concurrency issues.
  • Loading branch information
quzard authored Jan 2, 2024
1 parent e82d44e commit d787724
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
6 changes: 3 additions & 3 deletions core/processor/ProcessorParseApsaraNative.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ bool ProcessorParseApsaraNative::ProcessEvent(const StringView& logPath,
if (!sourceEvent.HasContent(mSourceKey)) {
return true;
}
mSourceKeyOverwritten = false;
bool sourceKeyOverwritten = false;
StringView buffer = sourceEvent.GetContent(mSourceKey);
if (buffer.size() == 0) {
return true;
Expand Down Expand Up @@ -210,7 +210,7 @@ bool ProcessorParseApsaraNative::ProcessEvent(const StringView& logPath,
StringView data(buffer.data() + colon_index + 1, index - colon_index - 1);
AddLog(key, data, sourceEvent);
if (key == mSourceKey) {
mSourceKeyOverwritten = true;
sourceKeyOverwritten = true;
}
colon_index = -1;
}
Expand All @@ -228,7 +228,7 @@ bool ProcessorParseApsaraNative::ProcessEvent(const StringView& logPath,
sb.size = std::min(20, snprintf(sb.data, sb.capacity, "%lld", logTime_in_micro));
#endif
AddLog("microtime", StringView(sb.data, sb.size), sourceEvent);
if (!mSourceKeyOverwritten) {
if (!sourceKeyOverwritten) {
sourceEvent.DelContent(mSourceKey);
}
if (mCommonParserOptions.ShouldAddSourceContent(true)) {
Expand Down
1 change: 0 additions & 1 deletion core/processor/ProcessorParseApsaraNative.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ class ProcessorParseApsaraNative : public Processor {
int32_t ParseApsaraBaseFields(const StringView& buffer, LogEvent& sourceEvent);

int32_t mLogTimeZoneOffsetSecond = 0;
bool mSourceKeyOverwritten = false;

int* mLogGroupSize = nullptr;
int* mParseFailures = nullptr;
Expand Down

0 comments on commit d787724

Please sign in to comment.