Fix: Remove MSG_NOSIGNAL from HelperIPC.cpp, fix include paths for macOS
Browse files123456789101112131415161718198 unmodified lines282930313233343536373839404142434445464748495017 unmodified lines686970717273747576777879802 unmodified lines83848586878889907 unmodified lines98991001011021031041051061071081091102 unmodified lines113114115116117118119#include "HelperIPC.h"#include "HelperPluginHost.h"#include "../Shared/IPCProtocol.h"#include <sys/socket.h>#include <sys/un.h>#include <unistd.h>#include <poll.h>// Using nlohmann json (shared with parent)#include "json.hpp"using json = nlohmann::json;HelperIPC::HelperIPC(int parentPid, HelperPluginHost& host): parentPid(parentPid), host(host){}HelperIPC::~HelperIPC()8 unmodified linessocketFd = socket(AF_UNIX, SOCK_STREAM, 0);if (socketFd < 0) return false;struct sockaddr_un addr;memset(&addr, 0, sizeof(addr));addr.sun_family = AF_UNIX;strncpy(addr.sun_path, socketPath.c_str(), sizeof(addr.sun_path) - 1);// Try to connect (parent should have the socket listening already)int retries = 50; // 5 seconds totalwhile (retries-- > 0){if (::connect(socketFd, (struct sockaddr*)&addr, sizeof(addr)) == 0){// Connected — start listeningrunning.store(true);listenThread = std::thread([this]() { listenLoop(); });return true;}usleep(100000); // 100ms}close(socketFd);17 unmodified linesvoid HelperIPC::sendReady(){json msg = {{"notify", "ready"}};sendMessage(msg.dump());}void HelperIPC::sendParamChanged(int index, float value){json msg = {{"notify", "param_changed"}, {"index", index}, {"value", value}};sendMessage(msg.dump());}void HelperIPC::sendMessage(const juce::String& jsonStr)2 unmodified linesauto data = jsonStr + "\n";auto bytes = data.toRawUTF8();auto len = data.getNumBytesAsUTF8();::send(socketFd, bytes, len, MSG_NOSIGNAL);}void HelperIPC::listenLoop()7 unmodified linespfd.fd = socketFd;pfd.events = POLLIN;int ret = poll(&pfd, 1, 200); // 200ms timeoutif (ret <= 0) continue;ssize_t n = recv(socketFd, chunk, sizeof(chunk) - 1, 0);if (n <= 0){// Parent disconnected or errorDBG("HelperIPC: Parent disconnected");juce::JUCEApplication::getInstance()->systemRequestedQuit();return;2 unmodified lineschunk[n] = '\0';buffer += chunk;// Process complete messages (newline-delimited)size_t pos;while ((pos = buffer.find('\n')) != std::string::npos){12345678910111213141516171819208 unmodified lines2930313233343536373839404142434445464748495051525317 unmodified lines717273747576777879808182832 unmodified lines86878889909192937 unmodified lines1011021031041051061071081091101111122 unmodified lines115116117118119120#include "HelperIPC.h"#include "HelperPluginHost.h"#include "IPCProtocol.h"#include <sys/socket.h>#include <sys/un.h>#include <unistd.h>#include <poll.h>#include <signal.h>#include "json.hpp"using json = nlohmann::json;HelperIPC::HelperIPC(int parentPid, HelperPluginHost& host): parentPid(parentPid), host(host){signal(SIGPIPE, SIG_IGN);}HelperIPC::~HelperIPC()8 unmodified linessocketFd = socket(AF_UNIX, SOCK_STREAM, 0);if (socketFd < 0) return false;// Set SO_NOSIGPIPE (macOS)int nosigpipe = 1;setsockopt(socketFd, SOL_SOCKET, SO_NOSIGPIPE, &nosigpipe, sizeof(nosigpipe));struct sockaddr_un addr;memset(&addr, 0, sizeof(addr));addr.sun_family = AF_UNIX;strncpy(addr.sun_path, socketPath.c_str(), sizeof(addr.sun_path) - 1);int retries = 50;while (retries-- > 0){if (::connect(socketFd, (struct sockaddr*)&addr, sizeof(addr)) == 0){running.store(true);listenThread = std::thread([this]() { listenLoop(); });return true;}usleep(100000);}close(socketFd);17 unmodified linesvoid HelperIPC::sendReady(){json msg = {{"notify", "ready"}};sendMessage(juce::String(msg.dump()));}void HelperIPC::sendParamChanged(int index, float value){json msg = {{"notify", "param_changed"}, {"index", index}, {"value", value}};sendMessage(juce::String(msg.dump()));}void HelperIPC::sendMessage(const juce::String& jsonStr)2 unmodified linesauto data = jsonStr + "\n";auto bytes = data.toRawUTF8();auto len = (size_t)data.getNumBytesAsUTF8();::send(socketFd, bytes, len, 0);}void HelperIPC::listenLoop()7 unmodified linespfd.fd = socketFd;pfd.events = POLLIN;int ret = poll(&pfd, 1, 200);if (ret <= 0) continue;ssize_t n = recv(socketFd, chunk, sizeof(chunk) - 1, 0);if (n <= 0){DBG("HelperIPC: Parent disconnected");juce::JUCEApplication::getInstance()->systemRequestedQuit();return;2 unmodified lineschunk[n] = '\0';buffer += chunk;size_t pos;while ((pos = buffer.find('\n')) != std::string::npos){
Source/Helper/HelperIPC.cpp+14-13