Re: BUG in Winsock on P4 HT CPU

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Glambert (Glambert_at_discussions.microsoft.com)
Date: 09/07/04


Date: Tue, 7 Sep 2004 08:23:01 -0700

Multiple calls to Recieve() within OnReceive() will also cause the socket to
"hang" on a single, nonHT cpu...its just that it does not happen as
frequently.

I agree with Greg about CAsyncSocket::DoCallBacks() should renable
notification when it detects no data for an FD_READ (and subsequently does
not call the OnRecieve()) by calling recv() and requesting 0 bytes. It seems
this would renable notificaiton.
"Chris P. [MVP]" wrote:

> Greg Ennis wrote:
> > Wedson,
> >
> > Thanks for the reply and the explanation. So the problem is a race
> > condition that (usually) all 4 reads occur before an FD_READ could be
> > posted, but on a HT CPU or on a dual CPU, it is running other threads
> > simultaneously so it manages to post an FD_READ before I read all the
> > data. Then there is nothing left to read and MFC does not re-enable
> > notifications. Is that right?
> >
> > The best fix obviously is to read all the data in one read call in my
> > app. But other than this (which I cant due to the complex nature of
> > the actual app), what is the proper fix for this? It seems that MFC
> > should re-enable notifications on SOCKET_ERROR, but I can do it
> > myself in the app after reading everything as marked by the //!
> > comments. Is this a decent fix?
>
> On my dual CPU Xeon the test barely gets off the ground. Usually only 0 or
> 1 packet sent. Set the process affinity to 1, which essentially makes it a
> single processor system as far as the application is concerned and your test
> works as you expect.
>
> Calling Receive() only once from inside OnReceive() does fix the problem.
> You don't have to read all available data in the callback but you should be
> aware that you will receive no further notifications for the data that is
> already in the receive buffer. The cheat, in your case is to either call
> AsyncSelect() or to force your application to only run on a single
> processor. A slight redesign of your procedures is probably the best way to
> go if you can.
>
> Multi-CPU's does make a programmer's life more difficult, you can no longer
> think sequentially.
>
>
>



Relevant Pages

  • Re: VS2005 - network headers slow network operations to a crawl
    ... appears to be a real problem related to a massive stream of "change ... That's why I suggested getting the network guy to look at it. ... client re-directs related to the change notifications. ... When I say "fix", I mean with a very fast network with custom built o/s, ...
    (microsoft.public.vsnet.general)
  • Re: Rules Wizard problem
    ... That's real easy to fix. ... I believe that this is towards the bottom of the page where you ... > Have any of you worked out how to stop getting 2 notifications of an email ...
    (microsoft.public.outlook.general)
  • Amavis Virus Notifications [solved]
    ... Last week someone asked the question of how to turn off virus ... notifications; not notification to the sender, ... I've located the fix. ... Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org ...
    (Ubuntu)