开发者

Why isn't this thread reading all data from the pipe consistently?

Anything wrong with this in general?

CallingFunction()
{
   CreatePipe()
   CreateMutex()开发者_开发问答
   CreateThread( ThreadFunction )

   while(there is data left to send)
   {
      WriteFile(send data in 256 byte chunks)
   }

   WaitForSingleobject() //don't return until ReadThread is done

   return 0;
 }

ThreadFunction()
{
   WaitForSinglObject()

   while(bytesRead != totalBytestoReadFileSize)
   {
      ReadfromPipe(in chunks)
      update bytesRead++
   }

   ReleaseMutex()

   return 0;
 }

Before the calling function ends -

FileSize: 232016

BytesWrittenToPipe: 232016

BytesReadFromPipe: 231946 or 232012 or 231840 -> Why not consistent?


Expecting us to debug such an issue from pseudo code is not realistic. Use FlushFileBuffers to ensure all data in the pipe is written.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜