package daemon: Move volume change counter back to Volume

This commit is contained in:
Ingo Weinhold
2014-05-04 20:59:01 +02:00
parent 0e45e3eb1d
commit 870e93acf8
5 changed files with 16 additions and 19 deletions
@@ -98,7 +98,7 @@ CommitTransactionHandler::HandleRequest(
const BActivationTransaction& transaction, BMessage* reply)
{
// check the change count
if (transaction.ChangeCount() != fVolumeState->ChangeCount())
if (transaction.ChangeCount() != fVolume->ChangeCount())
throw Exception(B_DAEMON_CHANGE_COUNT_MISMATCH);
// collect the packages to deactivate
+10 -6
View File
@@ -145,6 +145,7 @@ Volume::Volume(BLooper* looper)
fPackageFileManager(NULL),
fLatestState(NULL),
fActiveState(NULL),
fChangeCount(0),
fLock("volume"),
fPendingNodeMonitorEventsLock("pending node monitor events"),
fPendingNodeMonitorEvents(),
@@ -450,7 +451,7 @@ Volume::HandleGetLocationInfoRequest(BMessage* message)
// If the cached reply message is up-to-date, just send it.
int64 changeCount;
if (fLocationInfoReply.FindInt64("change count", &changeCount) == B_OK
&& changeCount == fLatestState->ChangeCount()) {
&& changeCount == fChangeCount) {
locker.Unlock();
message->SendReply(&fLocationInfoReply, (BHandler*)NULL,
kCommunicationTimeout);
@@ -484,10 +485,8 @@ Volume::HandleGetLocationInfoRequest(BMessage* message)
}
}
if (fLocationInfoReply.AddInt64("change count", fLatestState->ChangeCount())
!= B_OK) {
if (fLocationInfoReply.AddInt64("change count", fChangeCount) != B_OK)
return;
}
locker.Unlock();
@@ -756,8 +755,7 @@ Volume::CreateTransaction(BPackageInstallationLocation location,
}
// init the transaction
error = _transaction.SetTo(location, fLatestState->ChangeCount(),
directoryName);
error = _transaction.SetTo(location, fChangeCount, directoryName);
if (error != B_OK) {
BEntry entry;
_transactionDirectory.GetEntry(&entry);
@@ -909,6 +907,7 @@ INFORM("Volume::_PackagesEntryCreated(\"%s\")\n", name);
fLock.Lock();
fLatestState->AddPackage(package);
fChangeCount++;
fLock.Unlock();
try {
@@ -944,6 +943,7 @@ INFORM("Volume::_PackagesEntryRemoved(\"%s\")\n", name);
if (!package->IsActive()) {
AutoLocker<BLocker> locker(fLock);
fLatestState->RemovePackage(package);
fChangeCount++;
delete package;
return;
}
@@ -979,6 +979,7 @@ Volume::_ReadPackagesDirectory()
if (error == B_OK) {
AutoLocker<BLocker> locker(fLock);
fLatestState->AddPackage(package);
fChangeCount++;
}
}
@@ -1001,6 +1002,7 @@ Volume::_InitLatestState()
= fLatestState->ByFileNameIterator();
Package* package = it.Next();) {
fLatestState->SetPackageActive(package, true);
fChangeCount++;
}
return B_OK;
@@ -1079,6 +1081,7 @@ Volume::_InitLatestStateFromActivatedPackages()
Package* package = fLatestState->FindPackage(packageName);
if (package != NULL) {
fLatestState->SetPackageActive(package, true);
fChangeCount++;
} else {
WARN("Package \"%s\" from activation file not in packages "
"directory.\n", packageName);
@@ -1226,6 +1229,7 @@ Volume::_SetLatestState(VolumeState* state, bool isActive)
delete fLatestState;
fLatestState = state;
fChangeCount++;
}
+4
View File
@@ -111,6 +111,9 @@ public:
void SetRoot(Root* root)
{ fRoot = root; }
int64 ChangeCount() const
{ return fChangeCount; }
PackageFileNameHashTable::Iterator PackagesByFileNameIterator()
const;
@@ -183,6 +186,7 @@ private:
PackageFileManager* fPackageFileManager;
VolumeState* fLatestState;
VolumeState* fActiveState;
int64 fChangeCount;
BLocker fLock;
BLocker fPendingNodeMonitorEventsLock;
NodeMonitorEventList fPendingNodeMonitorEvents;
+1 -8
View File
@@ -16,8 +16,7 @@
VolumeState::VolumeState()
:
fPackagesByFileName(),
fPackagesByNodeRef(),
fChangeCount(0)
fPackagesByNodeRef()
{
}
@@ -48,7 +47,6 @@ VolumeState::AddPackage(Package* package)
{
fPackagesByFileName.Insert(package);
fPackagesByNodeRef.Insert(package);
fChangeCount++;
}
@@ -57,7 +55,6 @@ VolumeState::RemovePackage(Package* package)
{
fPackagesByFileName.Remove(package);
fPackagesByNodeRef.Remove(package);
fChangeCount++;
}
@@ -65,7 +62,6 @@ void
VolumeState::SetPackageActive(Package* package, bool active)
{
package->SetActive(active);
fChangeCount++;
}
@@ -76,7 +72,6 @@ VolumeState::ActivationChanged(const PackageSet& activatedPackage,
for (PackageSet::iterator it = activatedPackage.begin();
it != activatedPackage.end(); ++it) {
(*it)->SetActive(true);
fChangeCount++;
}
for (PackageSet::iterator it = deactivatePackages.begin();
@@ -105,7 +100,5 @@ VolumeState::Clone() const
clone->AddPackage(clonedPackage);
}
clone->fChangeCount = fChangeCount;
return cloneDeleter.Detach();
}
-4
View File
@@ -19,9 +19,6 @@ public:
bool Init();
int64 ChangeCount() const
{ return fChangeCount; }
Package* FindPackage(const char* name) const;
Package* FindPackage(const node_ref& nodeRef) const;
@@ -45,7 +42,6 @@ private:
private:
PackageFileNameHashTable fPackagesByFileName;
PackageNodeRefHashTable fPackagesByNodeRef;
int64 fChangeCount;
};