-
Notifications
You must be signed in to change notification settings - Fork 958
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
Add Mutex on Top of p2p Feeds Map #321
Changes from all commits
218cb8d
c2b0460
a4860e0
297c4c0
a098347
7ced763
371fbbf
2ad008f
995319c
841074e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,8 +35,11 @@ func (s *Server) Feed(msg interface{}) *event.Feed { | |
t = reflect.TypeOf(msg) | ||
} | ||
|
||
s.mutex.Lock() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, done. |
||
defer s.mutex.Unlock() | ||
if s.feeds[t] == nil { | ||
s.feeds[t] = new(event.Feed) | ||
} | ||
|
||
return s.feeds[t] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package p2p | ||
|
||
import "testing" | ||
|
||
func TestFeed_ConcurrentWrite(t *testing.T) { | ||
s, err := NewServer() | ||
if err != nil { | ||
t.Fatalf("could not create server %v", err) | ||
} | ||
|
||
for i := 0; i < 5; i++ { | ||
go s.Feed("a") | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this changed ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, I think this was to fix the mac issue we ran into a month back
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@terenc3t about the reasons for this change see #321 (comment), if
0.13.0
is required i'lll remove the concurrent write unit test and the disable the race detector again, it can be added once0.13.0
(or a higher version) supports it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a comment stating that rules_go should not be updated until that specific bug has been resolved.
The Mac issue that others were referring to had to do with bazel itself, not these rules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, added comment with a link to the bug.