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

Refresh can reset the session #562

Open
Gilthoniel opened this issue Jun 6, 2023 · 0 comments
Open

Refresh can reset the session #562

Gilthoniel opened this issue Jun 6, 2023 · 0 comments

Comments

@Gilthoniel
Copy link

Hi,

Before going deeper into a fix, I'd like your opinion on this: if a refresh is occurring while messages are still attempted to be sent, it can happen that the session is reset. See:

	if session.RefreshOnLogon {
		if err := session.store.Refresh(); err != nil {
			session.logError(err)
			return
		}
	}
	session.log.OnEvent("Sending logon request")
	if err := session.sendLogon(); err != nil {
		session.logError(err)
		return
	}
// queueForSend will validate, persist, and queue the message for send
func (s *session) queueForSend(msg *Message) error {
	s.sendMutex.Lock()
	defer s.sendMutex.Unlock()

The store is usually protected against concurrent calls with the sendMutex of the session, but when a refresh is happening, the store can be called concurrently with queueForSend and store.Refresh(). Knowing that the refresh first reset the cache then goes into the database to populate it again, it can happen that sending resets the outgoing sequence number to 1.

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

No branches or pull requests

1 participant