mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-11-28 03:11:01 +00:00
bump go-runners version to fix possible race in Processing{Media,Emoji} (#1646)
Signed-off-by: kim <grufwub@gmail.com>
This commit is contained in:
parent
e8595f0c64
commit
883dc5476b
4 changed files with 25 additions and 19 deletions
2
go.mod
2
go.mod
|
@ -12,7 +12,7 @@ require (
|
|||
codeberg.org/gruf/go-kv v1.6.1
|
||||
codeberg.org/gruf/go-logger/v2 v2.2.1
|
||||
codeberg.org/gruf/go-mutexes v1.1.5
|
||||
codeberg.org/gruf/go-runners v1.6.0
|
||||
codeberg.org/gruf/go-runners v1.6.1
|
||||
codeberg.org/gruf/go-sched v1.2.3
|
||||
codeberg.org/gruf/go-store/v2 v2.2.1
|
||||
github.com/KimMachineGun/automemlimit v0.2.4
|
||||
|
|
4
go.sum
4
go.sum
|
@ -79,8 +79,8 @@ codeberg.org/gruf/go-mutexes v1.1.5 h1:8Y8DwCGf24MyzOSaPvLrtk/B4ecVx4z+fppL6dY+P
|
|||
codeberg.org/gruf/go-mutexes v1.1.5/go.mod h1:1j/6/MBeBQUedAtAtysLLnBKogfOZAxdym0E3wlaBD8=
|
||||
codeberg.org/gruf/go-pools v1.1.0 h1:LbYP24eQLl/YI1fSU2pafiwhGol1Z1zPjRrMsXpF88s=
|
||||
codeberg.org/gruf/go-pools v1.1.0/go.mod h1:ZMYpt/DjQWYC3zFD3T97QWSFKs62zAUGJ/tzvgB9D68=
|
||||
codeberg.org/gruf/go-runners v1.6.0 h1:cAHKxMgtkb3v6it4qZZs4fo+yYgICNCrYvFlayuvSdk=
|
||||
codeberg.org/gruf/go-runners v1.6.0/go.mod h1:QRcSExqXX8DM0rm8Xs6qX7baOzyvw0JIe4mu3TsQT+Y=
|
||||
codeberg.org/gruf/go-runners v1.6.1 h1:0KNiEfGnmNUs9intqxEAWqIKUyxVOmYTtn3kPVOHsjQ=
|
||||
codeberg.org/gruf/go-runners v1.6.1/go.mod h1:QRcSExqXX8DM0rm8Xs6qX7baOzyvw0JIe4mu3TsQT+Y=
|
||||
codeberg.org/gruf/go-sched v1.2.3 h1:H5ViDxxzOBR3uIyGBCf0eH8b1L8wMybOXcdtUUTXZHk=
|
||||
codeberg.org/gruf/go-sched v1.2.3/go.mod h1:vT9uB6KWFIIwnG9vcPY2a0alYNoqdL1mSzRM8I+PK7A=
|
||||
codeberg.org/gruf/go-store/v2 v2.2.1 h1:lbvMjhMLebefiaPNLtWvPySKSYM5xN1aztSxxz+vCzU=
|
||||
|
|
36
vendor/codeberg.org/gruf/go-runners/process.go
generated
vendored
36
vendor/codeberg.org/gruf/go-runners/process.go
generated
vendored
|
@ -15,8 +15,7 @@ type Processable func() error
|
|||
// that only a single instance of it is ever running at any one time.
|
||||
type Processor struct {
|
||||
mutex sync.Mutex
|
||||
state uint32
|
||||
wait sync.WaitGroup
|
||||
wait *sync.WaitGroup
|
||||
err *error
|
||||
}
|
||||
|
||||
|
@ -26,24 +25,34 @@ func (p *Processor) Process(proc Processable) (err error) {
|
|||
// Acquire state lock.
|
||||
p.mutex.Lock()
|
||||
|
||||
if p.state != 0 {
|
||||
if p.wait != nil {
|
||||
// Already running.
|
||||
//
|
||||
// Get current err ptr.
|
||||
// Get current ptrs.
|
||||
waitPtr := p.wait
|
||||
errPtr := p.err
|
||||
|
||||
// Wait until finish.
|
||||
// Free state lock.
|
||||
p.mutex.Unlock()
|
||||
p.wait.Wait()
|
||||
|
||||
// Wait for finish.
|
||||
waitPtr.Wait()
|
||||
return *errPtr
|
||||
}
|
||||
|
||||
// Reset error ptr.
|
||||
p.err = new(error)
|
||||
// Alloc waiter for new process.
|
||||
var wait sync.WaitGroup
|
||||
|
||||
// No need to alloc new error as
|
||||
// we use the alloc'd named error
|
||||
// return required for panic handling.
|
||||
|
||||
// Reset ptrs.
|
||||
p.wait = &wait
|
||||
p.err = &err
|
||||
|
||||
// Set started.
|
||||
p.wait.Add(1)
|
||||
p.state = 1
|
||||
wait.Add(1)
|
||||
p.mutex.Unlock()
|
||||
|
||||
defer func() {
|
||||
|
@ -57,15 +66,12 @@ func (p *Processor) Process(proc Processable) (err error) {
|
|||
err = fmt.Errorf("caught panic: %v", r)
|
||||
}
|
||||
|
||||
// Store error.
|
||||
*p.err = err
|
||||
|
||||
// Mark done.
|
||||
p.wait.Done()
|
||||
wait.Done()
|
||||
|
||||
// Set stopped.
|
||||
p.mutex.Lock()
|
||||
p.state = 0
|
||||
p.wait = nil
|
||||
p.mutex.Unlock()
|
||||
}()
|
||||
|
||||
|
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
|
@ -58,7 +58,7 @@ codeberg.org/gruf/go-mutexes
|
|||
# codeberg.org/gruf/go-pools v1.1.0
|
||||
## explicit; go 1.16
|
||||
codeberg.org/gruf/go-pools
|
||||
# codeberg.org/gruf/go-runners v1.6.0
|
||||
# codeberg.org/gruf/go-runners v1.6.1
|
||||
## explicit; go 1.19
|
||||
codeberg.org/gruf/go-runners
|
||||
# codeberg.org/gruf/go-sched v1.2.3
|
||||
|
|
Loading…
Reference in a new issue