Click here to Skip to main content
15,903,388 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generalstring compare Pin
pnpfriend12-Jul-02 4:41
pnpfriend12-Jul-02 4:41 
GeneralRe: string compare Pin
jfugate12-Jul-02 5:05
jfugate12-Jul-02 5:05 
GeneralRe: string compare Pin
pnpfriend12-Jul-02 5:47
pnpfriend12-Jul-02 5:47 
GeneralRe: string compare Pin
Mel Stober12-Jul-02 6:59
Mel Stober12-Jul-02 6:59 
GeneralRe: string compare Pin
valikac12-Jul-02 5:08
valikac12-Jul-02 5:08 
GeneralRe: string compare Pin
pnpfriend12-Jul-02 5:39
pnpfriend12-Jul-02 5:39 
GeneralRe: string compare Pin
valikac12-Jul-02 9:04
valikac12-Jul-02 9:04 
GeneralMore multi processor woes Pin
Jim Crafton12-Jul-02 4:39
Jim Crafton12-Jul-02 4:39 
I have a socket server app that accepts a connection from our data feed (we send out financial data for various markets). This server has several threads, one for reading from the socket, and another for parsing the current chunk of data read in by the socket read thread. THe parse thread in turn adds a new instance of a data object (created by parsing the incoming data from the socket) to list. This list is protected by a critical section for both reads and writes. The two threads each have an event which is used to wake them up whenever new data is available.
All of this is set up as a DLL, that is then used as a library for some specific application.
When used in a console app this works fine, runs on single processor, or multi-processor machines like a charm - no mem leaks, no race cond, and stays up for weeks (the longest I kept is running was for 4 weeks - I shut it down to test something else).

Sadly, when the DLL is used in an MFC this is no longer the case. On single processor machines it seems to run fine. On our multi-processor Winnt4 box it crashes within an hour.

The gui app is a simple MFC dialog app, that uses a tray icon to remain invisible. When the icon is double click it displays a dialog with some list views that display various stats - like how many data packets have been recv, how many bytes, etc.


The libary works by creating a library object and then inside of a loop somewhere repeated calling a handleEvent() function. In the console program the code looks something like this:

GTIS::Application& app = GTIS::Application::getApp();

printf( "Starting application loop...\n" );
int count = 0;
while ( true ) {
    app.handleEvents(5); //the 5 is the num of milliseconds to
                         //wait before timeing out
    count ++;
    Sleep(0);
}


In the MFC app I have a timer that fires off every 10 milliseconds

in the call back for the timer message I call the
handleEvents() method

the crash occurs when the library goes to delete one of the newly allocated data objects (that was created from parsing the incoming socket data). This crash NEVER occurs in a single processor box only multiprocessor - the call stack is deep in the destructor code - curiously enough in the STL basic_string code, since the data object has a number of string members.

I have been staring at the code for days and I can think of nothing other than perhaps now would be a good time to open that lawn care business...

Thanks in advance !
GeneralRe: More multi processor woes Pin
Giles12-Jul-02 5:16
Giles12-Jul-02 5:16 
GeneralRe: More multi processor woes Pin
Jim Crafton12-Jul-02 5:41
Jim Crafton12-Jul-02 5:41 
GeneralRe: More multi processor woes Pin
l a u r e n12-Jul-02 7:47
l a u r e n12-Jul-02 7:47 
GeneralRe: More multi processor woes Pin
Giles12-Jul-02 10:46
Giles12-Jul-02 10:46 
GeneralWinsock - discovering ip address Pin
JohnnyG12-Jul-02 4:32
JohnnyG12-Jul-02 4:32 
GeneralRe: Winsock - discovering ip address Pin
markkuk12-Jul-02 8:21
markkuk12-Jul-02 8:21 
GeneralRe: Winsock - discovering ip address Pin
JohnnyG13-Jul-02 15:41
JohnnyG13-Jul-02 15:41 
GeneralMarquee in visual C++ Pin
John Duffell12-Jul-02 3:58
John Duffell12-Jul-02 3:58 
GeneralRe: Marquee in visual C++ Pin
l a u r e n12-Jul-02 7:50
l a u r e n12-Jul-02 7:50 
GeneralRe: Marquee in visual C++ Pin
NormDroid12-Jul-02 23:29
professionalNormDroid12-Jul-02 23:29 
GeneralSorting items in a listctrl Pin
Niko Tanghe12-Jul-02 3:47
Niko Tanghe12-Jul-02 3:47 
GeneralRe: Sorting items in a listctrl Pin
KaЯl12-Jul-02 4:08
KaЯl12-Jul-02 4:08 
GeneralRe: Sorting items in a listctrl Pin
Mike Upton12-Jul-02 4:17
Mike Upton12-Jul-02 4:17 
GeneralRe: Sorting items in a listctrl Pin
Niko Tanghe12-Jul-02 4:54
Niko Tanghe12-Jul-02 4:54 
GeneralRe: Knowing Client Window Messages in MDI Window ... Pin
Mike Upton12-Jul-02 3:48
Mike Upton12-Jul-02 3:48 
GeneralSeems to work, but not all messages... Pin
Cursoe12-Jul-02 20:01
sussCursoe12-Jul-02 20:01 
GeneralRe: Knowing Client Window Messages in MDI Window ... Pin
Mike Upton12-Jul-02 3:52
Mike Upton12-Jul-02 3:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.