Skip to content

Commit

Permalink
Fixed race condition while accessing state, updated code as per spec
Browse files Browse the repository at this point in the history
  • Loading branch information
sacOO7 committed Dec 5, 2023
1 parent e4ef0ce commit 5d5660d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions ably/realtime_channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -797,10 +797,12 @@ func (c *RealtimeChannel) notify(msg *protocolMessage) {
if msg.Flags != 0 {
c.setModes(channelModeFromFlag(msg.Flags))
}
// RTL12
if c.state == ChannelStateAttached && !msg.Flags.Has(flagResumed) {
c.emitErrorUpdate(newErrorFromProto(msg.Error), false) // RTL12
c.Presence.onAttach(msg, false)

if c.State() == ChannelStateAttached {
if !msg.Flags.Has(flagResumed) { // RTL12
c.Presence.onAttach(msg, true)
c.emitErrorUpdate(newErrorFromProto(msg.Error), false)
}
} else {
c.Presence.onAttach(msg, true)
c.setState(ChannelStateAttached, newErrorFromProto(msg.Error), msg.Flags.Has(flagResumed))
Expand Down

0 comments on commit 5d5660d

Please sign in to comment.