fix missing method
Some checks failed
BlockStorage/repertory/pipeline/head There was a failure building this commit

This commit is contained in:
Scott E. Graves 2025-03-23 07:19:37 -05:00
parent 0e8e56ad90
commit 6b18a72b95
2 changed files with 23 additions and 15 deletions

View File

@ -41,7 +41,7 @@ private:
const std::string unique_id_; const std::string unique_id_;
const std::string mutex_id_; const std::string mutex_id_;
int lock_fd_; int lock_fd_;
int lock_status_ = EWOULDBLOCK; int lock_status_{EWOULDBLOCK};
private: private:
[[nodiscard]] static auto get_state_directory() -> std::string; [[nodiscard]] static auto get_state_directory() -> std::string;
@ -51,8 +51,11 @@ private:
[[nodiscard]] auto get_lock_file() -> std::string; [[nodiscard]] auto get_lock_file() -> std::string;
private: private:
[[nodiscard]] static auto void release();
wait_for_lock(int fd, std::uint8_t retry_count = 30u) -> int;
[[nodiscard]] static auto wait_for_lock(int fd,
std::uint8_t retry_count = 30u)
-> int;
public: public:
[[nodiscard]] auto get_mount_state(json &mount_state) -> bool; [[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 grab_lock(std::uint8_t retry_count = 30u) -> lock_result;
[[nodiscard]] auto set_mount_state(bool active, [[nodiscard]] auto set_mount_state(bool active,
const std::string &mount_location, const std::string &mount_location, int pid)
int pid) -> bool; -> bool;
}; };
[[nodiscard]] auto create_meta_attributes( [[nodiscard]] auto create_meta_attributes(

View File

@ -47,16 +47,7 @@ lock_data::lock_data(const provider_type &pt, std::string unique_id /*= ""*/)
lock_data::lock_data() lock_data::lock_data()
: pt_(provider_type::sia), unique_id_(""), mutex_id_(""), lock_fd_(-1) {} : pt_(provider_type::sia), unique_id_(""), mutex_id_(""), lock_fd_(-1) {}
lock_data::~lock_data() { lock_data::~lock_data() { release(); }
if (lock_fd_ != -1) {
if (lock_status_ == 0) {
unlink(get_lock_file().c_str());
flock(lock_fd_, LOCK_UN);
}
close(lock_fd_);
}
}
auto lock_data::get_lock_data_file() -> std::string { auto lock_data::get_lock_data_file() -> std::string {
const auto dir = get_state_directory(); 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, auto lock_data::set_mount_state(bool active, const std::string &mount_location,
int pid) -> bool { int pid) -> bool {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();