Browse Source

Fix bridge zombies, closes #123

tags/1.9.5
falkTX 10 years ago
parent
commit
0cf3d9ea7a
5 changed files with 24 additions and 5 deletions
  1. +6
    -1
      source/backend/engine/CarlaEngineBridge.cpp
  2. +3
    -0
      source/backend/plugin/BridgePlugin.cpp
  3. +10
    -3
      source/backend/plugin/CarlaPluginThread.cpp
  4. +1
    -0
      source/bridges-plugin/CarlaBridgePlugin.cpp
  5. +4
    -1
      source/utils/CarlaBridgeUtils.hpp

+ 6
- 1
source/backend/engine/CarlaEngineBridge.cpp View File

@@ -578,7 +578,7 @@ public:
CARLA_SAFE_ASSERT_BREAK(data != nullptr);

CarlaString dataBase64 = CarlaString::asBase64(data, dataSize);
CARLA_SAFE_ASSERT_RETURN(dataBase64.length() > 0,);
CARLA_SAFE_ASSERT_BREAK(dataBase64.length() > 0);

String filePath(File::getSpecialLocation(File::tempDirectory).getFullPathName());

@@ -651,6 +651,7 @@ public:

case kPluginBridgeNonRtQuit:
signalThreadShouldExit();
callback(ENGINE_CALLBACK_QUIT, 0, 0, 0, 0.0f, nullptr);
break;
}
}
@@ -868,6 +869,10 @@ protected:

break;
}

case kPluginBridgeRtQuit:
signalThreadShouldExit();
break;
}
}



+ 3
- 0
source/backend/plugin/BridgePlugin.cpp View File

@@ -383,6 +383,9 @@ public:
fShmNonRtControl.writeOpcode(kPluginBridgeNonRtQuit);
fShmNonRtControl.commitWrite();

fShmRtControl.writeOpcode(kPluginBridgeRtQuit);
fShmRtControl.commitWrite();

if (! fTimedOut)
fShmRtControl.waitForServer(3);
}


+ 10
- 3
source/backend/plugin/CarlaPluginThread.cpp View File

@@ -274,7 +274,7 @@ void CarlaPluginThread::run()
// we only get here if UI was closed or thread asked to exit
if (fProcess->isRunning() && shouldThreadExit())
{
//fProcess->waitForFinished(static_cast<int>(fEngine->getOptions().uiBridgesTimeout));
fProcess->waitForProcessToFinish(static_cast<int>(fEngine->getOptions().uiBridgesTimeout));

if (fProcess->isRunning())
{
@@ -309,12 +309,19 @@ void CarlaPluginThread::run()
carla_sleep(1);

// we only get here if bridge crashed or thread asked to exit
if (shouldThreadExit())
if (fProcess->isRunning() && shouldThreadExit())
{
fProcess->getExitCode(); // TEST
fProcess->waitForProcessToFinish(2000);

if (fProcess->isRunning())
{
carla_stdout("CarlaPluginThread::run() - bridge refused to close, force kill now");
fProcess->kill();
}
else
{
carla_stdout("CarlaPluginThread::run() - bridge auto-closed successfully");
}
}
else
{


+ 1
- 0
source/bridges-plugin/CarlaBridgePlugin.cpp View File

@@ -325,6 +325,7 @@ protected:
{
case ENGINE_CALLBACK_ENGINE_STOPPED:
case ENGINE_CALLBACK_PLUGIN_REMOVED:
case ENGINE_CALLBACK_QUIT:
gCloseNow = true;
break;



+ 4
- 1
source/utils/CarlaBridgeUtils.hpp View File

@@ -61,7 +61,8 @@ enum PluginBridgeRtOpcode {
kPluginBridgeRtControlEventAllSoundOff, // uint/frame, byte/chan
kPluginBridgeRtControlEventAllNotesOff, // uint/frame, byte/chan
kPluginBridgeRtMidiEvent, // uint/frame, byte/port, byte/size, byte[]/data
kPluginBridgeRtProcess
kPluginBridgeRtProcess,
kPluginBridgeRtQuit
};

// carla-plugin sends these during non-RT
@@ -221,6 +222,8 @@ const char* PluginBridgeRtOpcode2str(const PluginBridgeRtOpcode opcode) noexcept
return "kPluginBridgeRtMidiEvent";
case kPluginBridgeRtProcess:
return "kPluginBridgeRtProcess";
case kPluginBridgeRtQuit:
return "kPluginBridgeRtQuit";
}

carla_stderr("CarlaBackend::PluginBridgeRtOpcode2str(%i) - invalid opcode", opcode);


Loading…
Cancel
Save