Imported Upstream version 4.2.0.179

Former-commit-id: 0a113cb3a6feb7873f632839b1307cc6033cd595
This commit is contained in:
Xamarin Public Jenkins
2015-08-26 07:17:56 -04:00
committed by Jo Shields
parent 183bba2c9a
commit 6992685b86
7507 changed files with 90259 additions and 657307 deletions

View File

@@ -601,6 +601,9 @@ namespace Mono.Security.Protocol.Tls
{
asyncResult.SetComplete(preReadSize);
}
else if (recordStream.Position < recordStream.Length) {
InternalReadCallback_inner (asyncResult, recbuf, new object[] { recbuf, asyncResult }, false, 0);
}
else if (!this.context.ReceivedConnectionEnd)
{
// this will read data from the network until we have (at least) one
@@ -650,6 +653,24 @@ namespace Mono.Security.Protocol.Tls
return;
}
InternalReadCallback_inner(internalResult, recbuf, state, true, n);
}
catch (Exception ex)
{
internalResult.SetComplete(ex);
}
}
// read encrypted data until we have enough to decrypt (at least) one
// record and return are the records (may be more than one) we have
private void InternalReadCallback_inner(InternalAsyncResult internalResult, byte[] recbuf, object[] state, bool didRead, int n)
{
if (this.disposed)
return;
try
{
bool dataToReturn = false;
long pos = recordStream.Position;
@@ -713,7 +734,7 @@ namespace Mono.Security.Protocol.Tls
pos = 0;
}
if (!dataToReturn && (n > 0))
if (!dataToReturn && (!didRead || (n > 0)))
{
if (context.ReceivedConnectionEnd) {
internalResult.SetComplete (0);
@@ -744,7 +765,6 @@ namespace Mono.Security.Protocol.Tls
{
internalResult.SetComplete(ex);
}
}
private void InternalBeginWrite(InternalAsyncResult asyncResult)
@@ -1022,6 +1042,7 @@ namespace Mono.Security.Protocol.Tls
if (remainder > 0) {
recordStream.Write (outofrecord, 0, outofrecord.Length);
recordStream.Position = 0;
}
if (dataToReturn) {