From 92bfc9c2246c7e87d3aa69bd42e86142dc7434a1 Mon Sep 17 00:00:00 2001 From: Dave Horton Date: Thu, 21 Nov 2024 15:29:29 -0500 Subject: [PATCH] fix for #386 (#391) * fix for #386 * copyright notice --- src/cdr.hpp | 2 +- src/client-controller.cpp | 2 +- src/client-controller.hpp | 2 +- src/client.cpp | 2 +- src/client.hpp | 2 +- src/controller.cpp | 2 +- src/controller.hpp | 2 +- src/drachtio-config.cpp | 2 +- src/drachtio-config.hpp | 2 +- src/drachtio.cpp | 2 +- src/drachtio.h | 2 +- src/main.cpp | 2 +- src/pending-request-controller.cpp | 2 +- src/pending-request-controller.hpp | 2 +- src/request-handler.cpp | 10 ++++++++-- src/request-handler.hpp | 2 +- src/request-router.cpp | 2 +- src/request-router.hpp | 2 +- src/sip-dialog-controller.cpp | 5 ++++- src/sip-dialog-controller.hpp | 2 +- src/sip-dialog.cpp | 22 ++++++++++++++-------- src/sip-dialog.hpp | 29 ++++++++++++++++++----------- src/sip-proxy-controller.cpp | 2 +- src/sip-proxy-controller.hpp | 2 +- src/sip-transports.cpp | 2 +- src/sip-transports.hpp | 2 +- src/timer-queue-manager.hpp | 2 +- src/timer-queue.hpp | 2 +- 28 files changed, 68 insertions(+), 46 deletions(-) diff --git a/src/cdr.hpp b/src/cdr.hpp index 603d1de04a..844aee1663 100644 --- a/src/cdr.hpp +++ b/src/cdr.hpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, David C Horton +Copyright (c) 2024, FirstFive8, Inc Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/client-controller.cpp b/src/client-controller.cpp index ab738d2495..4b0216b5ef 100644 --- a/src/client-controller.cpp +++ b/src/client-controller.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, David C Horton +Copyright (c) 2024, FirstFive8, Inc Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/client-controller.hpp b/src/client-controller.hpp index 2eb597ed07..d1138756d0 100644 --- a/src/client-controller.hpp +++ b/src/client-controller.hpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, David C Horton +Copyright (c) 2024, FirstFive8, Inc Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/client.cpp b/src/client.cpp index f4d00f213a..9bc7917d9f 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, David C Horton +Copyright (c) 2024, FirstFive8, Inc Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/client.hpp b/src/client.hpp index fc96d044c5..ae8c1b517b 100644 --- a/src/client.hpp +++ b/src/client.hpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, David C Horton +Copyright (c) 2024, FirstFive8, Inc Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/controller.cpp b/src/controller.cpp index 5c2d5e15bd..be06aae192 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, David C Horton +Copyright (c) 2024, FirstFive8, Inc Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/controller.hpp b/src/controller.hpp index 70c97afafb..75cd0ed600 100644 --- a/src/controller.hpp +++ b/src/controller.hpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, David C Horton +Copyright (c) 2024, FirstFive8, Inc Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/drachtio-config.cpp b/src/drachtio-config.cpp index a68d8b72ef..c1c2f6b2e0 100644 --- a/src/drachtio-config.cpp +++ b/src/drachtio-config.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, David C Horton +Copyright (c) 2024, FirstFive8, Inc Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/drachtio-config.hpp b/src/drachtio-config.hpp index ae7a9bbd4a..4e42c05509 100644 --- a/src/drachtio-config.hpp +++ b/src/drachtio-config.hpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, David C Horton +Copyright (c) 2024, FirstFive8, Inc Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/drachtio.cpp b/src/drachtio.cpp index 33287b5c1a..c59bf62dcc 100644 --- a/src/drachtio.cpp +++ b/src/drachtio.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, David C Horton +Copyright (c) 2024, FirstFive8, Inc Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/drachtio.h b/src/drachtio.h index e09374a820..043d9f3582 100644 --- a/src/drachtio.h +++ b/src/drachtio.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, David C Horton +Copyright (c) 2024, FirstFive8, Inc Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/main.cpp b/src/main.cpp index 2e979f3e80..714a19839d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,7 +1,7 @@ /**************************************************************************** The MIT License (MIT) -Copyright (c) 2013, David C Horton +Copyright (c) 2024, FirstFive8, Inc Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/pending-request-controller.cpp b/src/pending-request-controller.cpp index 8a0222d265..a4949b4f36 100644 --- a/src/pending-request-controller.cpp +++ b/src/pending-request-controller.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, David C Horton +Copyright (c) 2024, FirstFive8, Inc Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/pending-request-controller.hpp b/src/pending-request-controller.hpp index fabf15c091..e5353ed84c 100644 --- a/src/pending-request-controller.hpp +++ b/src/pending-request-controller.hpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, David C Horton +Copyright (c) 2024, FirstFive8, Inc Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/request-handler.cpp b/src/request-handler.cpp index 9a68baf72e..b1fe68ffa7 100644 --- a/src/request-handler.cpp +++ b/src/request-handler.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, David C Horton +Copyright (c) 2024, FirstFive8, Inc Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -438,7 +438,13 @@ namespace drachtio { m_thread.swap( t ) ; } RequestHandler::~RequestHandler() { - curl_multi_cleanup(m_g.multi); + if (nullptr == m_g.multi) { + DR_LOG(log_error) << "RequestHandler::~RequestHandler - multi handle is null; this should only happen during shutdown"; + } + else { + curl_multi_cleanup(m_g.multi); + m_g.multi = nullptr; + } } void RequestHandler::threadFunc() { diff --git a/src/request-handler.hpp b/src/request-handler.hpp index e9ac5cf481..1d6d629304 100644 --- a/src/request-handler.hpp +++ b/src/request-handler.hpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, David C Horton +Copyright (c) 2024, FirstFive8, Inc Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/request-router.cpp b/src/request-router.cpp index 93ab5fa30a..bd3b20f3af 100644 --- a/src/request-router.cpp +++ b/src/request-router.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, David C Horton +Copyright (c) 2024, FirstFive8, Inc Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/request-router.hpp b/src/request-router.hpp index 61ceb93028..6ad084d692 100644 --- a/src/request-router.hpp +++ b/src/request-router.hpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, David C Horton +Copyright (c) 2024, FirstFive8, Inc Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/sip-dialog-controller.cpp b/src/sip-dialog-controller.cpp index 56ae0466bc..35616dcc29 100644 --- a/src/sip-dialog-controller.cpp +++ b/src/sip-dialog-controller.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, David C Horton +Copyright (c) 2024, FirstFive8, Inc Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -346,6 +346,9 @@ namespace drachtio { if( orq ) { DR_LOG(log_info) << "SipDialogController::doSendRequestInsideDialog - created orq " << std::hex << (void *) orq << " sending " << nta_outgoing_method_name(orq) << " to " << requestUri ; + if( sip_method_invite == method ) { + dlg->addReinviteOrq(orq); + } } } diff --git a/src/sip-dialog-controller.hpp b/src/sip-dialog-controller.hpp index 1d1f1d03b7..fc48efb453 100644 --- a/src/sip-dialog-controller.hpp +++ b/src/sip-dialog-controller.hpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, David C Horton +Copyright (c) 2024, FirstFive8, Inc Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/sip-dialog.cpp b/src/sip-dialog.cpp index d93795385c..e8fc7db9d8 100644 --- a/src/sip-dialog.cpp +++ b/src/sip-dialog.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, David C Horton +Copyright (c) 2024, FirstFive8, Inc Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -199,8 +199,8 @@ namespace drachtio { nta_leg_t *leg = nta_leg_by_call_id( theOneAndOnlyController->getAgent(), getCallId().c_str() ); - DR_LOG(log_debug) << "SipDialog::~SipDialog - I'm holding leg " << std::hex << (void *) m_leg << - " and retrieved leg via call-id " << (void *) leg; + DR_LOG(log_debug) << "SipDialog::~SipDialog - I'm holding leg " << std::hex << (void *) m_leg << + " and retrieved leg via call-id " << (void *) leg; assert( leg ) ; if( leg ) { @@ -214,6 +214,12 @@ namespace drachtio { if (we_are_uac == m_type && m_orq) { theOneAndOnlyController->getDialogController()->stopTimerD(m_orq); } + + for (nta_outgoing_t* item : m_reinvites) { + DR_LOG(log_debug) << "SipDialog::~SipDialog - I'm holding a reinvite orq " << std::hex << (void *) item; + theOneAndOnlyController->getDialogController()->stopTimerD(item); + } + /* N.B.: we only destroy the orq here for ACK for non-udp transports, since timer D handles for udp */ if (m_orqAck && m_bDestroyAckOnClose) { DR_LOG(log_debug) << "SipDialog::~SipDialog - destroying orq from original (uac) ACK " << std::hex << (void *) m_orqAck ; @@ -223,11 +229,11 @@ namespace drachtio { nta_outgoing_destroy(m_orq); } - auto txnIds = getIncomingRequestTransactionIds(); - theOneAndOnlyController->getDialogController()->clearDanglingIncomingRequests(txnIds); - - /* if we never got an ACK after sending a 200 OK to an incoming INVITE the net transaction is still there */ - theOneAndOnlyController->getClientController()->removeNetTransaction(this->getTransactionId()); + auto txnIds = getIncomingRequestTransactionIds(); + theOneAndOnlyController->getDialogController()->clearDanglingIncomingRequests(txnIds); + + /* if we never got an ACK after sending a 200 OK to an incoming INVITE the net transaction is still there */ + theOneAndOnlyController->getClientController()->removeNetTransaction(this->getTransactionId()); } std::ostream& operator<<(std::ostream& os, const SipDialog& dlg) { diff --git a/src/sip-dialog.hpp b/src/sip-dialog.hpp index 572f5f5028..1dcd28e362 100644 --- a/src/sip-dialog.hpp +++ b/src/sip-dialog.hpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, David C Horton +Copyright (c) 2024, FirstFive8, Inc Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -219,15 +219,19 @@ namespace drachtio { uint32_t getSeq(void) { return m_seq; } void clearSeq(void) {m_seq = 0;} - void addIncomingRequestTransaction(std::string& txnId) { - m_incomingRequestTransactionIds.insert(txnId); - } - void removeIncomingRequestTransaction(std::string& txnId) { - m_incomingRequestTransactionIds.erase(txnId); - } - std::vector getIncomingRequestTransactionIds(void) { - return std::vector(m_incomingRequestTransactionIds.begin(), m_incomingRequestTransactionIds.end()); - } + void addIncomingRequestTransaction(std::string& txnId) { + m_incomingRequestTransactionIds.insert(txnId); + } + void removeIncomingRequestTransaction(std::string& txnId) { + m_incomingRequestTransactionIds.erase(txnId); + } + std::vector getIncomingRequestTransactionIds(void) { + return std::vector(m_incomingRequestTransactionIds.begin(), m_incomingRequestTransactionIds.end()); + } + + void addReinviteOrq(nta_outgoing_t* orq) { + m_reinvites.push_back(orq); + } protected: @@ -291,7 +295,10 @@ namespace drachtio { // arrival time sip_time_t m_tmArrival; - std::set m_incomingRequestTransactionIds; + std::set m_incomingRequestTransactionIds; + + // re-invite orqs that we send as + std::vector m_reinvites; } ; diff --git a/src/sip-proxy-controller.cpp b/src/sip-proxy-controller.cpp index 5e655f1485..f71a6d6678 100644 --- a/src/sip-proxy-controller.cpp +++ b/src/sip-proxy-controller.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, David C Horton +Copyright (c) 2024, FirstFive8, Inc Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/sip-proxy-controller.hpp b/src/sip-proxy-controller.hpp index 9ce16ef27a..c4e1ce5d95 100644 --- a/src/sip-proxy-controller.hpp +++ b/src/sip-proxy-controller.hpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, David C Horton +Copyright (c) 2024, FirstFive8, Inc Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/sip-transports.cpp b/src/sip-transports.cpp index a5bb0c84bb..a92d7ade81 100644 --- a/src/sip-transports.cpp +++ b/src/sip-transports.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, David C Horton +Copyright (c) 2024, FirstFive8, Inc Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/sip-transports.hpp b/src/sip-transports.hpp index 4495be4cc7..1b71d9f85c 100644 --- a/src/sip-transports.hpp +++ b/src/sip-transports.hpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, David C Horton +Copyright (c) 2024, FirstFive8, Inc Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/timer-queue-manager.hpp b/src/timer-queue-manager.hpp index 829ef9feec..2cf93818df 100644 --- a/src/timer-queue-manager.hpp +++ b/src/timer-queue-manager.hpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, David C Horton +Copyright (c) 2024, FirstFive8, Inc Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/timer-queue.hpp b/src/timer-queue.hpp index 0a134c4dbb..e39da28068 100644 --- a/src/timer-queue.hpp +++ b/src/timer-queue.hpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, David C Horton +Copyright (c) 2024, FirstFive8, Inc Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal