diff --git a/ProxyChannel.cxx b/ProxyChannel.cxx index b2d5d9b0..39d53a55 100644 --- a/ProxyChannel.cxx +++ b/ProxyChannel.cxx @@ -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; } @@ -10330,7 +10329,7 @@ MultiplexedRTPHandler::MultiplexedRTPHandler() : SingletonGetTimerManager()->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; @@ -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; } @@ -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 } diff --git a/RasTbl.cxx b/RasTbl.cxx index 64944576..3ea1068b 100644 --- a/RasTbl.cxx +++ b/RasTbl.cxx @@ -2879,7 +2879,7 @@ CallRec::~CallRec() { PTRACE(3, "Gk\tDelete Call No. " << m_CallNumber); #ifdef HAS_H46018 - RemoveKeepAllAlives(); + RemoveAllRTPKeepAlives(); #endif delete(m_newSetupInternalAliases); @@ -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(); @@ -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) diff --git a/RasTbl.h b/RasTbl.h index 7786dec3..a05eeadb 100644 --- a/RasTbl.h +++ b/RasTbl.h @@ -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 }; @@ -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 @@ -957,6 +956,7 @@ class CallRec { void Lock(); void Unlock(); + bool IsUsed() const; /** @return Q.931 ReleaseComplete cause code for the call. @@ -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; } @@ -1813,7 +1813,7 @@ class CallTable : public Singleton return callptr((Iter != CallList.end()) ? *Iter : 0); } - bool InternalRemovePtr(CallRec *call); + void InternalRemovePtr(CallRec *call); void InternalRemove(iterator); void InternalRemoveFailedLeg(iterator); @@ -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);