Commit 82a68675 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent e471cb59
...@@ -486,7 +486,7 @@ error _Conn::resync(zodb::Tid at) { ...@@ -486,7 +486,7 @@ error _Conn::resync(zodb::Tid at) {
// //
// NOTE we'll relock atMu as R in the second part of resync, so we prelock // NOTE we'll relock atMu as R in the second part of resync, so we prelock
// wconn._filehMu.R as well while under atMu.W, to be sure that set of opened // wconn._filehMu.R as well while under atMu.W, to be sure that set of opened
// files stays the same during whole resync. // files and their states stay the same during whole resync.
bool atMuWLocked = true; bool atMuWLocked = true;
wconn._atMu.Lock(); wconn._atMu.Lock();
wconn._filehMu.RLock(); wconn._filehMu.RLock();
...@@ -529,7 +529,10 @@ error _Conn::resync(zodb::Tid at) { ...@@ -529,7 +529,10 @@ error _Conn::resync(zodb::Tid at) {
// TODO if file has no mappings and was not used during whole prev // TODO if file has no mappings and was not used during whole prev
// cycle - forget and stop watching it // cycle - forget and stop watching it
// XXX not yet ready f // opening or closing fileh, whose setup/teardown is handled by
// Conn.open and FileH.close correspondingly.
if (f._state != _FileHOpened)
continue;
// update f._headfsize and remmap to head/f zero regions that are now covered by head/f // update f._headfsize and remmap to head/f zero regions that are now covered by head/f
struct stat st; struct stat st;
...@@ -569,7 +572,8 @@ error _Conn::resync(zodb::Tid at) { ...@@ -569,7 +572,8 @@ error _Conn::resync(zodb::Tid at) {
// - we need to hold atMu.R to avoid race wrt e.g. other resync which changes at. // - we need to hold atMu.R to avoid race wrt e.g. other resync which changes at.
// - we cannot just do regular `atMu.Unlock + atMu.RLock()` because then // - we cannot just do regular `atMu.Unlock + atMu.RLock()` because then
// there is e.g. a race window in between Unlock and RLock where wconn.at can be changed. // there is e.g. a race window in between Unlock and RLock where wconn.at can be changed.
// XXX also deadlock, because it will become wconn._filehMu.lock + wconn._atMu lock // Also if we Unlock and Rlock, it will produce deadlock, because locking
// order will change to reverse: wconn._filehMu.R + wconn._atMu.R
// //
// Now other calls, e.g. Conn.open, can be running simultaneously to us, // Now other calls, e.g. Conn.open, can be running simultaneously to us,
// but since we already set wconn.at to new value it is ok. For example // but since we already set wconn.at to new value it is ok. For example
...@@ -663,7 +667,7 @@ retry: ...@@ -663,7 +667,7 @@ retry:
return make_pair(f, nil); return make_pair(f, nil);
} }
// create "opening" FileH entry and perform open with wconn._filehMu released // create "opening" FileH entry and perform open with wconn._filehMu released.
// NOTE wconn._atMu.R is still held because FileH._open relies on wconn.at being stable. // NOTE wconn._atMu.R is still held because FileH._open relies on wconn.at being stable.
f = adoptref(new _FileH()); f = adoptref(new _FileH());
f->wconn = newref(&wconn); f->wconn = newref(&wconn);
......
...@@ -231,7 +231,7 @@ struct _FileH : object { ...@@ -231,7 +231,7 @@ struct _FileH : object {
Conn wconn; Conn wconn;
zodb::Oid foid; // ZBigFile root object ID (does not change after fileh open) zodb::Oid foid; // ZBigFile root object ID (does not change after fileh open)
// protect by wconn.filehMu // protect by wconn._filehMu
_FileHState _state; // opening/opened/closing/closed _FileHState _state; // opening/opened/closing/closed
int _nopen; // number of times Conn.open returned this fileh int _nopen; // number of times Conn.open returned this fileh
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment