}
}
-struct Mutation;
+#include "include/memory.h"
+struct MutationImpl;
+typedef ceph::shared_ptr<MutationImpl> MutationRef;
extern "C" {
#include "locks.h"
// local state
int num_wrlock, num_xlock;
- Mutation *xlock_by;
+ MutationRef xlock_by;
client_t xlock_by_client;
client_t excl_client;
gather_set.empty() &&
num_wrlock == 0 &&
num_xlock == 0 &&
- xlock_by == NULL &&
+ xlock_by.get() == NULL &&
xlock_by_client == -1 &&
excl_client == -1;
}
unstable_bits_t() : num_wrlock(0),
num_xlock(0),
- xlock_by(NULL),
+ xlock_by(),
xlock_by_client(-1),
excl_client(-1) {}
};
}
// xlock
- void get_xlock(Mutation *who, client_t client) {
+ void get_xlock(MutationRef& who, client_t client) {
assert(get_xlock_by() == 0);
assert(state == LOCK_XLOCK || is_locallock() ||
state == LOCK_LOCK /* if we are a slave */);
state == LOCK_LOCK /* if we are a slave */);
if (!is_locallock())
state = LOCK_XLOCKDONE;
- more()->xlock_by = 0;
+ more()->xlock_by.reset();
}
void put_xlock() {
assert(state == LOCK_XLOCK || state == LOCK_XLOCKDONE || is_locallock() ||
--more()->num_xlock;
parent->put(MDSCacheObject::PIN_LOCK);
if (more()->num_xlock == 0) {
- more()->xlock_by = 0;
+ more()->xlock_by.reset();
more()->xlock_by_client = -1;
try_clear_more();
}
bool is_xlocked_by_client(client_t c) const {
return have_more() ? more()->xlock_by_client == c : false;
}
- Mutation *get_xlock_by() {
- return have_more() ? more()->xlock_by : NULL;
- }
- const Mutation *get_xlock_by() const {
- return have_more() ? more()->xlock_by : NULL;
+ MutationRef get_xlock_by() const {
+ return have_more() ? more()->xlock_by : MutationRef();
}
// lease