Skip to content
This repository has been archived by the owner on Jun 7, 2019. It is now read-only.

Bug fix on bug fix ... throttling cast to int at the wrong place #4

Merged
merged 1 commit into from
Nov 25, 2017
Merged

Bug fix on bug fix ... throttling cast to int at the wrong place #4

merged 1 commit into from
Nov 25, 2017

Conversation

PeterDM65
Copy link

@PeterDM65 PeterDM65 commented Nov 23, 2017

@Furtif
Copy link
Owner

Furtif commented Nov 23, 2017

see ok 👍

@@ -515,7 +515,7 @@ private Task<ByteString> SendRemoteProcedureCall(RequestEnvelope requestEnvelope
while (_rpcQueue.TryDequeue(out processRequestEnvelope))
{
// var diff = Math.Max(0, DateTime.Now.Millisecond - LastRpcRequest.Millisecond);
var diff = Math.Min((int)(DateTime.UtcNow - LastRpcRequest.ToUniversalTime()).TotalMilliseconds, Configuration.ThrottleDifference);
var diff = (int)Math.Min((DateTime.UtcNow - LastRpcRequest.ToUniversalTime()).TotalMilliseconds, Configuration.ThrottleDifference);
Copy link
Owner

Choose a reason for hiding this comment

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

maybe

int diff = 0; 

diff = (int)Math.Min((DateTime.UtcNow - LastRpcRequest.ToUniversalTime()).TotalMilliseconds, Configuration.ThrottleDifference);
if (diff < 0) diff = 0;

idee only

Copy link
Author

Choose a reason for hiding this comment

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

Under normal conditions LastRpcRequest always comes before UtcNow => So the difference should always be greater than zero.
The problem here was that initial LastRpcRequest has a value of '01/01/0001' so the difference between the current date and LastRpcRequest was a big double value, and casting that number to a int resulted in a negative value.

@Furtif Furtif requested a review from Xelwon November 23, 2017 20:50
@Furtif Furtif removed the request for review from Xelwon November 25, 2017 20:55
@Furtif Furtif merged commit bebd2a2 into Furtif:core Nov 25, 2017
@ghost ghost removed the in progress label Nov 25, 2017
@PeterDM65 PeterDM65 deleted the Throttling branch November 25, 2017 21:54
Copy link
Owner

@Furtif Furtif left a comment

Choose a reason for hiding this comment

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

Ok

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants