mirror of
https://codeberg.org/davrot/forgejo.git
synced 2025-05-16 20:00:03 +02:00
Reduce data races (#14549)
* Add race conditions into test * Fix Race in GetManager() * DataAsync() use error chan * just log no chan * finish
This commit is contained in:
parent
0d1444751f
commit
87009ab40a
3 changed files with 18 additions and 6 deletions
|
@ -25,6 +25,7 @@ var (
|
|||
// ErrExecTimeout represent a timeout error
|
||||
ErrExecTimeout = errors.New("Process execution timeout")
|
||||
manager *Manager
|
||||
managerInit sync.Once
|
||||
|
||||
// DefaultContext is the default context to run processing commands in
|
||||
DefaultContext = context.Background()
|
||||
|
@ -48,11 +49,11 @@ type Manager struct {
|
|||
|
||||
// GetManager returns a Manager and initializes one as singleton if there's none yet
|
||||
func GetManager() *Manager {
|
||||
if manager == nil {
|
||||
managerInit.Do(func() {
|
||||
manager = &Manager{
|
||||
processes: make(map[int64]*Process),
|
||||
}
|
||||
}
|
||||
})
|
||||
return manager
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue