-
Notifications
You must be signed in to change notification settings - Fork 55
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
fix: tedge mqtt ignoring ctrl-c when connection fails #2950
fix: tedge mqtt ignoring ctrl-c when connection fails #2950
Conversation
Signed-off-by: Didier Wenzek <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files
|
Robot Results
|
Err(err) => { | ||
if interrupted.load(Ordering::Relaxed) { | ||
break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was initially wondering why the same is not done for publish
as well, but then noticed that the publisher already breaks out of the loop on any connection error. I'm assuming that the behaviour is different here (not breaking out of the loop on any connection error) to handle reconnection cases as well, esp for long running subscribers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the point is to handle long running subscribers ignoring connection blips unless the user requests to break.
Err(err) => { | ||
if interrupted.load(Ordering::Relaxed) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the performance of these utilities is not at all a concern, but immediate response to the Ctrl + C
command is desired, isn't it better to go with a stronger ordering guarantee using Ordering::Acquire
and Ordering::Release
so that the program closes as soon as Ctrl + C
is pressed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. A user will not notice the difference. Besides, the main delay is introduced by the event loop. The break will occur only after a connection error is reported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The delay (of up to 1 second) between pressing ctrl+c
is on there when the MQTT broker is not reachable, so I don't think the user will run into it very often, so it's ok from UX perspective.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved
Proposed changes
As rumqttc doesn't trigger a client disconnect when the connection is not established,
one has to combine a client disconnect with the use of an
AtomicBool
to break the event loopif for some reason the connection is not established when the user hits ctrl-c.
Types of changes
Paste Link to the issue
#2949
Checklist
cargo fmt
as mentioned in CODING_GUIDELINEScargo clippy
as mentioned in CODING_GUIDELINESFurther comments