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 the issue that the session's Close method could be invoked multi times #372

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

Conversation

bruce1125
Copy link
Contributor

Although the framework uses a sync.map and some check logic to prevent the SYNC issue, there is possibility to trigger in some situation.

…times,and sometimes deletes the new session caused by goroutine SYNC issue
@bruce1125
Copy link
Contributor Author

There is a possibility that the method is invoked from HandlerService.Handle's defer logic at the same time from different goroutine.
So, we need to make sure two things:

  1. ensure the Close method's logic is done only once, for the reason to prevent deleting the new one
  2. double check that there isn't a session in the store data before Storing

// so we need to make sure two things:
// 1. ensure the Close method's logic is done only once, for the reason to prevent deleting the new one
// 2. double check that there isn't a session in the store data before Storing
for s.pool.GetSessionByUID(uid) != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we put a timeout here so that this doesn't turn into a dead lock in corner cases?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, That's great. But I am not sure that how much timeout value we could set, is 30s enough? Or set the loop counter limit directly?

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

2 participants