From e6045a3cf599350471169b66e0ad24f97cbf4d23 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Wed, 10 Feb 2021 20:59:50 +0200 Subject: [PATCH] Fix bug if portal sync finishes early --- user.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/user.go b/user.go index 2bbe64d..b343575 100644 --- a/user.go +++ b/user.go @@ -176,8 +176,8 @@ func (bridge *Bridge) NewUser(dbUser *database.User) *User { IsRelaybot: false, - chatListReceived: make(chan struct{}), - syncPortalsDone: make(chan struct{}), + chatListReceived: make(chan struct{}, 1), + syncPortalsDone: make(chan struct{}, 1), syncStart: make(chan struct{}, 1), messageInput: make(chan PortalMessage), messageOutput: make(chan PortalMessage, bridge.Config.Bridge.UserMessageBuffer), @@ -453,8 +453,8 @@ func (user *User) PostLogin() { user.log.Debugln("Locking processing of incoming messages and starting post-login sync") // TODO can an old sync still be ongoing when PostLogin is called again? // TODO 2: can the new sync happen before this happens? - user.chatListReceived = make(chan struct{}) - user.syncPortalsDone = make(chan struct{}) + user.chatListReceived = make(chan struct{}, 1) + user.syncPortalsDone = make(chan struct{}, 1) user.syncWait.Add(1) user.syncStart <- struct{}{} go user.intPostLogin(user.Conn)