Improve error handling when Bitmask.Init fails, fixes #855
The segfault happens in gatewaychecker.go.:
// The gateway selector gets populated asynchronously, so this spawns a goroutine that
// checks whether they've been fetched to update status.
func (c connectionCtx) delayCheckForGateways() {
go func() {
cnt := 0
for {
if cnt > 60*2 {
break
}
cnt += 1
time.Sleep(time.Second * 5)
transport := c.bm.GetTransport()
locs := c.bm.GetLocationQualityMap(transport)
if len(locs) != 0 {
c.Locations = locs
updateStatusForGateways()
break
}
}
}()
}
Having a hardcoded sleep of 5 seconds is bad. The problem is that c.bm
is nil. We can use c.IsReady
to fix this
Edited by Pea Nut