Commit eaf5e6be authored by Matthieu Dorier's avatar Matthieu Dorier

added the correct protection mechanism

parent b6aa3898
......@@ -56,6 +56,7 @@ struct operation {
std::vector<mode_t> m_modes;
std::vector<int> m_fds;
std::vector<device*> m_devices;
tl::mutex m_mutex;
int m_error = REMI_SUCCESS;
};
......@@ -165,6 +166,9 @@ struct remi_provider : public tl::provider<remi_provider> {
}
auto& op = it->second;
{
std::lock_guard<tl::mutex> guard(op.m_mutex);
// close all the file descriptors
for(int fd : op.m_fds) {
close(fd);
......@@ -187,6 +191,8 @@ struct remi_provider : public tl::provider<remi_provider> {
result.first = result.second == 0 ? REMI_SUCCESS : REMI_ERR_USER;
req.respond(result);
}
m_op_in_progress.erase(it);
return;
......@@ -295,6 +301,9 @@ struct remi_provider : public tl::provider<remi_provider> {
return;
}
auto& op = it->second;
std::lock_guard<tl::mutex> guard(op.m_mutex);
// we found the operation, let's open some files!
std::vector<int> openedFileDescriptors;
......@@ -346,7 +355,6 @@ struct remi_provider : public tl::provider<remi_provider> {
}
}
return;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment