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

Internal refactor of P2P::Session vs. P2P::ManagerXXX classes #93

Merged
merged 6 commits into from
Feb 23, 2024

Conversation

fcecin
Copy link
Collaborator

@fcecin fcecin commented Feb 16, 2024

This changes the std::weak_ptr<Session> argument in P2P::ManagerXXX APIs to NodeId instead, which induces an additional lookup for the Session object from that NodeId.

I'm also including some changes to the P2P::ManagerBase start / stop.

@ghost
Copy link

ghost commented Feb 17, 2024

Quality Gate failed Quality Gate failed

Failed conditions

25 New issues
12.6% 12.6% Coverage on New Code (required ≥ 80%)
21.4% 21.4% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube

Catch issues before they fail your Quality Gate with our IDE extension SonarLint SonarLint

- Rule out any possibility that ManagerBase::sessions_ will
grow (or shrink) after ManagerBase::close_ is set to true, so that
ManagerBase::stop() can close all registered sessions

- On ManagerBase::stop(), join the Session thread pool after
Server and ClientFactory are stopped (possibly more correct)
- removed closed_; replaced by started_ (ManagerBase should be
able to start() and stop() repeatedly and safely)
- added stateMutex_ to synchronize start(), stop() and thread pool
- start() creates threadPool_
- stop() destroys threadPool_ (waits for all tasks and joins all
threads, guaranteeing that there is no session/socket message
handling code active when it is time to e.g. destroy the
underlying io_context)
- threadPool_ is now isolated and not forwarded to other objects;
to use the ManagerBase thread pool, other objects have to call a
method on ManagerBase that will service the request, such as
ManagerBase::asyncHandleMessage()

state.cpp (test):

- increased timeout from 5s to 120s in a couple of futures to
avoid random, performance-related failures (logs to cout if they
exceed 5s, which in any case is rare)
@jcarraror jcarraror self-requested a review February 22, 2024 12:14
src/net/p2p/managerbase.cpp Outdated Show resolved Hide resolved
src/net/p2p/managerbase.cpp Outdated Show resolved Hide resolved
@itamarcps itamarcps self-requested a review February 23, 2024 04:12
@jcarraror jcarraror merged commit 64f7c3d into development Feb 23, 2024
3 checks passed
@fcecin fcecin deleted the p2p_session_id_refactor branch February 23, 2024 17:01
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.

3 participants