Page 1 of 1

IPC and wxYield -

Posted: Thu Jan 10, 2008 7:38 am
by celstark
I've got two applications that need to talk. At the moment, they will just send simple messages, but down the road, decent chunks of data will need to go between them. Overall, things are working fine with wxServer and wxClient. If the server program is in an idle state, Execute messages come in from the client without issue (e.g., I show them in the Status Bar and all is fine and dandy).

In practice, the Server program will be active when these signals come in (e.g., capturing data from a device and showing it in a window). One command, for example, is to pause this capture / display process.

Here is where the trouble lies. The capture and display need to call wxYield. Captures take several seconds and while 95% of the UI is locked, an Abort button is present and needs to be able to be signaled. If I don't run a wxYield, my display doesn't get updated properly, etc.

So, I need wxYield is this capture/display loop. When that loop is active, any incoming Execute or Connect messages cause the server to lock up with the stack being:

#0 0x0011836d in GetTimeZone at IPCserver.cpp:69
#1 0x00118450 in wxDateTime::TimeZone::TimeZone at IPCserver.cpp:69
#2 0x0018481d in wxSocketBase::_Wait at IPCserver.cpp:69
#3 0x00184d9d in wxSocketBase::WaitForRead at IPCserver.cpp:69
#4 0x00184e4b in wxSocketBase::_Read at IPCserver.cpp:69
#5 0x00184fc9 in wxSocketBase::Read at IPCserver.cpp:69
#6 0x00183b1d in wxSocketInputStream::OnSysRead at IPCserver.cpp:69
#7 0x0027196c in wxInputStream::Read at IPCserver.cpp:69
#8 0x0026ab3c in wxDataInputStream::Read8 at IPCserver.cpp:69
#9 0x001823f0 in wxTCPEventHandler::Server_OnRequest at IPCserver.cpp:69
#10 0x001759bc in wxEvtHandler::ProcessEventIfMatches at IPCserver.cpp:69
#11 0x00175b53 in wxEventHashTable::HandleEvent at IPCserver.cpp:69
#12 0x00175fd7 in wxEvtHandler::ProcessEvent at IPCserver.cpp:69
#13 0x00176383 in wxEvtHandler::ProcessPendingEvents at IPCserver.cpp:69
#14 0x00111408 in wxAppConsole::ProcessPendingEvents at IPCserver.cpp:69
#15 0x0027d0e7 in wxMacProcessNotifierAndPendingEvents at IPCserver.cpp:69
#16 0x0018b53c in wxApp::MacHandleOneEvent at IPCserver.cpp:69
#17 0x0018b6b7 in wxApp::Yield at IPCserver.cpp:69
#18 0x00007be8 in MyFrame::OnLoopExposure at frame_events.cpp:202

Note, for #18 there, it is the wxYield(true) line that it is hung up on. So, while it's not throwing an error about a recursive wxYield, my guess is this is what is happening from reading several other threads here.

FWIW, this is on wxMac 2.8.6 at the moment (cross-platform app) and I am using Unix domain-style IPC as suggested in the docs (no need to run cross-machines).

Any idea what's happening with the IPC events here that is causing this / a way around it? Any guidance would be greatly appreciated.


Posted: Sat Jan 12, 2008 9:16 pm
by celstark
I'm going to answer my own question here. There appears to be no way. WaitForRead calls _Wait which calls wxYield and it looks like we're going to have wxYield called more than once at the same time, mucking up the event handling.

I've recoded things with wxSocketServer and wxSocketClient and things are running nicely. These have a good bit more control over the trade-offs and I can just have the GUI lock up briefly when things come in and don't seem to need to put this in its own thread. Data xfer is actually a bit easier with these as well, so I'd encourage others to look at these.


Posted: Mon Nov 03, 2008 9:45 am
by sago

I have the same problem as you. Could you help me please ?.