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
Extend server client ResetStatistics()
to reset all client statistics not only channel...
#1587
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -73,7 +73,13 @@ public void HandleReceivedPacket(MqttPacket packet) | |||||||||||
LastNonKeepAlivePacketReceivedTimestamp = LastPacketReceivedTimestamp; | ||||||||||||
} | ||||||||||||
} | ||||||||||||
|
||||||||||||
public void ResetStatistics(){ | ||||||||||||
Interlocked.Exchange(ref _sentApplicationMessagesCount,0); | ||||||||||||
Interlocked.Exchange(ref _receivedApplicationMessagesCount,0); | ||||||||||||
Interlocked.Exchange(ref _sentPacketsCount,0); | ||||||||||||
Interlocked.Exchange(ref _receivedPacketsCount,0); | ||||||||||||
Comment on lines
+79
to
+80
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should these be set to MQTTnet/Source/MQTTnet/Server/Internal/MqttClientStatistics.cs Lines 13 to 17 in e88b280
BTW: there should be a space after the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In my opinion 0 is fine because the user wants so to reset the entire statistics. The initial 1 is required to have correct values directly after start. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah as @chkr1011 said this is user reset.. 1 is only on init when client open connection... |
||||||||||||
} | ||||||||||||
|
||||||||||||
public void HandleSentPacket(MqttPacket packet) | ||||||||||||
{ | ||||||||||||
if (packet == null) | ||||||||||||
|
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.
Personally I'd structure it like done in #1590 with an extra struct to hold the values.
And use Volatile.Read/Write instead of Interlocked.Exchange -- see PR for reason.
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.
Will have a look and update... Inpull i just fit what was used in lib sources...
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 will merge the pull request because it fixes the bug in the first place. We can then discuss how it is done and how to optimize it in your pull request.