Skip to content

Commit

Permalink
when deleting topic use del.Hard instead of defaulting to true
Browse files Browse the repository at this point in the history
  • Loading branch information
or-else committed Apr 14, 2020
1 parent 0a31207 commit abb2a7b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions server/hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ func (h *Hub) run() {
log.Println("hub: topic's broadcast queue is full", dst.name)
}
}
} else if (strings.HasPrefix(msg.rcptto, "usr") || strings.HasPrefix(msg.rcptto, "grp")) && globals.cluster.isRemoteTopic(msg.rcptto) {
} else if (strings.HasPrefix(msg.rcptto, "usr") || strings.HasPrefix(msg.rcptto, "grp")) &&
globals.cluster.isRemoteTopic(msg.rcptto) {
// It is a remote topic.
if err := globals.cluster.routeToTopicIntraCluster(msg.rcptto, msg); err != nil {
log.Printf("hub: routing to '%s' failed", msg.rcptto)
Expand Down Expand Up @@ -364,7 +365,7 @@ func (h *Hub) topicUnreg(sess *Session, topic string, msg *ClientComMessage, rea
// Case 1.1.1: requester is the owner or last sub in a p2p topic

t.markPaused(true)
if err := store.Topics.Delete(topic, true); err != nil {
if err := store.Topics.Delete(topic, msg.Del.Hard); err != nil {
t.markPaused(false)
sess.queueOut(ErrUnknown(msg.id, msg.topic, now))
return err
Expand Down Expand Up @@ -422,7 +423,7 @@ func (h *Hub) topicUnreg(sess *Session, topic string, msg *ClientComMessage, rea

if tcat == types.TopicCatP2P && len(subs) < 2 {
// This is a P2P topic and fewer than 2 subscriptions, delete the entire topic
if err := store.Topics.Delete(topic, true); err != nil {
if err := store.Topics.Delete(topic, msg.Del.Hard); err != nil {
sess.queueOut(ErrUnknown(msg.id, msg.topic, now))
return err
}
Expand Down Expand Up @@ -454,7 +455,7 @@ func (h *Hub) topicUnreg(sess *Session, topic string, msg *ClientComMessage, rea
} else {
// Case 1.2.1.1: owner, delete the group topic from db.
// Only group topics have owners.
if err := store.Topics.Delete(topic, true); err != nil {
if err := store.Topics.Delete(topic, msg.Del.Hard); err != nil {
sess.queueOut(ErrUnknown(msg.id, msg.topic, now))
return err
}
Expand Down

0 comments on commit abb2a7b

Please sign in to comment.