Skip to content

Commit 136d4b5

Browse files
committed
Let Manifest copy constructor take const& other
The lock is mutable so we can still lock the other without passing other as a non-const reference Change-Id: I8c47676f23b399a2c158414866ce6818509ea9c2 Reviewed-on: https://review.couchbase.org/c/kv_engine/+/227320 Reviewed-by: Vesko Karaganev <vesko.karaganev@couchbase.com> Tested-by: Build Bot <build@couchbase.com>
1 parent a4384ca commit 136d4b5

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

engines/ep/src/collections/vbucket_manifest.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Manifest::~Manifest() {
8989
}
9090
}
9191

92-
Manifest::Manifest(Manifest& other) : manager(other.manager) {
92+
Manifest::Manifest(const Manifest& other) : manager(other.manager) {
9393
// Prevent other from being modified while we copy.
9494
std::unique_lock<Manifest::mutex_type> wlock(other.rwlock);
9595

engines/ep/src/collections/vbucket_manifest.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,8 @@ class Manifest {
144144
* Copy ctor - more of a logical copy as we can't copy the lock guarding
145145
* the manifest. Used by NexusKVStore to generate a manifest for the
146146
* secondary KVStore to update stats against when flushing.
147-
*
148-
* Interestingly this isn't const because we want to take the write lock
149-
* (wlock()) to prevent updates to the manifest. It's probably fine to
150-
* take a read lock instead but because the read handles can update various
151-
* stats which will be copied it's better to err on the side of caution and
152-
* take the write lock.
153147
*/
154-
Manifest(Manifest& other);
148+
Manifest(const Manifest& other);
155149

156150
/**
157151
* @return ReadHandle, no iterator is held on the collection container

0 commit comments

Comments
 (0)