MCPcopy Create free account
hub / github.com/Haivision/srt / newSocket

Method newSocket

srtcore/api.cpp:559–611  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

557}
558
559SRTSOCKET srt::CUDTUnited::newSocket(CUDTSocket** pps)
560{
561 // XXX consider using some replacement of std::unique_ptr
562 // so that exceptions will clean up the object without the
563 // need for a dedicated code.
564 CUDTSocket* ns = NULL;
565
566 try
567 {
568 ns = new CUDTSocket;
569 }
570 catch (...)
571 {
572 delete ns;
573 throw CUDTException(MJ_SYSTEMRES, MN_MEMORY, 0);
574 }
575
576 try
577 {
578 ns->m_SocketID = generateSocketID();
579 }
580 catch (...)
581 {
582 delete ns;
583 throw;
584 }
585 ns->m_Status = SRTS_INIT;
586 ns->m_ListenSocket = 0;
587 ns->core().m_SocketID = ns->m_SocketID;
588 ns->core().m_pCache = m_pCache;
589
590 try
591 {
592 HLOGC(smlog.Debug, log << CONID(ns->m_SocketID) << "newSocket: mapping socket " << ns->m_SocketID);
593
594 // protect the m_Sockets structure.
595 ExclusiveLock cs(m_GlobControlLock);
596 m_Sockets[ns->m_SocketID] = ns;
597 }
598 catch (...)
599 {
600 // failure and rollback
601 delete ns;
602 ns = NULL;
603 throw CUDTException(MJ_SYSTEMRES, MN_MEMORY, 0);
604 }
605
606 startGarbageCollector();
607 if (pps)
608 *pps = ns;
609
610 return ns->m_SocketID;
611}
612
613// XXX NOTE: TSan reports here false positive against the call
614// to CRcvQueue::removeListener. This here will apply shared

Callers 2

socketMethod · 0.80
TESTFunction · 0.80

Calls 1

CUDTExceptionClass · 0.70

Tested by 1

TESTFunction · 0.64