From ed18c73409783448be05b37b9b7240d779086687 Mon Sep 17 00:00:00 2001 From: falkTX Date: Thu, 28 Apr 2016 12:52:46 +0100 Subject: [PATCH] Allow to set pipe size --- source/utils/CarlaPipeUtils.cpp | 21 ++++++++++++++++++--- source/utils/CarlaPipeUtils.hpp | 2 +- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/source/utils/CarlaPipeUtils.cpp b/source/utils/CarlaPipeUtils.cpp index 9d1881a9f..553d2a6c1 100644 --- a/source/utils/CarlaPipeUtils.cpp +++ b/source/utils/CarlaPipeUtils.cpp @@ -1133,7 +1133,10 @@ uintptr_t CarlaPipeServer::getPID() const noexcept // ----------------------------------------------------------------------- -bool CarlaPipeServer::startPipeServer(const char* const filename, const char* const arg1, const char* const arg2) noexcept +bool CarlaPipeServer::startPipeServer(const char* const filename, + const char* const arg1, + const char* const arg2, + const int size) noexcept { CARLA_SAFE_ASSERT_RETURN(pData->pipeRecv == INVALID_PIPE_VALUE, false); CARLA_SAFE_ASSERT_RETURN(pData->pipeSend == INVALID_PIPE_VALUE, false); @@ -1326,10 +1329,22 @@ bool CarlaPipeServer::startPipeServer(const char* const filename, const char* co pipeRecvServer = pipeSendServer = INVALID_PIPE_VALUE; #ifndef CARLA_OS_WIN + int ret; + //---------------------------------------------------------------- - // set non-block reading + // set size - int ret = 0; + if (size > 4096) + { + try { + ::fcntl(pipeRecvClient, F_SETPIPE_SZ, size); + } catch (...) { + // non-fatal + } + } + + //---------------------------------------------------------------- + // set non-block reading try { ret = ::fcntl(pipeRecvClient, F_SETFL, ::fcntl(pipeRecvClient, F_GETFL) | O_NONBLOCK); diff --git a/source/utils/CarlaPipeUtils.hpp b/source/utils/CarlaPipeUtils.hpp index d74630406..6fed61dca 100644 --- a/source/utils/CarlaPipeUtils.hpp +++ b/source/utils/CarlaPipeUtils.hpp @@ -259,7 +259,7 @@ public: * Start the pipe server using @a filename with 2 arguments. * @see fail() */ - bool startPipeServer(const char* const filename, const char* const arg1, const char* const arg2) noexcept; + bool startPipeServer(const char* const filename, const char* const arg1, const char* const arg2, const int size = -1) noexcept; /*! * Stop the pipe server.