fix missing method
Some checks failed
BlockStorage/repertory/pipeline/head There was a failure building this commit
Some checks failed
BlockStorage/repertory/pipeline/head There was a failure building this commit
This commit is contained in:
parent
0e8e56ad90
commit
6b18a72b95
@ -41,7 +41,7 @@ private:
|
||||
const std::string unique_id_;
|
||||
const std::string mutex_id_;
|
||||
int lock_fd_;
|
||||
int lock_status_ = EWOULDBLOCK;
|
||||
int lock_status_{EWOULDBLOCK};
|
||||
|
||||
private:
|
||||
[[nodiscard]] static auto get_state_directory() -> std::string;
|
||||
@ -51,8 +51,11 @@ private:
|
||||
[[nodiscard]] auto get_lock_file() -> std::string;
|
||||
|
||||
private:
|
||||
[[nodiscard]] static auto
|
||||
wait_for_lock(int fd, std::uint8_t retry_count = 30u) -> int;
|
||||
void release();
|
||||
|
||||
[[nodiscard]] static auto wait_for_lock(int fd,
|
||||
std::uint8_t retry_count = 30u)
|
||||
-> int;
|
||||
|
||||
public:
|
||||
[[nodiscard]] auto get_mount_state(json &mount_state) -> bool;
|
||||
@ -60,8 +63,8 @@ public:
|
||||
[[nodiscard]] auto grab_lock(std::uint8_t retry_count = 30u) -> lock_result;
|
||||
|
||||
[[nodiscard]] auto set_mount_state(bool active,
|
||||
const std::string &mount_location,
|
||||
int pid) -> bool;
|
||||
const std::string &mount_location, int pid)
|
||||
-> bool;
|
||||
};
|
||||
|
||||
[[nodiscard]] auto create_meta_attributes(
|
||||
|
@ -47,16 +47,7 @@ lock_data::lock_data(const provider_type &pt, std::string unique_id /*= ""*/)
|
||||
lock_data::lock_data()
|
||||
: pt_(provider_type::sia), unique_id_(""), mutex_id_(""), lock_fd_(-1) {}
|
||||
|
||||
lock_data::~lock_data() {
|
||||
if (lock_fd_ != -1) {
|
||||
if (lock_status_ == 0) {
|
||||
unlink(get_lock_file().c_str());
|
||||
flock(lock_fd_, LOCK_UN);
|
||||
}
|
||||
|
||||
close(lock_fd_);
|
||||
}
|
||||
}
|
||||
lock_data::~lock_data() { release(); }
|
||||
|
||||
auto lock_data::get_lock_data_file() -> std::string {
|
||||
const auto dir = get_state_directory();
|
||||
@ -125,6 +116,20 @@ auto lock_data::grab_lock(std::uint8_t retry_count) -> lock_result {
|
||||
}
|
||||
}
|
||||
|
||||
void lock_data::release() {
|
||||
if (lock_fd_ == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (lock_status_ == 0) {
|
||||
unlink(get_lock_file().c_str());
|
||||
flock(lock_fd_, LOCK_UN);
|
||||
}
|
||||
|
||||
close(lock_fd_);
|
||||
lock_fd_ = -1;
|
||||
}
|
||||
|
||||
auto lock_data::set_mount_state(bool active, const std::string &mount_location,
|
||||
int pid) -> bool {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
Loading…
x
Reference in New Issue
Block a user