diff --git a/srtcore/common.h b/srtcore/common.h index 5a53c05e6..c40d9028e 100644 --- a/srtcore/common.h +++ b/srtcore/common.h @@ -357,6 +357,14 @@ struct EventVariant // Note: UNDEFINED and ARRAY don't have assignment operator. // For ARRAY you'll use 'set' function. For UNDEFINED there's nothing. + // For events that pass no argument (e.g. TEV_SYNC). + EventVariant() + { + type = UNDEFINED; + u.array.ptr = NULL; + u.array.len = 0; + } + explicit EventVariant(const srt::CPacket* arg) { type = PACKET; diff --git a/srtcore/core.h b/srtcore/core.h index a4a9acaee..e548c2982 100644 --- a/srtcore/core.h +++ b/srtcore/core.h @@ -929,7 +929,7 @@ class CUDT return; m_pSndBuffer->setRateEstimator(rate); - updateCC(TEV_SYNC, EventVariant(0)); + updateCC(TEV_SYNC, EventVariant()); } diff --git a/srtcore/socketconfig.cpp b/srtcore/socketconfig.cpp index e3ad5cde2..fe2bc9b19 100644 --- a/srtcore/socketconfig.cpp +++ b/srtcore/socketconfig.cpp @@ -161,7 +161,7 @@ struct CSrtConfigSetter { static void set(CSrtConfig& co, const void* optval, int optlen) { - co.iUDPSndBufSize = std::max(co.iMSS, cast_optval(optval, optlen)); + co.iUDPSndBufSize = std::max(co.iMSS, cast_optval(optval, optlen)); } }; @@ -170,7 +170,7 @@ struct CSrtConfigSetter { static void set(CSrtConfig& co, const void* optval, int optlen) { - co.iUDPRcvBufSize = std::max(co.iMSS, cast_optval(optval, optlen)); + co.iUDPRcvBufSize = std::max(co.iMSS, cast_optval(optval, optlen)); } }; template<> diff --git a/srtcore/socketconfig.h b/srtcore/socketconfig.h index f44e3c24c..9abbc0e50 100644 --- a/srtcore/socketconfig.h +++ b/srtcore/socketconfig.h @@ -218,7 +218,7 @@ struct CSrtConfig: CSrtMuxerConfig static const size_t MAX_PFILTER_LENGTH = 64; static const size_t MAX_CONG_LENGTH = 16; - int iMSS; // Maximum Segment Size, in bytes + int32_t iMSS; // Maximum Segment Size, in bytes (int32_t: matches CHandShake::m_iMSS) size_t zExpPayloadSize; // Expected average payload size (user option) // Options diff --git a/srtcore/sync_posix.cpp b/srtcore/sync_posix.cpp index cfbd2ab6d..8c9328ede 100644 --- a/srtcore/sync_posix.cpp +++ b/srtcore/sync_posix.cpp @@ -9,6 +9,7 @@ */ #include "platform_sys.h" +#include #include #include #include @@ -394,22 +395,11 @@ srt::sync::CThread& srt::sync::CThread::operator=(CThread& other) { if (joinable()) { - // If the thread has already terminated, then - // pthread_join() returns immediately. - // But we have to check it has terminated before replacing it. + // Match std::thread semantics: assigning to a joinable thread + // terminates the program ([thread.thread.assign]). This error should + // not normally happen; the log line makes the abort diagnosable. LOGC(inlog.Error, log << "IPE: Assigning to a thread that is not terminated!"); - -#ifndef DEBUG -#if !defined(__ANDROID__) && !defined(__OHOS__) - // In case of production build the hanging thread should be terminated - // to avoid hang ups and align with C++11 implementation. - // There is no pthread_cancel on Android. See #1476. This error should not normally - // happen, but if it happen, then detaching the thread. - pthread_cancel(m_thread); -#endif // __ANDROID__ __OHOS__ -#else - join(); -#endif + std::terminate(); } // Move thread handler from other m_thread = other.m_thread;