[#274] wc: Resolve possible deadlock
If operation with WC are _fast enough_ (e.g. `Init` failed and `Close` is called immediately) there is a race and a deadlock that do not allow finish (and start, in fact) an initialization routine because of taken `modeMtx` and also do not allow finish `Close` call because of awaiting initialization finish. So do stop initialization _before_ any mutex is taken. Signed-off-by: Pavel Karpy <p.karpy@yadro.com>
This commit is contained in:
parent
6b6f33ed71
commit
e9461686b8
2 changed files with 10 additions and 13 deletions
|
@ -163,9 +163,6 @@ func (c *cache) Init() error {
|
|||
|
||||
// Close closes db connection and stops services. Executes ObjectCounters.FlushAndClose op.
|
||||
func (c *cache) Close() error {
|
||||
c.modeMtx.Lock()
|
||||
defer c.modeMtx.Unlock()
|
||||
|
||||
// Finish all in-progress operations.
|
||||
if err := c.setMode(context.TODO(), mode.ReadOnly); err != nil {
|
||||
return err
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue