reverted to good add queue version

This commit is contained in:
Radu Ioan Fericean
2015-06-30 14:04:46 +03:00
parent 137bd4a8d5
commit be59d92ee4

View File

@@ -75,9 +75,9 @@ func newQueueSaver(saveInterval time.Duration, sq *StatsQueue, adb AccountingSto
}
func (svr *queueSaver) stop() {
svr.sq.Save(svr.accountingDb)
svr.ticker.Stop()
svr.stopper <- true
svr.sq.Save(svr.accountingDb)
}
func NewStats(ratingDb RatingStorage, accountingDb AccountingStorage, saveInterval time.Duration) *Stats {
@@ -120,10 +120,15 @@ func (s *Stats) AddQueue(cs *CdrStats, out *int) error {
if s.queueSavers == nil {
s.queueSavers = make(map[string]*queueSaver)
}
if sq, exists := s.queues[cs.Id]; exists {
var sq *StatsQueue
var exists bool
if sq, exists = s.queues[cs.Id]; exists {
sq.UpdateConf(cs)
} else {
s.queues[cs.Id] = NewStatsQueue(cs)
sq = NewStatsQueue(cs)
s.queues[cs.Id] = sq
}
if _, exists = s.queueSavers[sq.GetId()]; !exists {
s.setupQueueSaver(sq)
}
return nil