Skip to content

Commit

Permalink
[core] Reordered socket/eid removal on unsubscription (#1390)
Browse files Browse the repository at this point in the history
  • Loading branch information
ethouris committed Aug 6, 2020
1 parent b0c1520 commit e4ec8dc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
12 changes: 8 additions & 4 deletions srtcore/api.cpp
Expand Up @@ -1578,7 +1578,7 @@ int CUDTUnited::groupConnect(CUDTGroup* pg, SRT_SOCKGROUPCONFIG* targets, int ar
// Finished, delete epoll.
if (eid != -1)
{
HLOGC(mglog.Debug, log << "connect FIRST IN THE GROUP finished, removing EID " << eid);
HLOGC(mglog.Debug, log << "connect FIRST IN THE GROUP finished, removing E" << eid);
srt_epoll_release(eid);
}

Expand Down Expand Up @@ -2166,13 +2166,17 @@ int CUDTUnited::epoll_remove_entity(const int eid, EntityType* ent)
HLOGC(dlog.Debug, log << "epoll_remove_usock: CLEARING readiness on E" << eid << " of @" << ent->id());
ent->removeEPollEvents(eid);

// First remove the EID from the subscribed in the socket so that
// a possible call to update_events:
// - if happens before this call, can find the epoll bit update possible
// - if happens after this call, will not strike this EID
HLOGC(dlog.Debug, log << "epoll_remove_usock: REMOVING E" << eid << " from back-subscirbers in @" << ent->id());
ent->removeEPollID(eid);

HLOGC(dlog.Debug, log << "epoll_remove_usock: CLEARING subscription on E" << eid << " of @" << ent->id());
int no_events = 0;
int ret = m_EPoll.update_usock(eid, ent->id(), &no_events);

HLOGC(dlog.Debug, log << "epoll_remove_usock: REMOVING E" << eid << " from back-subscirbers in @" << ent->id());
ent->removeEPollID(eid);

return ret;
}

Expand Down
12 changes: 6 additions & 6 deletions srtcore/epoll.cpp
Expand Up @@ -782,7 +782,7 @@ int CEPoll::swait(CEPollDesc& d, map<SRTSOCKET, int>& st, int64_t msTimeOut, boo

// Logging into 'singles' because it notifies as to whether
// the edge-triggered event has been cleared
HLOGC(dlog.Debug, log << "EID " << d.m_iID << " rdy=" << total << ": "
HLOGC(dlog.Debug, log << "E" << d.m_iID << " rdy=" << total << ": "
<< singles.str()
<< " TRACKED: " << d.DisplayEpollWatch());
return total;
Expand Down Expand Up @@ -847,7 +847,7 @@ int CEPoll::update_events(const SRTSOCKET& uid, std::set<int>& eids, const int e
map<int, CEPollDesc>::iterator p = m_mPolls.find(*i);
if (p == m_mPolls.end())
{
HLOGC(dlog.Note, log << "epoll/update: EID " << *i << " was deleted in the meantime");
HLOGC(dlog.Note, log << "epoll/update: E" << *i << " was deleted in the meantime");
// EID invalid, though still present in the socket's subscriber list
// (dangling in the socket). Postpone to fix the subscruption and continue.
lost.push_back(*i);
Expand All @@ -861,7 +861,7 @@ int CEPoll::update_events(const SRTSOCKET& uid, std::set<int>& eids, const int e
if (!pwait)
{
// As this is mapped in the socket's data, it should be impossible.
LOGC(dlog.Error, log << "epoll/update: IPE: update struck EID "
LOGC(dlog.Error, log << "epoll/update: IPE: update struck E"
<< (*i) << " which is NOT SUBSCRIBED to @" << uid);
continue;
}
Expand All @@ -877,7 +877,7 @@ int CEPoll::update_events(const SRTSOCKET& uid, std::set<int>& eids, const int e
int changes = pwait->state ^ newstate; // oldState XOR newState
if (!changes)
{
HLOGC(dlog.Debug, log << debug.str() << ": EID " << (*i)
HLOGC(dlog.Debug, log << debug.str() << ": E" << (*i)
<< tracking << " NOT updated: no changes");
continue; // no changes!
}
Expand All @@ -887,7 +887,7 @@ int CEPoll::update_events(const SRTSOCKET& uid, std::set<int>& eids, const int e
changes &= pwait->watch;
if (!changes)
{
HLOGC(dlog.Debug, log << debug.str() << ": EID " << (*i)
HLOGC(dlog.Debug, log << debug.str() << ": E" << (*i)
<< tracking << " NOT updated: not subscribed");
continue; // no change watching
}
Expand All @@ -899,7 +899,7 @@ int CEPoll::update_events(const SRTSOCKET& uid, std::set<int>& eids, const int e
// - if !enable, it will clear event flags, possibly remove notice if resulted in 0
ed.updateEventNotice(*pwait, uid, events, enable);

HLOGC(dlog.Debug, log << debug.str() << ": EID " << (*i)
HLOGC(dlog.Debug, log << debug.str() << ": E" << (*i)
<< " TRACKING: " << ed.DisplayEpollWatch());
}

Expand Down

0 comments on commit e4ec8dc

Please sign in to comment.