Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Dunitrust
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
nodes
rust
Dunitrust
Commits
7c789921
Commit
7c789921
authored
6 years ago
by
Éloïs
Browse files
Options
Downloads
Patches
Plain Diff
[fix] core:router: prevent a module from receiving its own event
parent
a68d49b4
No related branches found
No related tags found
1 merge request
!152
Elois/prevent module recv own event
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/core/core/src/router.rs
+17
-28
17 additions, 28 deletions
lib/core/core/src/router.rs
with
17 additions
and
28 deletions
lib/core/core/src/router.rs
+
17
−
28
View file @
7c789921
...
...
@@ -40,7 +40,6 @@ enum DursMsgReceiver {
/// Start broadcasting thread
fn
start_broadcasting_thread
(
start_time
:
SystemTime
,
run_duration_in_secs
:
u64
,
receiver
:
&
mpsc
::
Receiver
<
RouterThreadMessage
<
DursMsg
>>
,
_external_followers
:
&
[
mpsc
::
Sender
<
DursMsg
>
],
)
{
...
...
@@ -178,32 +177,29 @@ fn start_broadcasting_thread(
}
RouterThreadMessage
::
ModuleMessage
(
msg
)
=>
match
msg
{
DursMsg
::
Stop
=>
break
,
DursMsg
::
Event
{
event_type
,
..
}
=>
{
DursMsg
::
Event
{
event_from
,
event_type
,
..
}
=>
{
// the node to be started less than MAX_REGISTRATION_DELAY seconds ago,
// keep the message in memory to be able to send it back to modules not yet plugged
store_msg_in_pool
(
start_time
,
run_duration_in_secs
,
msg
.clone
(),
&
mut
pool_msgs
,
);
store_msg_in_pool
(
start_time
,
msg
.clone
(),
&
mut
pool_msgs
);
// Get list of receivers
let
receivers
=
events_subscriptions
.get
(
&
event_type
)
.unwrap_or
(
&
Vec
::
with_capacity
(
0
))
.to_vec
();
.iter
()
.filter
(|
module_static_name
|
**
module_static_name
!=
event_from
)
.cloned
()
.collect
::
<
Vec
<
ModuleStaticName
>>
();
// Send msg to receivers
send_msg_to_several_receivers
(
msg
,
&
receivers
,
&
modules_senders
)
}
DursMsg
::
Request
{
req_to
:
role
,
..
}
=>
{
// If the node to be started less than MAX_REGISTRATION_DELAY seconds ago,
// keep the message in memory to be able to send it back to modules not yet plugged
store_msg_in_pool
(
start_time
,
run_duration_in_secs
,
msg
.clone
(),
&
mut
pool_msgs
,
);
store_msg_in_pool
(
start_time
,
msg
.clone
(),
&
mut
pool_msgs
);
// Get list of receivers
let
receivers
=
roles
.get
(
&
role
)
.unwrap_or
(
&
Vec
::
with_capacity
(
0
))
.to_vec
();
...
...
@@ -288,12 +284,10 @@ fn send_msg_to_several_receivers(
/// keep the message in memory to be able to send it back to modules not yet plugged
fn
store_msg_in_pool
(
start_time
:
SystemTime
,
run_duration_in_secs
:
u64
,
msg
:
DursMsg
,
pool_msgs
:
&
mut
HashMap
<
DursMsgReceiver
,
Vec
<
DursMsg
>>
,
)
{
if
run_duration_in_secs
>
0
&&
SystemTime
::
now
()
if
SystemTime
::
now
()
.duration_since
(
start_time
)
.expect
(
"Duration error !"
)
.as_secs
()
...
...
@@ -339,12 +333,7 @@ pub fn start_router(
// Create broadcasting thread
thread
::
spawn
(
move
||
{
start_broadcasting_thread
(
start_time
,
run_duration_in_secs
,
&
broadcasting_receiver
,
&
external_followers
,
);
start_broadcasting_thread
(
start_time
,
&
broadcasting_receiver
,
&
external_followers
);
});
// Create conf thread channel
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment