Re: BUG in Winsock on P4 HT CPU
From: Glambert (Glambert_at_discussions.microsoft.com)
Date: 09/07/04
- Next message: Callum Winter: "Password Security"
- Previous message: Glambert: "RE: BUG in Winsock on P4 HT CPU"
- Messages sorted by: [ date ] [ thread ]
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.
>
>
>
- Next message: Callum Winter: "Password Security"
- Previous message: Glambert: "RE: BUG in Winsock on P4 HT CPU"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|