[[using locked(m_GlobControlLock)]]
| 2961 | |
| 2962 | // [[using locked(m_GlobControlLock)]] |
| 2963 | void srt::CUDTUnited::removeSocket(const SRTSOCKET u) |
| 2964 | { |
| 2965 | sockets_t::iterator i = m_ClosedSockets.find(u); |
| 2966 | |
| 2967 | // invalid socket ID |
| 2968 | if (i == m_ClosedSockets.end()) |
| 2969 | return; |
| 2970 | |
| 2971 | CUDTSocket* const s = i->second; |
| 2972 | |
| 2973 | // The socket may be in the trashcan now, but could |
| 2974 | // still be under processing in the sender/receiver worker |
| 2975 | // threads. If that's the case, SKIP IT THIS TIME. The |
| 2976 | // socket will be checked next time the GC rollover starts. |
| 2977 | CSNode* sn = s->core().m_pSNode; |
| 2978 | if (sn && sn->m_iHeapLoc != -1) |
| 2979 | return; |
| 2980 | |
| 2981 | CRNode* rn = s->core().m_pRNode; |
| 2982 | if (rn && rn->m_bOnList) |
| 2983 | return; |
| 2984 | |
| 2985 | if (s->isStillBusy()) |
| 2986 | { |
| 2987 | HLOGC(smlog.Debug, log << "@" << s->m_SocketID << " is still busy, NOT deleting"); |
| 2988 | return; |
| 2989 | } |
| 2990 | |
| 2991 | HLOGC(smlog.Note, log << "@" << s->m_SocketID << " busy=" << s->isStillBusy()); |
| 2992 | |
| 2993 | #if ENABLE_BONDING |
| 2994 | if (s->m_GroupOf) |
| 2995 | { |
| 2996 | HLOGC(smlog.Debug, |
| 2997 | log << "@" << s->m_SocketID << " IS MEMBER OF $" << s->m_GroupOf->id() << " - REMOVING FROM GROUP"); |
| 2998 | s->removeFromGroup(true); |
| 2999 | } |
| 3000 | #endif |
| 3001 | // decrease multiplexer reference count, and remove it if necessary |
| 3002 | const int mid = s->m_iMuxID; |
| 3003 | |
| 3004 | { |
| 3005 | ScopedLock cg(s->m_AcceptLock); |
| 3006 | |
| 3007 | // if it is a listener, close all un-accepted sockets in its queue |
| 3008 | // and remove them later |
| 3009 | for (map<SRTSOCKET, sockaddr_any>::iterator q = s->m_QueuedSockets.begin(); |
| 3010 | q != s->m_QueuedSockets.end(); ++ q) |
| 3011 | { |
| 3012 | sockets_t::iterator si = m_Sockets.find(q->first); |
| 3013 | if (si == m_Sockets.end()) |
| 3014 | { |
| 3015 | // gone in the meantime |
| 3016 | LOGC(smlog.Error, |
| 3017 | log << "removeSocket: IPE? socket @" << (q->first) << " being queued for listener socket @" |
| 3018 | << s->m_SocketID << " is GONE in the meantime ???"); |
| 3019 | continue; |
| 3020 | } |
nothing calls this directly
no test coverage detected