// Transport Security Layer (TLS)
// Copyright (c) 2003-2004 Carlos Guzman Alvarez
-// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2006-2007 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
{
#region Fields
+ private static ManualResetEvent record_processing = new ManualResetEvent (true);
+
protected Stream innerStream;
protected Context context;
public IAsyncResult BeginReceiveRecord(Stream record, AsyncCallback callback, object state)
{
- if (this.context.ConnectionEnd)
+ if (this.context.ReceivedConnectionEnd)
{
throw new TlsException(
AlertDescription.InternalError,
"The session is finished and it's no longer valid.");
}
+ record_processing.Reset ();
byte[] recordTypeBuffer = new byte[1];
ReceiveRecordAsyncResult internalResult = new ReceiveRecordAsyncResult(callback, state, recordTypeBuffer, record);
if (internalResult.CompletedWithError)
throw internalResult.AsyncException;
- else
- return internalResult.ResultingBuffer;
+
+ byte[] result = internalResult.ResultingBuffer;
+ record_processing.Set ();
+ return result;
}
public byte[] ReceiveRecord(Stream record)
switch (alertDesc)
{
case AlertDescription.CloseNotify:
- this.context.ConnectionEnd = true;
+ this.context.ReceivedConnectionEnd = true;
break;
}
break;
// Write record
this.SendRecord (ContentType.Alert, new byte[2] { (byte) level, (byte) description });
- if (close)
- {
- this.context.ConnectionEnd = true;
+ if (close) {
+ this.context.SentConnectionEnd = true;
}
}
public IAsyncResult BeginSendRecord(ContentType contentType, byte[] recordData, AsyncCallback callback, object state)
{
- if (this.context.ConnectionEnd)
+ if (this.context.SentConnectionEnd)
{
throw new TlsException(
AlertDescription.InternalError,
int offset,
int count)
{
- if (this.context.ConnectionEnd)
+ if (this.context.SentConnectionEnd)
{
throw new TlsException(
AlertDescription.InternalError,
{
this.Context.RecordProtocol.SendAlert(AlertDescription.DecryptionFailed);
}
-
throw;
}