🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #7932

Re: Missing data from network writes (Win2K client and server)

#7932
From: Bob Gonder
Date: Wed, 08 Dec 2004 19:10
109 lines
4590 bytes
Andrue Cope [TeamB] wrote:

>I added code to read the data back and compare it and that always
>succeeds..even when the resulting file claims not to contain that data.

Yes, Windows buffers the data and so can "read" it even if it hasn't
been flushed to disk.

>Our conclusion after a day's investigation is that the network
>requesters are simply failing to pass the data to the server. We are
>investigating different versions of Windows now since the only reason
>this can have remained hidden is that it's the result of a recent
>service pack or update.

Win95 had a redirector problem. MS had a patch for it. Q142803


>My own pet theory is that the requester has a queue for I/O requests
>and we are eventually filling it and the requester doesn't report an
>error or wait for the queue to empty. The only problem with this is
>that we've boiled what we're doing down to a single function (see
>below) and it doesn't exhibit this behaviour.
>
>bool TForm1::diskIsGood()
>{
>  HANDLE outHandle=CreateFile("l:\\tmp.apc\\baddy",
>                              GENERIC_READ|GENERIC_WRITE,
>                              FILE_SHARE_READ,
>                              NULL,
>                              CREATE_ALWAYS,
>                              0,
>                              NULL);

I would add  FILE_FLAG_WRITE_THROUGH

>     HANDLE fileHandle = CreateFile("\\\\.\\e:",
>                                    GENERIC_READ|GENERIC_WRITE,
>                                    FILE_SHARE_READ,
>                                    NULL,
>                                    OPEN_ALWAYS,
>                                    0,
>                                    NULL);
>
>  BYTE buffer[ 65535 ];
>
>  QWORD total=0;
>  for( DWORD blockNumber=0;
>       blockNumber<205000;
>       blockNumber+=31 )
>  {
>    SetFilePointer( fileHandle,
>                    blockNumber*DWORD( 2048 ),
>                    NULL,
>                    FILE_BEGIN );
>
>    DWORD bytesRead=0;
>
>    if( !ReadFile( fileHandle,
>                  buffer,
>                  2048*31,
>                  &bytesRead,
>                  NULL ) )
>    {
>      memset( buffer, '*', 2048*31 );

	You don't handle short reads (eof, or in this case, eod).
	Check bytesRead.
>    }
>
>  QWORD NewPosition=blockNumber*DWORD( 2048 );
	ULARGE_INTEGER  NewPosition;
	NewPosition.QuadPart = (ULONGLONG)blockNumber * 2048U;
>  long  hi=long( NewPosition>>32 );
>  long  lo=long( NewPosition&0xFFFFFFFF );

If you feel you need to do this for the write, you should also do it
for the read.

>    SetFilePointer( outHandle,
>                    lo,
>                    &hi,
>                    FILE_BEGIN );

SetFilePointer(outHandle,NewPosition.LoPart,&NewPosition.HighPart);
>
>    total+=2048*31;
>    if( !WriteFile( outHandle,
>                    buffer,
>                    2048*31,

This should be bytesRead instead of 62k unless you are filling the
un-read buffer space with 0

>                    &bytesRead,
>                    NULL ) )
>      return false;
>
>    Label1->Caption=General_StrComma( total );
>
>    Application->ProcessMessages();
>  }
>
>  ShowMessage( General_StrComma( total ) );
>
>  CloseHandle( outHandle );
>  CloseHandle( fileHandle );
>
>  return true;
>}
Technical Details
Message-ID: <jpher0lh8non9lu46pu2ql4tk7v2b074vn@4ax.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!newsgate.cistron.nl!feeder.enertel.nl!nntpfeed-01.ops.asmr-01.energis-idc.net!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <41b6de1f$1@newsgroups.borland.com> <41b731e9$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,99122155c7605386
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: Bob Gonder <notbg@notmindspring.invalid>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: Missing data from network writes (Win2K client and server)
Date: Wed, 08 Dec 2004 11:10:11 -0800
Organization: MindSpring Enterprises, Inc.
Reply-To: notbg@notmindspring.invalid
Message-ID: <jpher0lh8non9lu46pu2ql4tk7v2b074vn@4ax.com>
References: <41b6de1f$1@newsgroups.borland.com> <41b731e9$1@newsgroups.borland.com>
X-Newsreader: Forte Agent 1.93/32.576 English (American)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 67.77.36.235
X-Trace: newsgroups.borland.com 1102533009 67.77.36.235 (8 Dec 2004 11:10:09 -0800)
Lines: 110
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!newsgate.cistron.nl!feeder.enertel.nl!nntpfeed-01.ops.asmr-01.energis-idc.net!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail