mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
BUG: fileMonitor : parallel syncing
This commit is contained in:
@ -319,7 +319,7 @@ void Foam::fileMonitor::checkFiles() const
|
|||||||
|
|
||||||
if (ready < 0)
|
if (ready < 0)
|
||||||
{
|
{
|
||||||
FatalErrorIn("fileMonitor::updateStates()")
|
FatalErrorIn("fileMonitor::checkFiles()")
|
||||||
<< "Problem in issuing select."
|
<< "Problem in issuing select."
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
@ -335,7 +335,7 @@ void Foam::fileMonitor::checkFiles() const
|
|||||||
|
|
||||||
if (nBytes < 0)
|
if (nBytes < 0)
|
||||||
{
|
{
|
||||||
FatalErrorIn("fileMonitor::updateStates(const fileName&)")
|
FatalErrorIn("fileMonitor::checkFiles()")
|
||||||
<< "read of " << watcher_->inotifyFd_
|
<< "read of " << watcher_->inotifyFd_
|
||||||
<< " failed with " << label(nBytes)
|
<< " failed with " << label(nBytes)
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
@ -374,7 +374,7 @@ void Foam::fileMonitor::checkFiles() const
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Correct directory and name
|
// Correct directory and name
|
||||||
state_[i] = MODIFIED;
|
localState_[i] = MODIFIED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -403,18 +403,17 @@ void Foam::fileMonitor::checkFiles() const
|
|||||||
|
|
||||||
if (newTime == 0)
|
if (newTime == 0)
|
||||||
{
|
{
|
||||||
state_[watchFd] = DELETED;
|
localState_[watchFd] = DELETED;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (newTime > (oldTime + regIOobject::fileModificationSkew))
|
if (newTime > (oldTime + regIOobject::fileModificationSkew))
|
||||||
{
|
{
|
||||||
watcher_->lastMod_[watchFd] = newTime;
|
localState_[watchFd] = MODIFIED;
|
||||||
state_[watchFd] = MODIFIED;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
state_[watchFd] = UNMODIFIED;
|
localState_[watchFd] = UNMODIFIED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -422,12 +421,14 @@ void Foam::fileMonitor::checkFiles() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
Foam::fileMonitor::fileMonitor(const bool useInotify)
|
Foam::fileMonitor::fileMonitor(const bool useInotify)
|
||||||
:
|
:
|
||||||
useInotify_(useInotify),
|
useInotify_(useInotify),
|
||||||
|
localState_(20),
|
||||||
state_(20),
|
state_(20),
|
||||||
watchFile_(20),
|
watchFile_(20),
|
||||||
freeWatchFds_(2),
|
freeWatchFds_(2),
|
||||||
@ -476,6 +477,7 @@ Foam::label Foam::fileMonitor::addWatch(const fileName& fName)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
localState_(watchFd) = UNMODIFIED;
|
||||||
state_(watchFd) = UNMODIFIED;
|
state_(watchFd) = UNMODIFIED;
|
||||||
watchFile_(watchFd) = fName;
|
watchFile_(watchFd) = fName;
|
||||||
}
|
}
|
||||||
@ -517,30 +519,26 @@ void Foam::fileMonitor::updateStates
|
|||||||
{
|
{
|
||||||
if (Pstream::master() || !masterOnly)
|
if (Pstream::master() || !masterOnly)
|
||||||
{
|
{
|
||||||
|
// Update the localState_
|
||||||
checkFiles();
|
checkFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (syncPar)
|
if (syncPar)
|
||||||
{
|
{
|
||||||
// Pack current state (might be on master only)
|
// Pack local state (might be on master only)
|
||||||
PackedList<2> stats(state_.size(), MODIFIED);
|
PackedList<2> stats(state_.size(), MODIFIED);
|
||||||
if (Pstream::master() || !masterOnly)
|
if (Pstream::master() || !masterOnly)
|
||||||
{
|
{
|
||||||
forAll(state_, watchFd)
|
forAll(state_, watchFd)
|
||||||
{
|
{
|
||||||
stats[watchFd] = static_cast<unsigned int>(state_[watchFd]);
|
stats[watchFd] = static_cast<unsigned int>
|
||||||
|
(
|
||||||
|
localState_[watchFd]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Save local state for warning message below
|
|
||||||
PackedList<2> thisProcStats;
|
|
||||||
if (!masterOnly)
|
|
||||||
{
|
|
||||||
thisProcStats = stats;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Scatter or reduce to synchronise state
|
// Scatter or reduce to synchronise state
|
||||||
if (masterOnly)
|
if (masterOnly)
|
||||||
{
|
{
|
||||||
@ -573,33 +571,34 @@ void Foam::fileMonitor::updateStates
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Update local state
|
// Update synchronised state
|
||||||
forAll(state_, watchFd)
|
forAll(state_, watchFd)
|
||||||
{
|
{
|
||||||
if (masterOnly)
|
// Assign synchronised state
|
||||||
|
unsigned int stat = stats[watchFd];
|
||||||
|
state_[watchFd] = fileState(stat);
|
||||||
|
|
||||||
|
if (!masterOnly)
|
||||||
{
|
{
|
||||||
// No need to check for inconsistent state. Just assign.
|
// Give warning for inconsistent state
|
||||||
unsigned int stat = stats[watchFd];
|
if (state_[watchFd] != localState_[watchFd])
|
||||||
state_[watchFd] = fileState(stat);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Check for inconsistent state before assigning.
|
|
||||||
if (thisProcStats[watchFd] != UNMODIFIED)
|
|
||||||
{
|
{
|
||||||
if (stats[watchFd] == UNMODIFIED)
|
if (debug)
|
||||||
{
|
{
|
||||||
WarningIn("fileMonitor::updateStates(const bool) const")
|
Pout<< "fileMonitor : Delaying reading "
|
||||||
<< "Delaying reading " << watchFile_[watchFd]
|
<< watchFile_[watchFd]
|
||||||
<< " due to inconsistent "
|
<< " due to inconsistent "
|
||||||
"file time-stamps between processors"
|
"file time-stamps between processors"
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
WarningIn
|
||||||
unsigned int stat = stats[watchFd];
|
(
|
||||||
state_[watchFd] = fileState(stat);
|
"fileMonitor::updateStates"
|
||||||
}
|
"(const bool, const bool) const"
|
||||||
|
) << "Delaying reading " << watchFile_[watchFd]
|
||||||
|
<< " due to inconsistent "
|
||||||
|
"file time-stamps between processors" << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -610,6 +609,7 @@ void Foam::fileMonitor::updateStates
|
|||||||
void Foam::fileMonitor::setUnmodified(const label watchFd)
|
void Foam::fileMonitor::setUnmodified(const label watchFd)
|
||||||
{
|
{
|
||||||
state_[watchFd] = UNMODIFIED;
|
state_[watchFd] = UNMODIFIED;
|
||||||
|
localState_[watchFd] = UNMODIFIED;
|
||||||
|
|
||||||
if (!useInotify_)
|
if (!useInotify_)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -71,7 +71,7 @@ public:
|
|||||||
{
|
{
|
||||||
UNMODIFIED = 0,
|
UNMODIFIED = 0,
|
||||||
MODIFIED = 1,
|
MODIFIED = 1,
|
||||||
DELETED = 2,
|
DELETED = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
static const NamedEnum<fileState, 3> fileStateNames_;
|
static const NamedEnum<fileState, 3> fileStateNames_;
|
||||||
@ -82,7 +82,10 @@ private:
|
|||||||
//- Whether to use inotify (requires -DFOAM_USE_INOTIFY, see above)
|
//- Whether to use inotify (requires -DFOAM_USE_INOTIFY, see above)
|
||||||
const bool useInotify_;
|
const bool useInotify_;
|
||||||
|
|
||||||
//- State for all watchFds
|
//- State for all watchFds based on local files
|
||||||
|
mutable DynamicList<fileState> localState_;
|
||||||
|
|
||||||
|
//- State for all watchFds - synchronised
|
||||||
mutable DynamicList<fileState> state_;
|
mutable DynamicList<fileState> state_;
|
||||||
|
|
||||||
//- Filename for all watchFds
|
//- Filename for all watchFds
|
||||||
@ -97,7 +100,7 @@ private:
|
|||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
//- Update state_ from any events.
|
//- Update localState_ from any events.
|
||||||
void checkFiles() const;
|
void checkFiles() const;
|
||||||
|
|
||||||
//- Disallow default bitwise copy construct
|
//- Disallow default bitwise copy construct
|
||||||
|
|||||||
@ -60,7 +60,6 @@ Foam::regIOobject::fileCheckTypes Foam::regIOobject::fileModificationChecking
|
|||||||
debug::optimisationSwitches().lookup
|
debug::optimisationSwitches().lookup
|
||||||
(
|
(
|
||||||
"fileModificationChecking"
|
"fileModificationChecking"
|
||||||
//Foam::regIOobject::timeStamp
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|||||||
@ -31,6 +31,7 @@ License
|
|||||||
#include "IOobject.H"
|
#include "IOobject.H"
|
||||||
#include "JobInfo.H"
|
#include "JobInfo.H"
|
||||||
#include "labelList.H"
|
#include "labelList.H"
|
||||||
|
#include "regIOobject.H"
|
||||||
|
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
|
|
||||||
@ -767,6 +768,16 @@ Foam::argList::argList
|
|||||||
sigQuit_.set(bannerEnabled);
|
sigQuit_.set(bannerEnabled);
|
||||||
sigSegv_.set(bannerEnabled);
|
sigSegv_.set(bannerEnabled);
|
||||||
|
|
||||||
|
if (bannerEnabled)
|
||||||
|
{
|
||||||
|
Info<< "Monitoring run-time modified files using "
|
||||||
|
<< regIOobject::fileCheckTypesNames
|
||||||
|
[
|
||||||
|
regIOobject::fileModificationChecking
|
||||||
|
]
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
if (Pstream::master() && bannerEnabled)
|
if (Pstream::master() && bannerEnabled)
|
||||||
{
|
{
|
||||||
Info<< endl;
|
Info<< endl;
|
||||||
|
|||||||
Reference in New Issue
Block a user