Fixup concurrency on mediation runs and stats, improving tutorial CdrStats files

This commit is contained in:
DanB
2014-08-03 16:04:43 +02:00
parent 455379ef97
commit 90fa1465ac
7 changed files with 45 additions and 26 deletions

View File

@@ -175,11 +175,11 @@ func (self *Mediator) RateCdr(storedCdr *utils.StoredCdr, sendToStats bool) erro
}
}
if sendToStats && self.stats != nil { // We send to stats only after saving to db since there are chances we cannot store and then no way to reproduce stats offline
go func() {
go func(cdr *utils.StoredCdr) { // Pass it by value since the variable will be overwritten by for
if err := self.stats.AppendCDR(cdr, nil); err != nil {
Logger.Err(fmt.Sprintf("Could not append cdr to stats (mediator): %s", err.Error()))
}
}()
}(cdr)
}
}
return nil