I changed this with success:
opensuse102rc1:~/svn/simias-trunk # svn diff
Index: simias/src/core/Sync/StreamStream.cs
===================================================================
--- simias/src/core/Sync/StreamStream.cs (Revision 6842)
+++ simias/src/core/Sync/StreamStream.cs (Arbeitskopie)
@@ -39,6 +39,7 @@
static Queue Buffer =
Queue.Synchronized(new Queue(2));
static int buffSize = 1024 * 64;
AutoResetEvent writeComplete = new
AutoResetEvent(true);
+ AutoResetEvent waitAllDone = new
AutoResetEvent(true);
Exception exception;
private static readonly ISimiasLog log =
SimiasLogManager.GetLogger(typeof(StreamStream));
@@ -203,6 +204,7 @@
/// <returns>The number of bytes read.</returns>
public int Read(Stream outStream, int count)
{
+ waitAllDone.WaitOne();
wStream = outStream;
int bytesLeft = count;
while(bytesLeft > 0)
@@ -221,6 +223,7 @@
}
writeComplete.WaitOne();
writeComplete.Set();
+ waitAllDone.Set();
wStream = null;
return count - bytesLeft;
}
@@ -234,6 +237,7 @@
/// <returns>The number of bytes read.</returns>
public int Read(Stream outStream, int count, string
encryptionAlgorithm, string EncryptionKey)
{
+ waitAllDone.WaitOne();
wStream = outStream;
int paddingLength = 0, reminder = 0;
int bytesLeft = count;
@@ -277,6 +281,7 @@
}
writeComplete.WaitOne();
writeComplete.Set();
+ waitAllDone.Set();
wStream = null;
return count - bytesLeft + paddingLength;
}
@@ -312,6 +317,7 @@
/// <param name="count">The number of bytes to write.</param>
public void Write(Stream inStream, int count)
{
+// waitAllDone.WaitOne();
int bytesLeft = count;
while(bytesLeft > 0)
{
@@ -329,6 +335,7 @@
}
writeComplete.WaitOne();
writeComplete.Set();
+// waitAllDone.Set();
}
/// <summary>
@@ -339,6 +346,7 @@
/// <param name="encryption_key">Key to encrypt the data
with.</param>
public void Write(Stream inStream, int count, int actualCount,
string encryptionAlgorithm, string EncryptionKey)
{
+// waitAllDone.WaitOne();
int bytesLeft = count;
int bytesToWrite;
while(bytesLeft > 0)
@@ -382,6 +390,7 @@
writeComplete.WaitOne();
writeComplete.Set();
+// waitAllDone.Set();
}
/// <summary>
###########################
The Sequence
writeComplete.WaitOne();
writeComplete.Set();
shall (as far as i can see) prevent the function to be terminated until
readWriteComplete has finished with finalize().
As in the logs above there is a timing problem with this, so i split of the
behaviour into waitAllDone.WaitOne() and waitAllDone.Set().
Possibly the
writeComplete.WaitOne();
writeComplete.Set();
Statement is obsolete now (to be tested).
I also added it to the corresponding Write()-functions, but with // - as the
sequence is here the same (to be tested).
Please check and apply patch.
Greets
Jan-Simon
_______________________________________________
ifolder-dev mailing list
[email protected]
http://forge.novell.com/mailman/listinfo/ifolder-dev