Skip to content

Commit

Permalink
connection socket writer thread fixed to catch ThreadInterruptedExcep…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
asimarslan committed Oct 26, 2016
1 parent 75b60fd commit 2df2c31
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 38 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,6 @@ docs/output
rc/

*.snk
.idea
*.jar

77 changes: 44 additions & 33 deletions Hazelcast.Net/Hazelcast.Client.Connection/ClientConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -371,52 +371,63 @@ private void StartReadWriteLoop()

private void WriteQueueLoop()
{
while (!_writeQueue.IsAddingCompleted)
try
{
try
while (!_writeQueue.IsAddingCompleted)
{
if (_lastWritable == null)
try
{
_lastWritable = _writeQueue.Take();
if (_lastWritable == null)
{
_lastWritable = _writeQueue.Take();
}
}
}
catch (InvalidOperationException)
{
//BlockingCollection is empty
if (_writeQueue.IsAddingCompleted)
catch (InvalidOperationException)
{
return;
//BlockingCollection is empty
if (_writeQueue.IsAddingCompleted)
{
return;
}
}
}

while (_sendBuffer.HasRemaining() && _lastWritable != null)
{
var complete = _lastWritable.WriteTo(_sendBuffer);
if (complete)
while (_sendBuffer.HasRemaining() && _lastWritable != null)
{
//grap one from queue
ISocketWritable tmp;
_writeQueue.TryTake(out tmp);
_lastWritable = tmp;
var complete = _lastWritable.WriteTo(_sendBuffer);
if (complete)
{
//grap one from queue
ISocketWritable tmp;
_writeQueue.TryTake(out tmp);
_lastWritable = tmp;
}
else
{
break;
}
}
else
if (_sendBuffer.Position > 0)
{
break;
_sendBuffer.Flip();
try
{
_stream.Write(_sendBuffer.Array(), _sendBuffer.Position, _sendBuffer.Remaining());
_sendBuffer.Clear();
}
catch (Exception e)
{
_lastWritable = null;
HandleSocketException(e);
}
}
}
if (_sendBuffer.Position > 0)

}
catch (ThreadInterruptedException)
{
if (Logger.IsFinestEnabled())
{
_sendBuffer.Flip();
try
{
_stream.Write(_sendBuffer.Array(), _sendBuffer.Position, _sendBuffer.Remaining());
_sendBuffer.Clear();
}
catch (Exception e)
{
_lastWritable = null;
HandleSocketException(e);
}
Logger.Finest("Writer thread interreptud, stopping...");
}
}
}
Expand Down
9 changes: 4 additions & 5 deletions Hazelcast.Net/Hazelcast.Net.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@
<Prefer32Bit>false</Prefer32Bit>
<DocumentationFile>bin\Debug\Hazelcast.Net.xml</DocumentationFile>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<NoWarn>1591</NoWarn>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<NoWarn>
</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand Down Expand Up @@ -597,9 +598,7 @@
<Output TaskParameter="CommitHash" PropertyName="CommitHash" />
</GitVersion>
<Message Text="Commit Hash: $(CommitHash)" />
<FileUpdate Files="Properties\AssemblyInfo.cs"
Regex="AssemblyConfiguration\(&quot;Commit.*&quot;\)"
ReplacementText="AssemblyConfiguration(&quot;Commit $(CommitHash)&quot;)"/>
<FileUpdate Files="Properties\AssemblyInfo.cs" Regex="AssemblyConfiguration\(&quot;Commit.*&quot;\)" ReplacementText="AssemblyConfiguration(&quot;Commit $(CommitHash)&quot;)" />
</Target>
<Target Name="Nightly">
<Message Text="Build Committed Revision: $(Revision)" />
Expand Down
20 changes: 20 additions & 0 deletions start-rc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/sh

if [ "$1" = "--local" ] ; then
USER="--user"
else
USER=""
fi

HAZELCAST_VERSION="3.7.2"
HAZELCAST_RC_VERSION="0.1-SNAPSHOT"
SNAPSHOT_REPO="https://oss.sonatype.org/content/repositories/snapshots"
RELEASE_REPO="http://repo1.maven.apache.org/maven2"
#ENTERPRISE_REPO="https://repository-hazelcast-l337.forge.cloudbees.com/release/"


mvn dependency:get -DrepoUrl=${SNAPSHOT_REPO} -Dartifact=com.hazelcast:hazelcast-remote-controller:${HAZELCAST_RC_VERSION} -Ddest=hazelcast-remote-controller-${HAZELCAST_RC_VERSION}.jar
mvn dependency:get -DrepoUrl=${RELEASE_REPO} -Dartifact=com.hazelcast:hazelcast:${HAZELCAST_VERSION} -Ddest=hazelcast-${HAZELCAST_VERSION}.jar

java -cp hazelcast-remote-controller-${HAZELCAST_RC_VERSION}.jar:hazelcast-${HAZELCAST_VERSION}.jar com.hazelcast.remotecontroller.Main
#>rc_stdout.log 2>rc_stderr.log &

0 comments on commit 2df2c31

Please sign in to comment.