Fix interleaved group host initialization

In case two yabridge instances start at the same time and both try to
launch a group host for the same group and the second plugin connects to
the first group host, then we should of course be using that process'es
PID to check if the group host is still running.
This commit is contained in:
Robbert van der Helm
2020-05-22 22:50:29 +02:00
parent bea924c0e1
commit 6da1909d4b
+7 -2
View File
@@ -720,6 +720,8 @@ void PluginBridge::launch_vst_host() {
// TODO: Replace this polling with inotify when encapsulating
// the different host launch behaviors
while (vst_host.running()) {
std::this_thread::sleep_for(20ms);
try {
// This is the exact same connection sequence as above
boost::asio::local::stream_protocol::socket group_socket(
@@ -729,11 +731,14 @@ void PluginBridge::launch_vst_host() {
write_object(group_socket,
GroupRequest{plugin_path.string(),
socket_path.string()});
read_object<GroupResponse>(group_socket);
const auto response =
read_object<GroupResponse>(group_socket);
// If two group processes started at the same time, than the
// first one will be the one to respond to the host request
vst_host_pid = response.pid;
return;
} catch (const boost::system::system_error&) {
std::this_thread::sleep_for(20ms);
}
}
});