fix(proxy): align shutdown and custom diff fallback
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
066bc42a89
commit
46231ef0a3
3 changed files with 9 additions and 10 deletions
|
|
@ -183,12 +183,6 @@ func (p *Proxy) Stop() {
|
||||||
server.Stop()
|
server.Stop()
|
||||||
}
|
}
|
||||||
stopHTTPServer(p)
|
stopHTTPServer(p)
|
||||||
if p.accessLogger != nil {
|
|
||||||
p.accessLogger.close()
|
|
||||||
}
|
|
||||||
if p.shareLogger != nil {
|
|
||||||
p.shareLogger.close()
|
|
||||||
}
|
|
||||||
if p.watcher != nil {
|
if p.watcher != nil {
|
||||||
p.watcher.Stop()
|
p.watcher.Stop()
|
||||||
}
|
}
|
||||||
|
|
@ -216,6 +210,13 @@ func (p *Proxy) Stop() {
|
||||||
shutdown.Disconnect()
|
shutdown.Disconnect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if p.accessLogger != nil {
|
||||||
|
p.accessLogger.close()
|
||||||
|
}
|
||||||
|
if p.shareLogger != nil {
|
||||||
|
p.shareLogger.close()
|
||||||
|
}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-p.done:
|
case <-p.done:
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -162,8 +162,6 @@ func (customDiff *CustomDiff) OnLogin(event Event) {
|
||||||
event.Miner.SetCustomDiff(value)
|
event.Miner.SetCustomDiff(value)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
event.Miner.SetCustomDiff(0)
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if customDiff == nil {
|
if customDiff == nil {
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ func TestCustomDiff_OnLogin_Bad(t *testing.T) {
|
||||||
func TestCustomDiff_OnLogin_Ugly(t *testing.T) {
|
func TestCustomDiff_OnLogin_Ugly(t *testing.T) {
|
||||||
miner := &Miner{user: "wallet+bad"}
|
miner := &Miner{user: "wallet+bad"}
|
||||||
NewCustomDiff(100).OnLogin(Event{Miner: miner})
|
NewCustomDiff(100).OnLogin(Event{Miner: miner})
|
||||||
if miner.User() != "wallet+bad" || miner.CustomDiff() != 0 {
|
if miner.User() != "wallet+bad" || miner.CustomDiff() != 100 {
|
||||||
t.Fatalf("expected invalid suffix to preserve user and leave diff unset, got user=%q diff=%d", miner.User(), miner.CustomDiff())
|
t.Fatalf("expected invalid suffix to preserve user and fall back to global diff, got user=%q diff=%d", miner.User(), miner.CustomDiff())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue