mirror of
https://github.com/TalAloni/SMBLibrary.git
synced 2025-04-30 10:47:48 +02:00
Do not try to prefetch write-only streams
This commit is contained in:
parent
8c7b17426c
commit
af936b2217
1 changed files with 15 additions and 12 deletions
|
@ -25,22 +25,25 @@ namespace Utilities
|
||||||
public PrefetchedStream(Stream stream)
|
public PrefetchedStream(Stream stream)
|
||||||
{
|
{
|
||||||
m_stream = stream;
|
m_stream = stream;
|
||||||
new Thread(delegate()
|
if (m_stream.CanRead)
|
||||||
{
|
{
|
||||||
lock (m_syncLock)
|
new Thread(delegate()
|
||||||
{
|
{
|
||||||
m_cacheOffset = 0;
|
lock (m_syncLock)
|
||||||
m_cache = new byte[CacheSize];
|
|
||||||
int bytesRead = m_stream.Read(m_cache, 0, CacheSize);
|
|
||||||
System.Diagnostics.Debug.Print("[{0}] bytes read {1}", DateTime.Now.ToString("HH:mm:ss:ffff"), bytesRead);
|
|
||||||
this.Position = 0;
|
|
||||||
if (bytesRead < CacheSize)
|
|
||||||
{
|
{
|
||||||
// EOF, we must trim the response data array
|
m_cacheOffset = 0;
|
||||||
m_cache = ByteReader.ReadBytes(m_cache, 0, bytesRead);
|
m_cache = new byte[CacheSize];
|
||||||
|
int bytesRead = m_stream.Read(m_cache, 0, CacheSize);
|
||||||
|
System.Diagnostics.Debug.Print("[{0}] bytes read {1}", DateTime.Now.ToString("HH:mm:ss:ffff"), bytesRead);
|
||||||
|
this.Position = 0;
|
||||||
|
if (bytesRead < CacheSize)
|
||||||
|
{
|
||||||
|
// EOF, we must trim the response data array
|
||||||
|
m_cache = ByteReader.ReadBytes(m_cache, 0, bytesRead);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}).Start();
|
||||||
}).Start();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int Read(byte[] buffer, int offset, int count)
|
public override int Read(byte[] buffer, int offset, int count)
|
||||||
|
|
Loading…
Add table
Reference in a new issue