Skip to content

Commit

Permalink
when topic destroying. make nsqd won't assign any new client into it
Browse files Browse the repository at this point in the history
fix #883
  • Loading branch information
slayercat committed Apr 17, 2017
1 parent 75f215b commit 4c42cab
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions nsqd/nsqd.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,13 +501,12 @@ func (n *NSQD) GetExistingTopic(topicName string) (*Topic, error) {

// DeleteExistingTopic removes a topic only if it exists
func (n *NSQD) DeleteExistingTopic(topicName string) error {
n.RLock()
n.Lock()
topic, ok := n.topicMap[topicName]
if !ok {
n.RUnlock()
n.Unlock()
return errors.New("topic does not exist")
}
n.RUnlock()

// delete empties all channels and the topic itself before closing
// (so that we dont leave any messages around)
Expand All @@ -517,7 +516,6 @@ func (n *NSQD) DeleteExistingTopic(topicName string) error {
// to enforce ordering
topic.Delete()

n.Lock()
delete(n.topicMap, topicName)
n.Unlock()

Expand Down

0 comments on commit 4c42cab

Please sign in to comment.