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

fixed #1194 (ThrottleTransportAdapter overflow bug) #1195

Merged
merged 1 commit into from
Aug 3, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified src/.nuget/NuGet.exe
Binary file not shown.
3 changes: 2 additions & 1 deletion src/core/Akka.Remote.Tests/Transport/ThrottleModeSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
using System;
using Akka.Remote.Transport;
using Akka.TestKit;
using Akka.Util;
using Xunit;

namespace Akka.Remote.Tests.Transport
{
public class ThrottleModeSpec : AkkaSpec
{
static readonly long HalfSecond = TimeSpan.FromSeconds(0.5).Ticks;
static readonly long HalfSecond = TimeSpan.FromSeconds(0.5).Ticks.ToNanos();

[Fact]
public void ThrottleMode_must_allow_consumption_of_infinite_amount_of_tokens_when_unthrottled()
Expand Down
4 changes: 3 additions & 1 deletion src/core/Akka.Remote/Transport/ThrottleTransportAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,9 @@ public override TimeSpan TimeToAvailable(long currentNanoTime, int tokens)

int TokensGenerated(long nanoTimeOfSend)
{
return Convert.ToInt32(((double)(nanoTimeOfSend - _nanoTimeOfLastSend) / TimeSpan.TicksPerMillisecond) * _tokensPerSecond / 1000);
var milliSecondsSinceLastSend = ((nanoTimeOfSend - _nanoTimeOfLastSend).ToTicks()/TimeSpan.TicksPerMillisecond);
var tokensGenerated = milliSecondsSinceLastSend*_tokensPerSecond/1000;
return Convert.ToInt32(tokensGenerated);
}

TokenBucket Copy(int? capacity = null, double? tokensPerSecond = null, long? nanoTimeOfLastSend = null, int? availableTokens = null)
Expand Down