[Kernel] Fix data race on XFile position
This commit is contained in:
@@ -35,6 +35,16 @@ XFile::~XFile() {
|
|||||||
file_->Destroy();
|
file_->Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64_t XFile::position() const {
|
||||||
|
std::lock_guard<std::mutex> lock(file_lock_);
|
||||||
|
return position_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void XFile::set_position(uint64_t value) {
|
||||||
|
std::lock_guard<std::mutex> lock(file_lock_);
|
||||||
|
position_ = value;
|
||||||
|
}
|
||||||
|
|
||||||
X_STATUS XFile::QueryDirectory(X_FILE_DIRECTORY_INFORMATION* out_info,
|
X_STATUS XFile::QueryDirectory(X_FILE_DIRECTORY_INFORMATION* out_info,
|
||||||
size_t length, const std::string_view file_name,
|
size_t length, const std::string_view file_name,
|
||||||
bool restart) {
|
bool restart) {
|
||||||
|
|||||||
@@ -143,8 +143,8 @@ class XFile : public XObject {
|
|||||||
const std::string& path() const { return file_->entry()->path(); }
|
const std::string& path() const { return file_->entry()->path(); }
|
||||||
const std::string& name() const { return file_->entry()->name(); }
|
const std::string& name() const { return file_->entry()->name(); }
|
||||||
|
|
||||||
uint64_t position() const { return position_; }
|
uint64_t position() const;
|
||||||
void set_position(uint64_t value) { position_ = value; }
|
void set_position(uint64_t value);
|
||||||
|
|
||||||
X_STATUS QueryDirectory(X_FILE_DIRECTORY_INFORMATION* out_info, size_t length,
|
X_STATUS QueryDirectory(X_FILE_DIRECTORY_INFORMATION* out_info, size_t length,
|
||||||
const std::string_view file_name, bool restart);
|
const std::string_view file_name, bool restart);
|
||||||
@@ -193,7 +193,7 @@ class XFile : public XObject {
|
|||||||
vfs::File* file_ = nullptr;
|
vfs::File* file_ = nullptr;
|
||||||
std::unique_ptr<threading::Event> async_event_ = nullptr;
|
std::unique_ptr<threading::Event> async_event_ = nullptr;
|
||||||
|
|
||||||
std::mutex file_lock_;
|
mutable std::mutex file_lock_;
|
||||||
std::mutex completion_port_lock_;
|
std::mutex completion_port_lock_;
|
||||||
std::vector<std::pair<uint32_t, object_ref<XIOCompletion>>> completion_ports_;
|
std::vector<std::pair<uint32_t, object_ref<XIOCompletion>>> completion_ports_;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user