mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-10-14 00:59:33 +00:00
Prevent infinite ticker leaks in kaspaminer (#1476)
* Prevent infinite tickers leaks in kaspaminer * Reset ticker in ConnectionManager instead of allocating a new one Co-authored-by: Ori Newman <orinewman1@gmail.com>
This commit is contained in:
parent
d281dabdb4
commit
280fa3de46
@ -167,6 +167,8 @@ func templatesLoop(client *minerClient, miningAddr util.Address,
|
|||||||
newTemplateChan <- template
|
newTemplateChan <- template
|
||||||
}
|
}
|
||||||
getBlockTemplate()
|
getBlockTemplate()
|
||||||
|
const tickerTime = 500 * time.Millisecond
|
||||||
|
ticker := time.NewTicker(tickerTime)
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-stopChan:
|
case <-stopChan:
|
||||||
@ -174,7 +176,8 @@ func templatesLoop(client *minerClient, miningAddr util.Address,
|
|||||||
return
|
return
|
||||||
case <-client.blockAddedNotificationChan:
|
case <-client.blockAddedNotificationChan:
|
||||||
getBlockTemplate()
|
getBlockTemplate()
|
||||||
case <-time.Tick(500 * time.Millisecond):
|
ticker.Reset(tickerTime)
|
||||||
|
case <-ticker.C:
|
||||||
getBlockTemplate()
|
getBlockTemplate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -147,8 +147,7 @@ func (c *ConnectionManager) IsBanned(netConnection *netadapter.NetConnection) (b
|
|||||||
func (c *ConnectionManager) waitTillNextIteration() {
|
func (c *ConnectionManager) waitTillNextIteration() {
|
||||||
select {
|
select {
|
||||||
case <-c.resetLoopChan:
|
case <-c.resetLoopChan:
|
||||||
c.loopTicker.Stop()
|
c.loopTicker.Reset(connectionsLoopInterval)
|
||||||
c.loopTicker = time.NewTicker(connectionsLoopInterval)
|
|
||||||
case <-c.loopTicker.C:
|
case <-c.loopTicker.C:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user