L
Lee Gillie
I am using the asynchronous I/O model to receive data over a socket, and
asynchronously write the incoming data to a disk file using FileStream.
So long as the pending writes have not yet completed I continue to
allocate more read buffers. As a result I can get a backlog of about 250
disk writes (1K buffers, because that is the max size the receiver will
give me).
During the course of a 50 MB transfer I get about 6 of these errors:
07:42:50.14 System.IndexOutOfRangeException: Probable I/O race condition
detected while copying memory. The I/O package is not thread safe by
default. In multithreaded applications, a stream must be accessed in a
thread-safe way, such as a thread-safe wrapper returned by TextReader's
or TextWriter's Synchronized methods. This also applies to classes like
StreamWriter and StreamReader.
07:42:50.14 at System.Buffer.InternalBlockCopy(Array src, Int32
srcOffset, Array dst, Int32 dstOffset, Int32 count)
07:42:50.14 at System.IO.FileStream.BeginWrite(Byte[] array, Int32
offset, Int32 numBytes, AsyncCallback userCallback, Object stateObject)
07:42:50.14 at
ODP.NMServe.DataChannelSession.ReceiveHandler(IAsyncResult ar)
I am obviously doing SOMETHING wrong. I was thinking the
FileSystem.BeginWrite was supposed to be safe to work from in the thread
pool utilized by the socket read completions. And that there was safe
FIFO queueing of requests. The FileStream was opened with the
asynchronous option TRUE. I am not sure what the error messages are
looking for, what I need to change to avoid this.
The disk I am writing to is an SCSI RAID 5 disk array. This runs on a
dual processor W2K box.
Thanks for any pointers
Best regards - Lee Gillie
asynchronously write the incoming data to a disk file using FileStream.
So long as the pending writes have not yet completed I continue to
allocate more read buffers. As a result I can get a backlog of about 250
disk writes (1K buffers, because that is the max size the receiver will
give me).
During the course of a 50 MB transfer I get about 6 of these errors:
07:42:50.14 System.IndexOutOfRangeException: Probable I/O race condition
detected while copying memory. The I/O package is not thread safe by
default. In multithreaded applications, a stream must be accessed in a
thread-safe way, such as a thread-safe wrapper returned by TextReader's
or TextWriter's Synchronized methods. This also applies to classes like
StreamWriter and StreamReader.
07:42:50.14 at System.Buffer.InternalBlockCopy(Array src, Int32
srcOffset, Array dst, Int32 dstOffset, Int32 count)
07:42:50.14 at System.IO.FileStream.BeginWrite(Byte[] array, Int32
offset, Int32 numBytes, AsyncCallback userCallback, Object stateObject)
07:42:50.14 at
ODP.NMServe.DataChannelSession.ReceiveHandler(IAsyncResult ar)
I am obviously doing SOMETHING wrong. I was thinking the
FileSystem.BeginWrite was supposed to be safe to work from in the thread
pool utilized by the socket read completions. And that there was safe
FIFO queueing of requests. The FileStream was opened with the
asynchronous option TRUE. I am not sure what the error messages are
looking for, what I need to change to avoid this.
The disk I am writing to is an SCSI RAID 5 disk array. This runs on a
dual processor W2K box.
Thanks for any pointers
Best regards - Lee Gillie