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

Test race condition #55

Closed

Conversation

DanielePalaia
Copy link
Contributor

Some unit tests in connection were showing a race condition (see #31):

These ones were the ones testing Open scenarios. The issue is that Open and Close, rwc.Open and rwc.Close can at the same time write on:

c.allocator = newAllocator(1, c.Config.ChannelMax)
connection.go line 444 and
connection.go line 849

while shutdown is protected by the structure mutex m, OpenComplete() is not causing the race.

Daniele Palaia added 2 commits March 24, 2022 15:32
…itmq#31):

These ones were the ones testing Open scenarios. The issue is that Open and Close, rwc.Open and rwc.Close can at the same time write on:

c.allocator = newAllocator(1, c.Config.ChannelMax)
connection.go line 444 and
connection.go line 849

while shutdown is protected by the structure mutex m, OpenComplete() is not causing the race.

Not sure if the library should be protected in this case adding Lock also in OpenComplete().
In any case the tests were just testing Open, so the rwc.Close() can be moved in the main function at the end avoiding the race and not affected the test functionality
@DanielePalaia
Copy link
Contributor Author

Will be replaced by a new one

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.

None yet

1 participant