Skip to content

Commit

Permalink
nsqd: retry sub to ephemeral topic/channel which is Exiting
Browse files Browse the repository at this point in the history
quick hacky fix, instead of "proper" locking
  • Loading branch information
ploxiln committed May 8, 2017
1 parent 71734e9 commit 19da9a4
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions nsqd/protocol_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -615,10 +615,19 @@ func (p *protocolV2) SUB(client *clientV2, params [][]byte) ([]byte, error) {
return nil, err
}

topic := p.ctx.nsqd.GetTopic(topicName)
channel := topic.GetChannel(channelName)
channel.AddClient(client.ID, client)
var channel *Channel
for {
topic := p.ctx.nsqd.GetTopic(topicName)
channel = topic.GetChannel(channelName)
channel.AddClient(client.ID, client)

if (channel.ephemeral && channel.Exiting()) || (topic.ephemeral && topic.Exiting()) {
channel.RemoveClient(client.ID)
time.Sleep(1 * time.Millisecond)
continue
}
break
}
atomic.StoreInt32(&client.State, stateSubscribed)
client.Channel = channel
// update message pump
Expand Down

0 comments on commit 19da9a4

Please sign in to comment.