Try and fix thread callback double-free crash by going via RT message queue

nix
Owen Green 5 years ago
parent 54cda6c78b
commit 360155f4c4

@ -70,7 +70,7 @@ namespace impl {
}
else //client has screwed up
{
std::cout << "ERROR: ID " << id << " already in use\n";
std::cout << "ERROR: " << Wrapper::getName() << " ID " << id << " already in use\n";
return {};
}
}
@ -313,11 +313,10 @@ namespace impl {
bool mSuccess;
};
static void doProcessCallback(World* world, index id,size_t completionMsgSize,char* completionMessage,void* replyAddress)
{
// std::cout << "In callback\n";
auto ft = getInterfaceTable();
struct Context{
World* mWorld;
index mID;
@ -328,6 +327,8 @@ namespace impl {
Context* c = new Context{world,id,completionMsgSize,completionMessage,replyAddress};
auto launchCompletionFromNRT = [](FifoMsg* inmsg)
{
auto runCompletion = [](FifoMsg* msg){
// std::cout << "In FIFOMsg\n";
Context* c = static_cast<Context*>(msg->mData);
@ -345,9 +346,17 @@ namespace impl {
delete c;
};
auto ft = getInterfaceTable();
FifoMsg fwd = *inmsg;
fwd.Set(inmsg->mWorld, runCompletion, tidyup, inmsg->mData);
if(inmsg->mWorld->mRunning)
ft->fSendMsgToRT(inmsg->mWorld,fwd);
};
FifoMsg msg;
msg.Set(world, runCompletion, tidyup, c);
if(world->mRunning) ft->fSendMsgToRT(world,msg);
msg.Set(world, launchCompletionFromNRT, nullptr, c);
if(world->mRunning) ft->fSendMsgFromRT(world,msg);
}
struct CommandProcess: public NRTCommand

Loading…
Cancel
Save