Skip to content

Commit

Permalink
fix: add queue after server stopped
Browse files Browse the repository at this point in the history
  • Loading branch information
pcmid committed Dec 11, 2024
1 parent 8d2955e commit a05cbd2
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -810,15 +810,14 @@ func (srv *Server) AddQueue(qname string, priority, concurrency int) {
return
}

srv.queues[qname] = priority

srv.state.mu.Lock()
state := srv.state.value
srv.state.mu.Unlock()
if state == srvStateNew || state == srvStateClosed {
srv.queues[qname] = priority
srv.state.mu.Unlock()
return
}
srv.state.mu.Unlock()

srv.logger.Info("restart server...")
srv.forwarder.shutdown()
Expand All @@ -832,6 +831,8 @@ func (srv *Server) AddQueue(qname string, priority, concurrency int) {
srv.heartbeater.shutdown()
srv.wg.Wait()

srv.queues[qname] = priority

qnames := make([]string, 0, len(srv.queues))
for q := range srv.queues {
qnames = append(qnames, q)
Expand Down

0 comments on commit a05cbd2

Please sign in to comment.