Skip to content
This repository has been archived by the owner on Apr 17, 2021. It is now read-only.

Commit

Permalink
Don't loop for ever waiting for cipher
Browse files Browse the repository at this point in the history
  • Loading branch information
delmet committed Sep 23, 2016
1 parent 89bd048 commit 060f53b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
11 changes: 10 additions & 1 deletion src/DTLS.Net/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,17 @@ private void ProcessHandshake(DTLSRecord record)
byte[] data;
if (_EncyptedServerEpoch.HasValue && (_EncyptedServerEpoch.Value == record.Epoch))
{
while (_Cipher == null)

int count = 0;
while ((_Cipher == null) && (count < 50))
{
System.Threading.Thread.Sleep(10);
count++;
}

if (_Cipher == null)
throw new Exception();


if (_Cipher != null)
{
Expand Down
1 change: 1 addition & 0 deletions src/DTLS.Net/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ private void ProcessRecord(SocketAddress address, Session session, DTLSRecord re
catch
{
#endif
SendAlert(session, address, TAlertLevel.Fatal, TAlertDescription.InternalError);
}
}

Expand Down
11 changes: 10 additions & 1 deletion src/DTLS.Net/ServerHandshake.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,17 @@ public void ProcessHandshake(DTLSRecord record)
byte[] data;
if ((session != null) && session.IsEncypted(record))
{
while (session.Cipher == null)
int count = 0;
while ((session.Cipher == null) && (count < 50))
{
System.Threading.Thread.Sleep(10);
count++;
}

if (session.Cipher == null)
{
throw new Exception();
}

if (session.Cipher != null)
{
Expand Down
2 changes: 1 addition & 1 deletion src/DTLS.Net/project.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.0.18-*",
"version": "1.0.19-*",
"title": "DTLS.Net",
"description": "DTLS.Net Class Library",
"authors": [ "Delme Thomas" ],
Expand Down

0 comments on commit 060f53b

Please sign in to comment.