mirror of
https://github.com/anyproto/anytype-heart.git
synced 2025-06-08 05:47:07 +09:00
Merge pull request #2428 from anyproto/go-5663-fix-race-condition-in-addmessage
GO-5663: Chats: AddMessage: fix events race condition
This commit is contained in:
commit
131ebc7882
2 changed files with 7 additions and 1 deletions
|
@ -157,7 +157,6 @@ func (s *subscriptionManager) Flush() {
|
|||
if s.sessionContext != nil {
|
||||
s.sessionContext.SetMessages(s.chatId, events)
|
||||
s.eventSender.BroadcastToOtherSessions(s.sessionContext.ID(), ev)
|
||||
s.sessionContext = nil
|
||||
} else if s.IsActive() {
|
||||
s.eventSender.Broadcast(ev)
|
||||
}
|
||||
|
|
|
@ -217,7 +217,14 @@ func (s *storeObject) AddMessage(ctx context.Context, sessionCtx session.Context
|
|||
return "", fmt.Errorf("create chat: %w", err)
|
||||
}
|
||||
|
||||
s.subscription.Lock()
|
||||
s.subscription.SetSessionContext(sessionCtx)
|
||||
s.subscription.Unlock()
|
||||
defer func() {
|
||||
s.subscription.Lock()
|
||||
s.subscription.SetSessionContext(nil)
|
||||
s.subscription.Unlock()
|
||||
}()
|
||||
messageId, err := s.storeSource.PushStoreChange(ctx, source.PushStoreChangeParams{
|
||||
Changes: builder.ChangeSet,
|
||||
State: s.store,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue