Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove stopped InputStream and StreamHandlers from Registry managers #172

Merged
4 commits merged into from
Jan 10, 2022

Conversation

ghost
Copy link

@ghost ghost commented Jan 7, 2022

No description provided.

@ghost ghost requested a review from weyrick January 7, 2022 22:02
@ghost ghost linked an issue Jan 7, 2022 that may be closed by this pull request
@ghost ghost changed the title Remove stoped InputStream and StreamHandlers from Registry managers Remove stopped InputStream and StreamHandlers from Registry managers Jan 7, 2022
Copy link
Member

@weyrick weyrick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, let's encapsulate this into PolicyManager

src/Policies.cpp Outdated
}
policy->stop();
_map.erase(name);
lock.unlock();
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@weyrick I've applied the same previous logic here to avoid locking HandlerManger and InputManager mutexes inside PolicyManager. here we could erase from map only at the end and keep everything in PolicyManger lock context. What do you think is safer?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes let's unlock at the end - otherwise we may have a race if the policy is recreated quickly and the handler or input names collide

src/Policies.cpp Outdated
}

auto policy = _map[name].get();
std::string input_name = policy->input_stream()->name();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tiny but if you use auto here, we'll get a const reference instead of a copy here. good habit i think.

src/Policies.cpp Show resolved Hide resolved
src/Policies.cpp Outdated
auto policy = _map[name].get();
std::string input_name = policy->input_stream()->name();
std::vector<std::string> module_names;
for (auto &mod : policy->modules()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const auto&

src/Policies.cpp Outdated
_map.erase(name);
lock.unlock();

for (auto &name : module_names) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const auto&

src/Policies.cpp Outdated
}
policy->stop();
_map.erase(name);
lock.unlock();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes let's unlock at the end - otherwise we may have a race if the policy is recreated quickly and the handler or input names collide

@ghost ghost force-pushed the bugfix/add-deleted-policy branch from 6f595b6 to 779333c Compare January 10, 2022 15:27
@ghost ghost merged commit 1ad574f into develop Jan 10, 2022
@ghost ghost deleted the bugfix/add-deleted-policy branch January 10, 2022 16:23
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

segfault after trying to include a previous deleted policy
1 participant