Skip to content

Commit

Permalink
Updated and fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikołaj Małecki committed Sep 27, 2024
2 parents fc9482b + 7a4f5e2 commit 3376247
Show file tree
Hide file tree
Showing 27 changed files with 345 additions and 148 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cxx11-macos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: configure
run: |
mkdir _build && cd _build
cmake ../ -DENABLE_STDCXX_SYNC=ON -DENABLE_ENCRYPTION=OFF -DENABLE_UNITTESTS=ON -DENABLE_BONDING=ON -DUSE_CXX_STD=14
cmake ../ -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DENABLE_STDCXX_SYNC=ON -DENABLE_ENCRYPTION=OFF -DENABLE_UNITTESTS=ON -DENABLE_BONDING=ON -DUSE_CXX_STD=14
- name: build
run: cd _build && cmake --build ./
- name: test
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cxx11-ubuntu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: configure
run: |
mkdir _build && cd _build
cmake ../ -DENABLE_STDCXX_SYNC=ON -DENABLE_ENCRYPTION=ON -DENABLE_UNITTESTS=ON -DENABLE_BONDING=ON -DENABLE_TESTING=ON -DENABLE_EXAMPLES=ON -DENABLE_CODE_COVERAGE=ON
cmake ../ -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DENABLE_STDCXX_SYNC=ON -DENABLE_ENCRYPTION=ON -DENABLE_UNITTESTS=ON -DENABLE_BONDING=ON -DENABLE_TESTING=ON -DENABLE_EXAMPLES=ON -DENABLE_CODE_COVERAGE=ON
- name: build
run: cd _build && build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build .
- name: test
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/cxx11-win.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ jobs:
- name: configure
run: |
md _build && cd _build
cmake ../ -DENABLE_STDCXX_SYNC=ON -DENABLE_ENCRYPTION=OFF -DENABLE_UNITTESTS=ON -DENABLE_BONDING=ON
cmake ../ -DENABLE_STDCXX_SYNC=ON -DENABLE_ENCRYPTION=OFF -DENABLE_UNITTESTS=ON -DENABLE_BONDING=ON -DUSE_CXX_STD=c++11
- name: build
run: cd _build && cmake --build ./ --config Release
run: cd _build && cmake --build ./ --config Release --verbose
- name: test
run: cd _build && ctest -E "TestIPv6.v6_calls_v4|TestConnectionTimeout.BlockingLoop" --extra-verbose -C Release
57 changes: 57 additions & 0 deletions apps/apputil.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include "netinet_any.h"
#include "utilities.h"
#include "srt.h"

#if _WIN32

Expand Down Expand Up @@ -336,4 +337,60 @@ std::string OptionHelpItem(const OptionName& o);
const char* SRTClockTypeStr();
void PrintLibVersion();


namespace srt
{

struct OptionSetterProxy
{
SRTSOCKET s;
int result = -1;

OptionSetterProxy(SRTSOCKET ss): s(ss) {}

struct OptionProxy
{
OptionSetterProxy& parent;
SRT_SOCKOPT opt;

#define SPEC(type) \
OptionProxy& operator=(const type& val)\
{\
parent.result = srt_setsockflag(parent.s, opt, &val, sizeof val);\
return *this;\
}

SPEC(int32_t);
SPEC(int64_t);
SPEC(bool);
#undef SPEC

template<size_t N>
OptionProxy& operator=(const char (&val)[N])
{
parent.result = srt_setsockflag(parent.s, opt, val, N-1);
return *this;
}

OptionProxy& operator=(const std::string& val)
{
parent.result = srt_setsockflag(parent.s, opt, val.c_str(), val.size());
return *this;
}
};

OptionProxy operator[](SRT_SOCKOPT opt)
{
return OptionProxy {*this, opt};
}

operator int() { return result; }
};

inline OptionSetterProxy setopt(SRTSOCKET socket)
{
return OptionSetterProxy(socket);
}

}
#endif // INC_SRT_APPCOMMON_H
84 changes: 74 additions & 10 deletions configure-data.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,55 @@ proc preprocess {} {
}
}

proc GetCompilerCommand {} {
# Added also the Intel compiler names, just in case.
set compiler_map {
cc c++
gcc g++
icc icpc
icx icpx
}

proc SplitCompilerVersionSuffix {cmd} {
# If there's no version suffix, return just $cmd.
# Otherwise return a list with cmd cut and version suffix

set parts [split $cmd -]
if {[llength $parts] == 1} {
return $cmd
}

set last [lindex $parts end]
if {![regexp {[0-9]+.*} $last]} {
return $cmd
}

# Got the version
if {[llength $parts] == 2} {
set first [lindex $parts 0]
} else {
set first [join [lrange $parts 0 end-1] -]
}

return [list $first -$last]
}

# This uses 'compiler' in the form of the C compiler
# command line. For C++ it returns the C++ command line,
# which is normally the C compiler command with ++.
proc GetCompilerCmdName {compiler lang} {
lassign [SplitCompilerVersionSuffix $compiler] compiler suffix
if {$lang == "c++"} {
if { [dict exists $::compiler_map $compiler] } {
return [dict get $::compiler_map $compiler]$suffix
}

return ${compiler}++${suffix}
}

return $compiler${suffix}
}

proc GetCompilerCommand { {lang {}} } {
# Expect that the compiler was set through:
# --with-compiler-prefix
# --cmake-c[++]-compiler
Expand All @@ -204,21 +252,25 @@ proc GetCompilerCommand {} {

if { [info exists ::optval(--with-compiler-prefix)] } {
set prefix $::optval(--with-compiler-prefix)
return ${prefix}$compiler
return ${prefix}[GetCompilerCmdName $compiler $lang]
} else {
return $compiler
return [GetCompilerCmdName $compiler $lang]
}

if { [info exists ::optval(--cmake-c-compiler)] } {
return $::optval(--cmake-c-compiler)
if { $lang != "c++" } {
if { [info exists ::optval(--cmake-c-compiler)] } {
return $::optval(--cmake-c-compiler)
}
}

if { [info exists ::optval(--cmake-c++-compiler)] } {
return $::optval(--cmake-c++-compiler)
}
if { $lang != "c" } {
if { [info exists ::optval(--cmake-c++-compiler)] } {
return $::optval(--cmake-c++-compiler)
}

if { [info exists ::optval(--cmake-cxx-compiler)] } {
return $::optval(--cmake-cxx-compiler)
if { [info exists ::optval(--cmake-cxx-compiler)] } {
return $::optval(--cmake-cxx-compiler)
}
}

puts "NOTE: Cannot obtain compiler, assuming toolchain file will do what's necessary"
Expand Down Expand Up @@ -284,6 +336,18 @@ proc postprocess {} {
} else {
puts "CONFIGURE: default compiler used"
}

# Complete the variables before calling cmake, otherwise it might not work

if { [info exists ::optval(--with-compiler-type)] } {
if { ![info exists ::optval(--cmake-c-compiler)] } {
lappend ::cmakeopt "-DCMAKE_C_COMPILER=[GetCompilerCommand c]"
}

if { ![info exists ::optval(--cmake-c++-compiler)] } {
lappend ::cmakeopt "-DCMAKE_CXX_COMPILER=[GetCompilerCommand c++]"
}
}
}

if { $::srt_name != "" } {
Expand Down
4 changes: 4 additions & 0 deletions srtcore/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,11 @@ class CUDTUnited
bool acquire(CUDTUnited& glob, CUDTSocket* s)
{
if (s == NULL)
{
socket = NULL;
return false;
}

const bool caught = glob.acquireSocket(s);
socket = caught ? s : NULL;
return caught;
Expand Down
48 changes: 48 additions & 0 deletions srtcore/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,54 @@ bool SrtParseConfig(const string& s, SrtConfig& w_config)

return true;
}

std::string FormatLossArray(const std::vector< std::pair<int32_t, int32_t> >& lra)
{
std::ostringstream os;

os << "[ ";
for (std::vector< std::pair<int32_t, int32_t> >::const_iterator i = lra.begin(); i != lra.end(); ++i)
{
int len = CSeqNo::seqoff(i->first, i->second);
os << "%" << i->first;
if (len > 1)
os << "+" << len;
os << " ";
}

os << "]";
return os.str();
}

ostream& PrintEpollEvent(ostream& os, int events, int et_events)
{
static pair<int, const char*> const namemap [] = {
make_pair(SRT_EPOLL_IN, "R"),
make_pair(SRT_EPOLL_OUT, "W"),
make_pair(SRT_EPOLL_ERR, "E"),
make_pair(SRT_EPOLL_UPDATE, "U")
};
bool any = false;

const int N = (int)Size(namemap);

for (int i = 0; i < N; ++i)
{
if (events & namemap[i].first)
{
os << "[";
if (et_events & namemap[i].first)
os << "^";
os << namemap[i].second << "]";
any = true;
}
}

if (!any)
os << "[]";

return os;
}
} // namespace srt

namespace srt_logging
Expand Down
19 changes: 2 additions & 17 deletions srtcore/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -1435,23 +1435,8 @@ inline bool checkMappedIPv4(const sockaddr_in6& sa)
return checkMappedIPv4(addr);
}

inline std::string FormatLossArray(const std::vector< std::pair<int32_t, int32_t> >& lra)
{
std::ostringstream os;

os << "[ ";
for (std::vector< std::pair<int32_t, int32_t> >::const_iterator i = lra.begin(); i != lra.end(); ++i)
{
int len = CSeqNo::seqoff(i->first, i->second);
os << "%" << i->first;
if (len > 1)
os << "+" << len;
os << " ";
}

os << "]";
return os.str();
}
std::string FormatLossArray(const std::vector< std::pair<int32_t, int32_t> >& lra);
std::ostream& PrintEpollEvent(std::ostream& os, int events, int et_events = 0);

} // namespace srt

Expand Down
2 changes: 1 addition & 1 deletion srtcore/congctl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ class FileCC : public SrtCongestionControlBase
{
m_dPktSndPeriod = m_dCWndSize / (m_parent->SRTT() + m_iRCInterval);
HLOGC(cclog.Debug, log << "FileCC: CHKTIMER, SLOWSTART:OFF, sndperiod=" << m_dPktSndPeriod << "us AS wndsize/(RTT+RCIV) (wndsize="
<< setprecision(6) << m_dCWndSize << " RTT=" << m_parent->SRTT() << " RCIV=" << m_iRCInterval << ")");
<< m_dCWndSize << " RTT=" << m_parent->SRTT() << " RCIV=" << m_iRCInterval << ")");
}
}
else
Expand Down
31 changes: 0 additions & 31 deletions srtcore/epoll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,6 @@ modified by
using namespace std;
using namespace srt::sync;

#if ENABLE_HEAVY_LOGGING
namespace srt {
static ostream& PrintEpollEvent(ostream& os, int events, int et_events = 0);
}
#endif

namespace srt_logging
{
extern Logger eilog, ealog;
Expand Down Expand Up @@ -956,31 +950,6 @@ int srt::CEPoll::update_events(const SRTSOCKET& uid, std::set<int>& eids, const
namespace srt
{

static ostream& PrintEpollEvent(ostream& os, int events, int et_events)
{
static pair<int, const char*> const namemap [] = {
make_pair(SRT_EPOLL_IN, "R"),
make_pair(SRT_EPOLL_OUT, "W"),
make_pair(SRT_EPOLL_ERR, "E"),
make_pair(SRT_EPOLL_UPDATE, "U")
};

const int N = (int)Size(namemap);

for (int i = 0; i < N; ++i)
{
if (events & namemap[i].first)
{
os << "[";
if (et_events & namemap[i].first)
os << "^";
os << namemap[i].second << "]";
}
}

return os;
}

string DisplayEpollResults(const std::map<SRTSOCKET, int>& sockset)
{
typedef map<SRTSOCKET, int> fmap_t;
Expand Down
2 changes: 1 addition & 1 deletion srtcore/handshake.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ std::string srt::SrtFlagString(int32_t flags)
#define LEN(arr) (sizeof (arr)/(sizeof ((arr)[0])))

std::string output;
static std::string namera[] = { "TSBPD-snd", "TSBPD-rcv", "haicrypt", "TLPktDrop", "NAKReport", "ReXmitFlag", "StreamAPI" };
static std::string namera[] = { "TSBPD-snd", "TSBPD-rcv", "haicrypt", "TLPktDrop", "NAKReport", "ReXmitFlag", "StreamAPI", "FilterCapable" };

size_t i = 0;
for (; i < LEN(namera); ++i)
Expand Down
2 changes: 1 addition & 1 deletion srtcore/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void LogDispatcher::SendLogLine(const char* file, int line, const std::string& a
}
else if ( src_config->log_stream )
{
(*src_config->log_stream) << msg;
src_config->log_stream->write(msg.data(), msg.size());
src_config->log_stream->flush();
}
src_config->unlock();
Expand Down
Loading

0 comments on commit 3376247

Please sign in to comment.