mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-28 19:41:29 +00:00
Fix missing context in geo resources download
This commit is contained in:
parent
17584c245f
commit
c60a944aac
|
@ -143,14 +143,16 @@ func create() (*box.Box, context.CancelFunc, error) {
|
||||||
signal.Stop(osSignals)
|
signal.Stop(osSignals)
|
||||||
close(osSignals)
|
close(osSignals)
|
||||||
}()
|
}()
|
||||||
|
startCtx, finishStart := context.WithCancel(context.Background())
|
||||||
go func() {
|
go func() {
|
||||||
_, loaded := <-osSignals
|
_, loaded := <-osSignals
|
||||||
if loaded {
|
if loaded {
|
||||||
cancel()
|
cancel()
|
||||||
|
closeMonitor(startCtx)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
err = instance.Start()
|
err = instance.Start()
|
||||||
|
finishStart()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cancel()
|
cancel()
|
||||||
return nil, nil, E.Cause(err, "start service")
|
return nil, nil, E.Cause(err, "start service")
|
||||||
|
|
|
@ -173,7 +173,11 @@ func (r *Router) downloadGeoIPDatabase(savePath string) error {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
defer httpClient.CloseIdleConnections()
|
defer httpClient.CloseIdleConnections()
|
||||||
response, err := httpClient.Get(downloadURL)
|
request, err := http.NewRequest("GET", downloadURL, nil)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
response, err := httpClient.Do(request.WithContext(r.ctx))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -221,7 +225,11 @@ func (r *Router) downloadGeositeDatabase(savePath string) error {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
defer httpClient.CloseIdleConnections()
|
defer httpClient.CloseIdleConnections()
|
||||||
response, err := httpClient.Get(downloadURL)
|
request, err := http.NewRequest("GET", downloadURL, nil)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
response, err := httpClient.Do(request.WithContext(r.ctx))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue