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

Prevent concurrent map read and write #503

Merged
merged 1 commit into from
May 21, 2019
Merged

Prevent concurrent map read and write #503

merged 1 commit into from
May 21, 2019

Conversation

yilunzhang
Copy link
Member

Just saw 2 panic cause by concurrent map read and write. This patch use sync.Map to prevent it.

Type (put an x where ever applicable)

  • Bug fix: Link to the issue
  • Feature (Non-breaking change)
  • Feature (Breaking change)
  • Documentation Improvement

Checklist

Please put an x against the checkboxes. Write a small comment explaining if its N/A (not applicable)

  • Read the CONTRIBUTION guidelines.
  • All the tests are passing after the introduction of new changes.
  • Added tests respective to the part of code I have written.
  • Added proper documentation where ever applicable (in code and README.md).
  • Code has been written according to NKN-Golang-Style-Guide

Extra information

Any extra information related to this pull request.

}
return true
})
tp.TxLists.Range(func(_, v interface{}) bool {
Copy link
Member

Choose a reason for hiding this comment

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

Why traversed tp.TxLists twice? Would tp.TxLists iterator be influenced by v.CleanOrphans?
What happen if

tp.TxLists.Range( 
    func(_, v interface{}) bool {
        ......
        v.ProcessOrphans(...)
        v.CleanOrphans(nil)
        ......
        return true
    }
)

}
return true
})
tp.TxLists.Range(func(_, v interface{}) bool {
Copy link
Member

Choose a reason for hiding this comment

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

Same as above comments.

@yilunzhang
Copy link
Member Author

yilunzhang commented May 20, 2019 via email

Signed-off-by: Yilun <zyl.skysniper@gmail.com>
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