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

Commit 060f53b

Browse files
committed
Don't loop for ever waiting for cipher
1 parent 89bd048 commit 060f53b

4 files changed

Lines changed: 22 additions & 3 deletions

File tree

src/DTLS.Net/Client.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,17 @@ private void ProcessHandshake(DTLSRecord record)
128128
byte[] data;
129129
if (_EncyptedServerEpoch.HasValue && (_EncyptedServerEpoch.Value == record.Epoch))
130130
{
131-
while (_Cipher == null)
131+
132+
int count = 0;
133+
while ((_Cipher == null) && (count < 50))
134+
{
132135
System.Threading.Thread.Sleep(10);
136+
count++;
137+
}
138+
139+
if (_Cipher == null)
140+
throw new Exception();
141+
133142

134143
if (_Cipher != null)
135144
{

src/DTLS.Net/Server.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ private void ProcessRecord(SocketAddress address, Session session, DTLSRecord re
362362
catch
363363
{
364364
#endif
365+
SendAlert(session, address, TAlertLevel.Fatal, TAlertDescription.InternalError);
365366
}
366367
}
367368

src/DTLS.Net/ServerHandshake.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,17 @@ public void ProcessHandshake(DTLSRecord record)
7171
byte[] data;
7272
if ((session != null) && session.IsEncypted(record))
7373
{
74-
while (session.Cipher == null)
74+
int count = 0;
75+
while ((session.Cipher == null) && (count < 50))
76+
{
7577
System.Threading.Thread.Sleep(10);
78+
count++;
79+
}
80+
81+
if (session.Cipher == null)
82+
{
83+
throw new Exception();
84+
}
7685

7786
if (session.Cipher != null)
7887
{

src/DTLS.Net/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "1.0.18-*",
2+
"version": "1.0.19-*",
33
"title": "DTLS.Net",
44
"description": "DTLS.Net Class Library",
55
"authors": [ "Delme Thomas" ],

0 commit comments

Comments
 (0)