mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 04:44:37 +03:00
Add write mutex and max connection lifetime (#1211)
This commit is contained in:
@@ -176,17 +176,15 @@ func (t *ReadTransaction) Tag() models.TagReader {
|
||||
}
|
||||
|
||||
type TransactionManager struct {
|
||||
// only allow one write transaction at a time
|
||||
c chan struct{}
|
||||
}
|
||||
|
||||
func NewTransactionManager() *TransactionManager {
|
||||
return &TransactionManager{
|
||||
c: make(chan struct{}, 1),
|
||||
}
|
||||
return &TransactionManager{}
|
||||
}
|
||||
|
||||
func (t *TransactionManager) WithTxn(ctx context.Context, fn func(r models.Repository) error) error {
|
||||
database.WriteMu.Lock()
|
||||
defer database.WriteMu.Unlock()
|
||||
return models.WithTxn(&transaction{Ctx: ctx}, fn)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user