mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-08-30 01:40:55 +00:00
Bugfixes: div0, wrong low-mem condition, race
This commit is contained in:
parent
bbe8b41fed
commit
18c1abd3e3
3 changed files with 24 additions and 12 deletions
|
@ -12,6 +12,7 @@ import (
|
|||
"net/url"
|
||||
"os"
|
||||
"os/signal"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
|
@ -108,16 +109,21 @@ func SetupServerAndHandle(config *ConfigFile, serveMux *http.ServeMux) {
|
|||
logstasher.Setup(Configuration.ESServer, Configuration.ESIndexPrefix, Configuration.ESHostName)
|
||||
}
|
||||
|
||||
janitorsOnce.Do(func() {
|
||||
go authorizationJanitor()
|
||||
go bunchCacheJanitor()
|
||||
go pubsubJanitor()
|
||||
go aggregateDataSender()
|
||||
go commandCounter()
|
||||
janitorsOnce.Do(startJanitors)
|
||||
}
|
||||
|
||||
go ircConnection()
|
||||
go shutdownHandler()
|
||||
})
|
||||
// startJanitors starts the 'is_init_func' goroutines
|
||||
func startJanitors() {
|
||||
loadUniqueUsers()
|
||||
|
||||
go authorizationJanitor()
|
||||
go bunchCacheJanitor()
|
||||
go pubsubJanitor()
|
||||
go aggregateDataSender()
|
||||
go commandCounter()
|
||||
|
||||
go ircConnection()
|
||||
go shutdownHandler()
|
||||
}
|
||||
|
||||
func shutdownHandler() {
|
||||
|
@ -169,7 +175,7 @@ func HTTPHandleRootURL(w http.ResponseWriter, r *http.Request) {
|
|||
if r.Header.Get("Connection") == "Upgrade" {
|
||||
updateSysMem()
|
||||
|
||||
if Statistics.SysMemTotalKB-Statistics.SysMemFreeKB < Configuration.MinMemoryKBytes {
|
||||
if Statistics.SysMemFreeKB > 0 && Statistics.SysMemFreeKB < Configuration.MinMemoryKBytes {
|
||||
atomic.AddUint64(&Statistics.LowMemDroppedConnections, 1)
|
||||
w.WriteHeader(503)
|
||||
return
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue