Skip to content

Commit

Permalink
fix: resolve race condition in ES buffer write
Browse files Browse the repository at this point in the history
  • Loading branch information
BoyChai committed Jan 21, 2025
1 parent b148743 commit eb70008
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion output/elasticsearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ func (e *Elasticsearch) WriteRecord(record *evtx.EventRecord) error {
}

// 将数据加入缓存
bufferLock.Lock()
recordBuffer = append(recordBuffer, data)

bufferLock.Lock()
// 当缓存达到一定大小时,执行批量写入
if len(recordBuffer) >= bufferLimit {
go e.do()
Expand Down

0 comments on commit eb70008

Please sign in to comment.