Skip to content
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

fix: forwarders并发冲突问题 #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yiqiwang-17
Copy link
Collaborator

No description provided.

@@ -378,6 +380,7 @@ func (h *FileHarvester) Run() {
h.readerDone.Add(1)
go h.loopRead()
} else {
h.forwardersLock.Lock()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

对于读操作,使用读锁。

@@ -449,8 +453,13 @@ func (h *FileHarvester) forward(message reader.Message, err error) {
message: message,
error: err,
}

reuseReaders := make([]*ReuseHarvester, 0)
h.forwardersLock.Lock()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

对于读操作,使用读锁。

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

478 行的代码看起来又是写操作。

delete(h.forwarders, reuseReader.HarvesterID), 这里也需要加锁保护。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants