les:flowcontrol: fix division by zero for lightserv flag

This commit is contained in:
Bas van Kervel 2017-03-27 11:09:02 +02:00
parent 525116dbff
commit 43064d8ddd
No known key found for this signature in database
GPG key ID: BFB23B252EF5812B

View file

@ -81,10 +81,14 @@ func NewClientManager(rcTarget, maxSimReq, maxRcSum uint64) *ClientManager {
cm := &ClientManager{ cm := &ClientManager{
nodes: make(map[*cmNode]struct{}), nodes: make(map[*cmNode]struct{}),
resumeQueue: make(chan chan bool), resumeQueue: make(chan chan bool),
rcRecharge: rcConst * rcConst / (100*rcConst/rcTarget - rcConst), rcRecharge: rcConst * rcConst,
maxSimReq: maxSimReq, maxSimReq: maxSimReq,
maxRcSum: maxRcSum, maxRcSum: maxRcSum,
} }
if rcTarget < 100 {
cm.rcRecharge /= (100*rcConst/rcTarget - rcConst)
}
go cm.queueProc() go cm.queueProc()
return cm return cm
} }