mirror of
https://github.com/safing/portbase
synced 2025-04-17 16:09:08 +00:00
Implement review suggestions
This commit is contained in:
parent
483cbad600
commit
ac0a5176b3
3 changed files with 13 additions and 14 deletions
|
@ -272,7 +272,7 @@ func (e *Endpoint) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
// Wait for the owning module to be ready.
|
||||
if !moduleIsReady(e.BelongsTo) {
|
||||
http.Error(w, "The API endpoint is not ready yet. Please try again later.", http.StatusServiceUnavailable)
|
||||
http.Error(w, "The API endpoint is not ready yet or the its module is not enabled. Please try again later.", http.StatusServiceUnavailable)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -24,23 +24,23 @@ func GetNextBlock(data []byte) ([]byte, int, error) {
|
|||
// EncodedSize returns the size required to varint-encode an uint.
|
||||
func EncodedSize(n uint64) (size int) {
|
||||
switch {
|
||||
case n < 128:
|
||||
case n < 1<<7: // < 128
|
||||
return 1
|
||||
case n < 16384:
|
||||
case n < 1<<14: // < 16384
|
||||
return 2
|
||||
case n < 2097152:
|
||||
case n < 1<<21: // < 2097152
|
||||
return 3
|
||||
case n < 268435456:
|
||||
case n < 1<<28: // < 268435456
|
||||
return 4
|
||||
case n < 34359738368:
|
||||
case n < 1<<35: // < 34359738368
|
||||
return 5
|
||||
case n < 4398046511104:
|
||||
case n < 1<<42: // < 4398046511104
|
||||
return 6
|
||||
case n < 562949953421312:
|
||||
case n < 1<<49: // < 562949953421312
|
||||
return 7
|
||||
case n < 72057594037927936:
|
||||
case n < 1<<56: // < 72057594037927936
|
||||
return 8
|
||||
case n < 9223372036854775808:
|
||||
case n < 1<<63: // < 9223372036854775808
|
||||
return 9
|
||||
default:
|
||||
return 10
|
||||
|
|
|
@ -224,10 +224,11 @@ func (m *Module) checkIfStopComplete() {
|
|||
}
|
||||
|
||||
func (m *Module) stop(reports chan *report) {
|
||||
// check and set intermediate status
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
|
||||
// check and set intermediate status
|
||||
if m.status != StatusOnline {
|
||||
m.Unlock()
|
||||
go func() {
|
||||
reports <- &report{
|
||||
module: m,
|
||||
|
@ -249,8 +250,6 @@ func (m *Module) stop(reports chan *report) {
|
|||
m.stopFlag.Set()
|
||||
m.cancelCtx()
|
||||
|
||||
m.Unlock()
|
||||
|
||||
go m.stopAllTasks(reports, stopComplete)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue