A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/Haivision/srt/commit/790b7831fb7ec4851111e38ce601e4a13548847c below:

[core] Small refax of CUDTUnited::channelSettingsMatch(..) · Haivision/srt@790b783 · GitHub

@@ -1816,71 +1816,69 @@ int srt::CUDTUnited::groupConnect(CUDTGroup* pg, SRT_SOCKGROUPCONFIG* targets, i

1816 1816 1817 1817

int srt::CUDTUnited::connectIn(CUDTSocket* s, const sockaddr_any& target_addr, int32_t forced_isn)

1818 1818

{

1819 -

ScopedLock cg(s->m_ControlLock);

1820 -

// a socket can "connect" only if it is in the following states:

1821 -

// - OPENED: assume the socket binding parameters are configured

1822 -

// - INIT: configure binding parameters here

1823 -

// - any other (meaning, already connected): report error

1824 - 1825 -

if (s->m_Status == SRTS_INIT)

1826 -

{

1827 -

if (s->core().m_config.bRendezvous)

1828 -

throw CUDTException(MJ_NOTSUP, MN_ISRENDUNBOUND, 0);

1829 - 1830 -

// If bind() was done first on this socket, then the

1831 -

// socket will not perform this step. This actually does the

1832 -

// same thing as bind() does, just with empty address so that

1833 -

// the binding parameters are autoselected.

1834 - 1835 -

s->core().open();

1836 -

sockaddr_any autoselect_sa (target_addr.family());

1837 -

// This will create such a sockaddr_any that

1838 -

// will return true from empty().

1839 -

updateMux(s, autoselect_sa); // <<---- updateMux

1840 -

// -> C(Snd|Rcv)Queue::init

1841 -

// -> pthread_create(...C(Snd|Rcv)Queue::worker...)

1842 -

s->m_Status = SRTS_OPENED;

1843 -

}

1844 -

else

1845 -

{

1846 -

if (s->m_Status != SRTS_OPENED)

1847 -

throw CUDTException(MJ_NOTSUP, MN_ISCONNECTED, 0);

1819 +

ScopedLock cg(s->m_ControlLock);

1820 +

// a socket can "connect" only if it is in the following states:

1821 +

// - OPENED: assume the socket binding parameters are configured

1822 +

// - INIT: configure binding parameters here

1823 +

// - any other (meaning, already connected): report error

1848 1824 1849 -

// status = SRTS_OPENED, so family should be known already.

1850 -

if (target_addr.family() != s->m_SelfAddr.family())

1851 -

{

1852 -

LOGP(cnlog.Error, "srt_connect: socket is bound to a different family than target address");

1853 -

throw CUDTException(MJ_NOTSUP, MN_INVAL, 0);

1854 -

}

1855 -

}

1825 +

if (s->m_Status == SRTS_INIT)

1826 +

{

1827 +

if (s->core().m_config.bRendezvous)

1828 +

throw CUDTException(MJ_NOTSUP, MN_ISRENDUNBOUND, 0);

1829 + 1830 +

// If bind() was done first on this socket, then the

1831 +

// socket will not perform this step. This actually does the

1832 +

// same thing as bind() does, just with empty address so that

1833 +

// the binding parameters are autoselected.

1834 + 1835 +

s->core().open();

1836 +

sockaddr_any autoselect_sa (target_addr.family());

1837 +

// This will create such a sockaddr_any that

1838 +

// will return true from empty().

1839 +

updateMux(s, autoselect_sa); // <<---- updateMux

1840 +

// -> C(Snd|Rcv)Queue::init

1841 +

// -> pthread_create(...C(Snd|Rcv)Queue::worker...)

1842 +

s->m_Status = SRTS_OPENED;

1843 +

}

1844 +

else

1845 +

{

1846 +

if (s->m_Status != SRTS_OPENED)

1847 +

throw CUDTException(MJ_NOTSUP, MN_ISCONNECTED, 0);

1856 1848 1849 +

// status = SRTS_OPENED, so family should be known already.

1850 +

if (target_addr.family() != s->m_SelfAddr.family())

1851 +

{

1852 +

LOGP(cnlog.Error, "srt_connect: socket is bound to a different family than target address");

1853 +

throw CUDTException(MJ_NOTSUP, MN_INVAL, 0);

1854 +

}

1855 +

}

1857 1856 1858 -

// connect_complete() may be called before connect() returns.

1859 -

// So we need to update the status before connect() is called,

1860 -

// otherwise the status may be overwritten with wrong value

1861 -

// (CONNECTED vs. CONNECTING).

1862 -

s->m_Status = SRTS_CONNECTING;

1863 1857 1864 -

/*

1865 -

* In blocking mode, connect can block for up to 30 seconds for

1866 -

* rendez-vous mode. Holding the s->m_ControlLock prevent close

1867 -

* from cancelling the connect

1868 -

*/

1869 -

try

1870 -

{

1871 -

// record peer address

1872 -

s->m_PeerAddr = target_addr;

1873 -

s->core().startConnect(target_addr, forced_isn);

1874 -

}

1875 -

catch (CUDTException& e) // Interceptor, just to change the state.

1876 -

{

1877 -

s->m_Status = SRTS_OPENED;

1878 -

throw e;

1879 -

}

1858 +

// connect_complete() may be called before connect() returns.

1859 +

// So we need to update the status before connect() is called,

1860 +

// otherwise the status may be overwritten with wrong value

1861 +

// (CONNECTED vs. CONNECTING).

1862 +

s->m_Status = SRTS_CONNECTING;

1880 1863 1881 -

// ScopedLock destructor will delete cg and unlock s->m_ControlLock

1864 +

/*

1865 +

* In blocking mode, connect can block for up to 30 seconds for

1866 +

* rendez-vous mode. Holding the s->m_ControlLock prevent close

1867 +

* from cancelling the connect

1868 +

*/

1869 +

try

1870 +

{

1871 +

// record peer address

1872 +

s->m_PeerAddr = target_addr;

1873 +

s->core().startConnect(target_addr, forced_isn);

1874 +

}

1875 +

catch (CUDTException& e) // Interceptor, just to change the state.

1876 +

{

1877 +

s->m_Status = SRTS_OPENED;

1878 +

throw e;

1879 +

}

1882 1880 1883 -

return 0;

1881 +

return 0;

1884 1882

}

1885 1883 1886 1884

@@ -2857,9 +2855,9 @@ uint16_t srt::CUDTUnited::installMuxer(CUDTSocket* w_s, CMultiplexer& fw_sm)

2857 2855

return sa.hport();

2858 2856

}

2859 2857 2860 -

bool srt::CUDTUnited::channelSettingsMatch(const CMultiplexer& m, const CUDTSocket* s)

2858 +

bool srt::CUDTUnited::channelSettingsMatch(const CSrtMuxerConfig& cfgMuxer, const CSrtConfig& cfgSocket)

2861 2859

{

2862 -

return m.m_mcfg.bReuseAddr && m.m_mcfg == s->core().m_config;

2860 +

return cfgMuxer.bReuseAddr && cfgMuxer == cfgSocket;

2863 2861

}

2864 2862 2865 2863

void srt::CUDTUnited::updateMux(CUDTSocket* s, const sockaddr_any& addr, const UDPSOCKET* udpsock /*[[nullable]]*/)

@@ -2876,6 +2874,7 @@ void srt::CUDTUnited::updateMux(CUDTSocket* s, const sockaddr_any& addr, const U

2876 2874

// If not, we need to see if there exist already a multiplexer bound

2877 2875

// to the same endpoint.

2878 2876

const int port = addr.hport();

2877 +

const CSrtConfig& cfgSocket = s->core().m_config;

2879 2878 2880 2879

bool reuse_attempt = false;

2881 2880

for (map<int, CMultiplexer>::iterator i = m_mMultiplexer.begin();

@@ -2912,14 +2911,14 @@ void srt::CUDTUnited::updateMux(CUDTSocket* s, const sockaddr_any& addr, const U

2912 2911 2913 2912

// Still, for ANY you need either the same family, or open

2914 2913

// for families.

2915 -

if (m.m_mcfg.iIpV6Only != -1 && m.m_mcfg.iIpV6Only != s->core().m_config.iIpV6Only)

2914 +

if (m.m_mcfg.iIpV6Only != -1 && m.m_mcfg.iIpV6Only != cfgSocket.iIpV6Only)

2916 2915

{

2917 2916

LOGC(smlog.Error, log << "bind: Address: " << addr.str()

2918 2917

<< " conflicts with existing IPv6 wildcard binding: " << sa.str());

2919 2918

throw CUDTException(MJ_NOTSUP, MN_BUSYPORT, 0);

2920 2919

}

2921 2920 2922 -

if ((m.m_mcfg.iIpV6Only == 0 || s->core().m_config.iIpV6Only == 0) && m.m_iIPversion != addr.family())

2921 +

if ((m.m_mcfg.iIpV6Only == 0 || cfgSocket.iIpV6Only == 0) && m.m_iIPversion != addr.family())

2923 2922

{

2924 2923

LOGC(smlog.Error, log << "bind: Address: " << addr.str()

2925 2924

<< " conflicts with IPv6 wildcard binding: " << sa.str()

@@ -2955,7 +2954,7 @@ void srt::CUDTUnited::updateMux(CUDTSocket* s, const sockaddr_any& addr, const U

2955 2954

if (reuse_attempt)

2956 2955

{

2957 2956

// - if the channel settings match, it can be reused

2958 -

if (channelSettingsMatch(m, s))

2957 +

if (channelSettingsMatch(m.m_mcfg, cfgSocket))

2959 2958

{

2960 2959

HLOGC(smlog.Debug, log << "bind: reusing multiplexer for port " << port);

2961 2960

// reuse the existing multiplexer


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4