Skip to content

Fix listener race condition #303

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

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

Conversation

HashimTheArab
Copy link
Contributor

this causes a "send on nil channel" panic rarely
making sure listener.close is closed first will make the select return and drop further processing
then we can safely close listener.incoming

select {
case <-listener.close:
// The listener was closed while this one was logged in, so the incoming channel will be
// closed. Just return so the connection is closed and cleaned up.
return
case listener.incoming <- conn:
// The connection was previously not logged in, but was after receiving this packet,
// meaning the connection is fully completely now. We add it to the channel so that
// a call to Accept() can receive it.
}

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