Author: alanmc
Date: 2008-01-03 17:32:06 -0500 (Thu, 03 Jan 2008)
New Revision: 92211

Modified:
   trunk/bitsharp/src/MonoTorrent/Client/BufferedFileRead.cs
   trunk/bitsharp/src/MonoTorrent/Client/Managers/DiskManager.cs
   trunk/bitsharp/src/MonoTorrent/Client/Managers/FileManager.cs
Log:
Bugfix: Propagate the bytesRead back from the async read

Modified: trunk/bitsharp/src/MonoTorrent/Client/BufferedFileRead.cs
===================================================================
--- trunk/bitsharp/src/MonoTorrent/Client/BufferedFileRead.cs   2008-01-03 
21:52:54 UTC (rev 92210)
+++ trunk/bitsharp/src/MonoTorrent/Client/BufferedFileRead.cs   2008-01-03 
22:32:06 UTC (rev 92211)
@@ -13,6 +13,7 @@
         public int BufferOffset;
         public long PieceStartIndex;
         public int Count;
+        public int BytesRead;
 
 
         public BufferedFileRead(FileManager manager, byte[] buffer, int 
bufferOffset, long pieceStartIndex, int count)

Modified: trunk/bitsharp/src/MonoTorrent/Client/Managers/DiskManager.cs
===================================================================
--- trunk/bitsharp/src/MonoTorrent/Client/Managers/DiskManager.cs       
2008-01-03 21:52:54 UTC (rev 92210)
+++ trunk/bitsharp/src/MonoTorrent/Client/Managers/DiskManager.cs       
2008-01-03 22:32:06 UTC (rev 92211)
@@ -256,7 +256,7 @@
         /// <param name="bufferedFileIO"></param>
         private void PerformRead(BufferedFileRead io)
         {
-            Read(io.Manager, io.Buffer, io.BufferOffset, io.PieceStartIndex, 
io.Count);
+            io.BytesRead = Read(io.Manager, io.Buffer, io.BufferOffset, 
io.PieceStartIndex, io.Count);
             io.WaitHandle.Set();
         }
 

Modified: trunk/bitsharp/src/MonoTorrent/Client/Managers/FileManager.cs
===================================================================
--- trunk/bitsharp/src/MonoTorrent/Client/Managers/FileManager.cs       
2008-01-03 21:52:54 UTC (rev 92210)
+++ trunk/bitsharp/src/MonoTorrent/Client/Managers/FileManager.cs       
2008-01-03 22:32:06 UTC (rev 92211)
@@ -218,7 +218,7 @@
                         manager.Engine.DiskManager.QueueRead(read);
                         read.WaitHandle.WaitOne();
                         read.WaitHandle.Close();
-
+                        bytesRead = read.BytesRead;
                         hasher.TransformBlock(hashBuffer.Array, 
hashBuffer.Offset, bytesRead, hashBuffer.Array, hashBuffer.Offset);
                         totalRead += bytesRead;
                         pieceStartIndex += bytesToRead;

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to