From a5feba6ace55f053d0d23aff840ffbe90aa1f39e Mon Sep 17 00:00:00 2001 From: Tristan Matthews <tristan.matthews@savoirfairelinux.com> Date: Thu, 28 Jun 2012 15:07:45 -0400 Subject: [PATCH] * #12974: sip: check if transport already exists before trying to create/start a new one --- daemon/src/sip/siptransport.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/daemon/src/sip/siptransport.cpp b/daemon/src/sip/siptransport.cpp index eec152fe7a..e149283efa 100644 --- a/daemon/src/sip/siptransport.cpp +++ b/daemon/src/sip/siptransport.cpp @@ -338,23 +338,22 @@ void SipTransport::createSipTransport(SIPAccount &account) account.transport_ = createUdpTransport(account.getLocalInterface(), account.getLocalPort()); } } else { - account.transport_ = createUdpTransport(account.getLocalInterface(), account.getLocalPort()); - } - - if (!account.transport_) { + // if this transport already exists, reuse it std::string key(transportMapKey(account.getLocalInterface(), account.getLocalPort())); - DEBUG("Looking into previously created transport map for" " %s", key.c_str()); - // Could not create new transport, this transport may already exists std::map<std::string, pjsip_transport *>::iterator iter = transportMap_.find(key); if (iter != transportMap_.end()) { account.transport_ = iter->second; pjsip_transport_add_ref(account.transport_); - } else if (account.isTlsEnabled()) { + } else + account.transport_ = createUdpTransport(account.getLocalInterface(), account.getLocalPort()); + } + + if (!account.transport_) { + if (account.isTlsEnabled()) throw std::runtime_error("Could not create TLS connection"); - } else { + else throw std::runtime_error("Could not create new UDP transport"); - } } } -- GitLab