mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-18 08:16:39 +00:00
Fix deadlock
This commit is contained in:
@@ -177,6 +177,7 @@ func (u *UpdateManager) handleUpdate(ctx context.Context) {
|
|||||||
|
|
||||||
u.expectedVersionMutex.Lock()
|
u.expectedVersionMutex.Lock()
|
||||||
if u.update == nil {
|
if u.update == nil {
|
||||||
|
u.expectedVersionMutex.Unlock()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
expectedVersion := u.expectedVersion
|
expectedVersion := u.expectedVersion
|
||||||
@@ -319,7 +320,7 @@ func downloadFileToTemporaryDir(ctx context.Context, fileURL string) (string, er
|
|||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := out.Close(); err != nil {
|
if err := out.Close(); err != nil {
|
||||||
log.Errorf("Error closing temporary file: %v", err)
|
log.Errorf("error closing temporary file: %v", err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
@@ -337,12 +338,17 @@ func downloadFileToTemporaryDir(ctx context.Context, fileURL string) (string, er
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
if resp.StatusCode != http.StatusOK {
|
||||||
|
log.Errorf("error downloading update file, received status code: %d", resp.StatusCode)
|
||||||
|
return "", fmt.Errorf("error downloading file, received status code: %d", resp.StatusCode)
|
||||||
|
}
|
||||||
|
|
||||||
_, err = io.Copy(out, resp.Body)
|
_, err = io.Copy(out, resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("error downloading file: %w", err)
|
return "", fmt.Errorf("error downloading file: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Tracef("Downloaded update file to %s", out.Name())
|
log.Debugf("downloaded update file to %s", out.Name())
|
||||||
|
|
||||||
return out.Name(), nil
|
return out.Name(), nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user