mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-11 10:07:28 -06:00
[bugfix] Fix possible race condition in federatingdb (#490)
Signed-off-by: kim <grufwub@gmail.com>
This commit is contained in:
parent
8e80f983b3
commit
cc5f2e98b7
11 changed files with 131 additions and 220 deletions
8
vendor/github.com/superseriousbusiness/activity/pub/handlers.go
generated
vendored
8
vendor/github.com/superseriousbusiness/activity/pub/handlers.go
generated
vendored
|
|
@ -64,18 +64,20 @@ func NewActivityStreamsHandlerScheme(db Database, clock Clock, scheme string) Ha
|
|||
}
|
||||
isASRequest = true
|
||||
id := requestId(r, scheme)
|
||||
|
||||
var unlock func()
|
||||
|
||||
// Lock and obtain a copy of the requested ActivityStreams value
|
||||
err = db.Lock(c, id)
|
||||
unlock, err = db.Lock(c, id)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
// WARNING: Unlock not deferred
|
||||
t, err := db.Get(c, id)
|
||||
unlock() // unlock even on error
|
||||
if err != nil {
|
||||
db.Unlock(c, id)
|
||||
return
|
||||
}
|
||||
db.Unlock(c, id)
|
||||
// Unlock must have been called by this point and in every
|
||||
// branch above
|
||||
if t == nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue