Skip to content

Commit

Permalink
wait 30 after disconnect before deleting call object due to late arri…
Browse files Browse the repository at this point in the history
…ving RTP
  • Loading branch information
willamowius committed Jan 14, 2018
1 parent 99e4125 commit ee17f8a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
7 changes: 3 additions & 4 deletions ProxyChannel.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,6 @@ class LogicalChannel {
LogicalChannel(WORD flcn = 0) : channelNumber(flcn), port(0), used(false) { }
virtual ~LogicalChannel() { }

bool IsUsed() const { return used; }
bool Compare(WORD lcn) const { return channelNumber == lcn; }
WORD GetPort() const { return port; }
WORD GetChannelNumber() const { return channelNumber; }
Expand Down Expand Up @@ -10330,7 +10329,7 @@ MultiplexedRTPHandler::MultiplexedRTPHandler() : Singleton<MultiplexedRTPHandler
m_reader = new MultiplexedRTPReader();
PTime now;
m_cleanupTimer = Toolkit::Instance()->GetTimerManager()->RegisterTimer(this, &MultiplexedRTPHandler::SessionCleanup, now, 30);
m_deleteDelay.SetMilliSeconds(30 * 1000); // wait 30 sec. before really deleting a deleted session
m_deleteDelay.SetMilliSeconds(WAIT_DELETE_AFTER_DISCONNECT * 1000); // wait 30 sec. before really deleting a deleted session
} else {
m_reader = NULL;
m_cleanupTimer = GkTimerManager::INVALID_HANDLE;
Expand Down Expand Up @@ -10524,7 +10523,7 @@ bool MultiplexedRTPHandler::HandlePacket(DWORD receivedMultiplexID, const IPAndP
}
if (!isRTCP) {
// no warning for RTCP, probably a Polycom RTCP packet with missing multiplex ID
PTRACE(3, "RTP\tWarning: Didn't find a channel for receivedMultiplexID " << receivedMultiplexID << " from " << AsString(fromAddress));
PTRACE(7, "RTP\tWarning: Didn't find a channel for receivedMultiplexID " << receivedMultiplexID << " from " << AsString(fromAddress));
}
return false;
}
Expand Down Expand Up @@ -14105,7 +14104,7 @@ bool H245ProxyHandler::HandleCloseLogicalChannel(H245_CloseLogicalChannel & clc,
second->RemoveLogicalChannel((WORD)clc.m_forwardLogicalChannelNumber);
}
#ifdef HAS_H46018
call->RemoveKeepAlives(clc.m_forwardLogicalChannelNumber);
call->RemoveRTPKeepAlives(clc.m_forwardLogicalChannelNumber);
#endif
return false; // nothing changed
}
Expand Down
9 changes: 4 additions & 5 deletions RasTbl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2879,7 +2879,7 @@ CallRec::~CallRec()
{
PTRACE(3, "Gk\tDelete Call No. " << m_CallNumber);
#ifdef HAS_H46018
RemoveKeepAllAlives();
RemoveAllRTPKeepAlives();
#endif
delete(m_newSetupInternalAliases);

Expand Down Expand Up @@ -5074,13 +5074,13 @@ void CallRec::StartRTCPKeepAlive(unsigned flcn, int RTCPOSSocket)
}
}

void CallRec::RemoveKeepAlives(unsigned flcn)
void CallRec::RemoveRTPKeepAlives(unsigned flcn)
{
m_RTPkeepalives.erase(flcn);
m_RTCPkeepalives.erase(flcn);
}

void CallRec::RemoveKeepAllAlives()
void CallRec::RemoveAllRTPKeepAlives()
{
m_RTPkeepalives.clear();
m_RTCPkeepalives.clear();
Expand Down Expand Up @@ -5691,12 +5691,11 @@ void CallTable::RemoveCall(const callptr & call)
InternalRemovePtr(call.operator->());
}

bool CallTable::InternalRemovePtr(CallRec *call)
void CallTable::InternalRemovePtr(CallRec *call)
{
PTRACE(6, "GK\tRemoving callptr: " << AsString(call->GetCallIdentifier().m_guid));
WriteLock lock(listLock);
InternalRemove(find(CallList.begin(), CallList.end(), call));
return true; // useless, workaround for VC
}

void CallTable::RemoveFailedLeg(const callptr & call)
Expand Down
22 changes: 17 additions & 5 deletions RasTbl.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const DWORD INVALID_MULTIPLEX_ID = 0;
const BYTE GNUGK_KEEPALIVE_RTP_PAYLOADTYPE = 116; // must at least be 1 less than MAX_DYNAMIC_PAYLOAD_TYPE
const BYTE MIN_DYNAMIC_PAYLOAD_TYPE = 96;
const BYTE MAX_DYNAMIC_PAYLOAD_TYPE = 127;
const unsigned WAIT_DELETE_AFTER_DISCONNECT = 30; // time to wait after disconnect before deleting call object

enum PortType { RASPort=1, Q931Port=2, H245Port=3, RTPPort=4, T120Port=5, RadiusPort=6, StatusPort=7 };
enum PortAction { PortOpen=1, PortClose=2 };
Expand Down Expand Up @@ -929,8 +930,6 @@ class CallRec {
bool CompareSigAdr(const H225_TransportAddress *adr) const;
bool CompareSigAdrIgnorePort(const H225_TransportAddress *adr) const;

bool IsUsed() const { return (m_usedCount != 0); }

/** @return
true if the call has been connected - a Connect message
has been received in gk routed signaling or the call has been admitted
Expand All @@ -957,6 +956,7 @@ class CallRec {

void Lock();
void Unlock();
bool IsUsed() const;

/** @return
Q.931 ReleaseComplete cause code for the call.
Expand Down Expand Up @@ -1432,8 +1432,8 @@ class CallRec {
void StartRTPKeepAlive(unsigned flcn, int RTPOSSocket);
void AddRTCPKeepAlive(unsigned flcn, const H245_UnicastAddress & keepAliveRTCPAddr, unsigned keepAliveInterval, DWORD multiplexID);
void StartRTCPKeepAlive(unsigned flcn, int RTCPOSSocket);
void RemoveKeepAlives(unsigned flcn);
void RemoveKeepAllAlives();
void RemoveRTPKeepAlives(unsigned flcn);
void RemoveAllRTPKeepAlives();

void SetSessionMultiplexDestination(WORD session, void * openedBy, bool isRTCP, const IPAndPortAddress & toAddress, H46019Side side);
bool IgnoreSignaledIPs() const { return m_ignoreSignaledIPs; }
Expand Down Expand Up @@ -1813,7 +1813,7 @@ class CallTable : public Singleton<CallTable>
return callptr((Iter != CallList.end()) ? *Iter : 0);
}

bool InternalRemovePtr(CallRec *call);
void InternalRemovePtr(CallRec *call);
void InternalRemove(iterator);
void InternalRemoveFailedLeg(iterator);

Expand Down Expand Up @@ -2125,6 +2125,18 @@ inline void CallRec::Unlock()
--m_usedCount;
}

inline bool CallRec::IsUsed() const {
if (m_usedCount != 0)
return true;
// also consider all calls that ever connected as used until 30 sec after disconnect (due to late arriving RTP)
if ((m_disconnectTime > 0) && (time(NULL) - m_disconnectTime > WAIT_DELETE_AFTER_DISCONNECT))
return true;
if ((m_connectTime > 0) && (time(NULL) - m_connectTime > WAIT_DELETE_AFTER_DISCONNECT))
return true;
return false;
}


inline bool CallRec::CompareCallId(const H225_CallIdentifier *CallId) const
{
return (m_callIdentifier == *CallId);
Expand Down

0 comments on commit ee17f8a

Please sign in to comment.