From 85f581187316b302cc4999f91275a4f791fa42c3 Mon Sep 17 00:00:00 2001 From: Eli Mallon Date: Mon, 28 Feb 2022 14:25:21 +0100 Subject: [PATCH 1/7] CMakeLists: fixes for MacOS, parallel builds --- CMakeLists.txt | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a1bcf1ed8..a873d276d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,6 +68,11 @@ if (NOT DEBUG) endif() option(NOSHM "Disabled shared memory (falling back to shared temporary files)") + +if (APPLE) + set(NOSHM 1) +endif() + if (NOT NOSHM) add_definitions(-DSHM_ENABLED=1) else() @@ -298,6 +303,7 @@ add_library (mist lib/url.cpp lib/urireader.cpp ) + if (NOT APPLE) set (LIBRT -lrt) endif() @@ -306,7 +312,14 @@ target_link_libraries(mist ${LIBRT} ) if (NOT NOSSL) - target_link_libraries(mist mbedtls mbedx509 mbedcrypto srtp2) + find_library(MBEDTLS_LIB mbedtls) + find_library(MBEDX509_LIB mbedx509) + find_library(MBEDCRYPTO_LIB mbedcrypto) + find_library(SRTP2_LIB srtp2) + target_link_libraries(mist ${MBEDTLS_LIB} ${MBEDX509_LIB} ${MBEDCRYPTO_LIB} ${SRTP2_LIB}) + find_path(MBEDTLS_HEADER_DIR "mbedtls/net.h") + find_path(SRTP2_HEADER_DIR "srtp2/srtp.h") + include_directories(${MBEDTLS_HEADER_DIR} ${SRTP2_HEADER_DIR}) endif() install( FILES ${libHeaders} @@ -320,7 +333,9 @@ install( if(SRT_LIB) add_library(mist_srt lib/socket_srt.h lib/socket_srt.cpp) - target_link_libraries(mist_srt mist srt) + target_link_libraries(mist_srt mist ${SRT_LIB}) + find_path(SRT_HEADER_DIR "srt/srt.h") + include_directories(${SRT_HEADER_DIR}) install( TARGETS mist_srt DESTINATION lib @@ -534,7 +549,7 @@ macro(makeOutput outputName format) target_link_libraries(MistOut${outputName} rist cjson) endif() target_link_libraries(MistOut${outputName} mist ) - install( + install( TARGETS MistOut${outputName} DESTINATION bin ) @@ -593,6 +608,10 @@ add_executable(MistProcFFMPEG src/io.cpp ) target_link_libraries(MistProcFFMPEG mist) +install( + TARGETS MistProcFFMPEG + DESTINATION bin +) add_executable(MistProcMKVExec ${BINARY_DIR}/mist/.headers @@ -605,6 +624,10 @@ add_executable(MistProcMKVExec src/io.cpp ) target_link_libraries(MistProcMKVExec mist) +install( + TARGETS MistProcMKVExec + DESTINATION bin +) add_executable(MistProcLivepeer ${BINARY_DIR}/mist/.headers @@ -616,6 +639,10 @@ add_executable(MistProcLivepeer src/io.cpp ) target_link_libraries(MistProcLivepeer mist) +install( + TARGETS MistProcLivepeer + DESTINATION bin +) if (NOT NOSSL) makeOutput(HTTPS https)#LTS @@ -875,6 +902,8 @@ install( TARGETS MistController DESTINATION bin ) +# Needed to make parallel builds work well +add_dependencies(MistOutHTTP MistController) ######################################## # Make Clean # From c52e9c648b732528dd9eec5d8ec8d82e1e2ecb77 Mon Sep 17 00:00:00 2001 From: Eli Mallon Date: Sun, 9 Jan 2022 18:36:45 -0800 Subject: [PATCH 2/7] fixes for compilation on macos --- lib/json.cpp | 16 ++++++++++++++++ lib/json.h | 6 ++++++ 2 files changed, 22 insertions(+) diff --git a/lib/json.cpp b/lib/json.cpp index cfbfc9df1..d6ef690c0 100644 --- a/lib/json.cpp +++ b/lib/json.cpp @@ -479,6 +479,15 @@ JSON::Value::Value(uint64_t val){ myType = INTEGER; intVal = val; } + +#if defined(__APPLE__) +/// Sets this JSON::Value to the given integer. +JSON::Value::Value(unsigned long val){ + myType = INTEGER; + intVal = val; +} +#endif + /// Sets this JSON::Value to the given integer. JSON::Value::Value(int32_t val){ myType = INTEGER; @@ -684,6 +693,13 @@ JSON::Value &JSON::Value::operator=(const uint64_t &rhs){ return ((*this) = (int64_t)rhs); } +#if defined(__APPLE__) +/// Sets this JSON::Value to the given integer. +JSON::Value &JSON::Value::operator=(const unsigned long &rhs){ + return ((*this) = (int64_t)rhs); +} +#endif + /// Sets this JSON::Value to the given double. JSON::Value &JSON::Value::operator=(const double &rhs){ null(); diff --git a/lib/json.h b/lib/json.h index 20799b9bc..d906cd721 100644 --- a/lib/json.h +++ b/lib/json.h @@ -46,6 +46,9 @@ namespace JSON{ Value(int64_t val); Value(uint32_t val); Value(uint64_t val); +#if defined(__APPLE__) + Value(unsigned long val); +#endif Value(double val); Value(bool val); // comparison operators @@ -62,6 +65,9 @@ namespace JSON{ Value &operator=(const int64_t &rhs); Value &operator=(const int32_t &rhs); Value &operator=(const uint64_t &rhs); +#if defined(__APPLE__) + Value &operator=(const unsigned long &rhs); +#endif Value &operator=(const uint32_t &rhs); Value &operator=(const double &rhs); Value &operator=(const bool &rhs); From 4d13f82888146bc11110c773be39053861e9a8d9 Mon Sep 17 00:00:00 2001 From: Ivan Tivonenko Date: Thu, 13 Jan 2022 10:12:36 +0200 Subject: [PATCH 3/7] show process name on all platforms --- lib/defines.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/defines.h b/lib/defines.h index 7f09b00cd..e152522ff 100644 --- a/lib/defines.h +++ b/lib/defines.h @@ -66,7 +66,7 @@ static const char *DBG_LVL_LIST[] ={"NONE", "FAIL", "ERROR", "WARN", "IN #if DEBUG >= DLVL_DEVEL #define DEBUG_MSG(lvl, msg, ...) \ if (Util::printDebugLevel >= lvl){\ - fprintf(stderr, "%s|MistProcess|%d|%s:%d|%s|" msg "\n", DBG_LVL_LIST[lvl], getpid(), __FILE__, \ + fprintf(stderr, "%s|%s|%d|%s:%d|%s|" msg "\n", getprogname(), DBG_LVL_LIST[lvl], getpid(), __FILE__, \ __LINE__, Util::streamName, ##__VA_ARGS__); \ } #else From d98c6cc8a0b4fff9476f3fba267de66949757b17 Mon Sep 17 00:00:00 2001 From: Ivan Tivonenko Date: Thu, 13 Jan 2022 10:14:36 +0200 Subject: [PATCH 4/7] fix sharedfile unlink --- lib/shared_memory.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/shared_memory.cpp b/lib/shared_memory.cpp index fc1e838c4..48b88a93a 100644 --- a/lib/shared_memory.cpp +++ b/lib/shared_memory.cpp @@ -592,7 +592,11 @@ namespace IPC{ unmap(); if (handle > 0){ ::close(handle); - if (master && name != ""){unlink(name.c_str());} + if (master && name != ""){ + std::string remove(Util::getTmpFolder() + name); + DONTEVEN_MSG("Unlinking %s", remove.c_str()); + unlink(remove.c_str()); + } handle = 0; } } From cd63c3a630be4526724b09297cc47886e4fb9ef2 Mon Sep 17 00:00:00 2001 From: Eli Mallon Date: Tue, 1 Feb 2022 22:05:40 -0800 Subject: [PATCH 5/7] controller: add MIST_NO_PRETTY_LOGGING --- src/controller/controller.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/controller/controller.cpp b/src/controller/controller.cpp index 8350b14d2..b4fdc95f6 100644 --- a/src/controller/controller.cpp +++ b/src/controller/controller.cpp @@ -265,7 +265,11 @@ int main_loop(int argc, char **argv){ msghandler.detach(); // Attempt to open and redirect log messages to named pipe int outFD = -1; - if ((outFD = open(logPipe.c_str(), O_WRONLY)) == -1){ + if (getenv("MIST_NO_PRETTY_LOGGING")) { + WARN_MSG( + "MIST_NO_PRETTY_LOGGING is active, printing lots of pipes"); + } + else if ((outFD = open(logPipe.c_str(), O_WRONLY)) == -1){ ERROR_MSG( "Could not open log message pipe %s for writing! %s; falling back to standard error", logPipe.c_str(), strerror(errno)); From 5c511e04682bd7a46ccaed7bcf450045bd9e2bb4 Mon Sep 17 00:00:00 2001 From: Eli Mallon Date: Mon, 28 Feb 2022 14:29:16 +0100 Subject: [PATCH 6/7] controller: 15 --> 30 max args for connectors --- src/controller/controller_connectors.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controller/controller_connectors.cpp b/src/controller/controller_connectors.cpp index 52d9e9533..390f77aa1 100644 --- a/src/controller/controller_connectors.cpp +++ b/src/controller/controller_connectors.cpp @@ -160,7 +160,7 @@ namespace Controller{ // used for building args int err = fileno(stderr); - char *argarr[15]; // approx max # of args (with a wide margin) + char *argarr[30]; // approx max # of args (with a wide margin) int i; std::string tmp; From 7f827ca6d788f0d58189b8511eab6160271e26d2 Mon Sep 17 00:00:00 2001 From: Eli Mallon Date: Thu, 3 Mar 2022 12:37:54 +0100 Subject: [PATCH 7/7] fixes for log parsing on mac --- lib/defines.h | 2 +- src/controller/controller.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/defines.h b/lib/defines.h index e152522ff..ceeee012f 100644 --- a/lib/defines.h +++ b/lib/defines.h @@ -66,7 +66,7 @@ static const char *DBG_LVL_LIST[] ={"NONE", "FAIL", "ERROR", "WARN", "IN #if DEBUG >= DLVL_DEVEL #define DEBUG_MSG(lvl, msg, ...) \ if (Util::printDebugLevel >= lvl){\ - fprintf(stderr, "%s|%s|%d|%s:%d|%s|" msg "\n", getprogname(), DBG_LVL_LIST[lvl], getpid(), __FILE__, \ + fprintf(stderr, "%s|%s|%d|%s:%d|%s|" msg "\n", DBG_LVL_LIST[lvl], getprogname(), getpid(), __FILE__, \ __LINE__, Util::streamName, ##__VA_ARGS__); \ } #else diff --git a/src/controller/controller.cpp b/src/controller/controller.cpp index b4fdc95f6..4341efc54 100644 --- a/src/controller/controller.cpp +++ b/src/controller/controller.cpp @@ -235,6 +235,9 @@ int main_loop(int argc, char **argv){ // reload config from config file Controller::Storage = JSON::fromFile(Controller::conf.getString("configFile")); + // start push checking thread + tthread::thread pushThread(Controller::pushCheckLoop, 0); + {// spawn thread that reads stderr of process std::string logPipe = Util::getTmpFolder() + "MstLog"; if (mkfifo(logPipe.c_str(), S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH) != 0){ @@ -569,8 +572,6 @@ int main_loop(int argc, char **argv){ tthread::thread UDPAPIThread(Controller::handleUDPAPI, 0); // start monitoring thread /*LTS*/ tthread::thread uplinkThread(Controller::uplinkConnection, 0); /*LTS*/ - // start push checking thread - tthread::thread pushThread(Controller::pushCheckLoop, 0); #ifdef UPDATER // start updater thread tthread::thread updaterThread(Controller::updateThread, 0);