Commit 8a73d38d authored by pierre-luc's avatar pierre-luc

[#2027] Fix segmentation fault when showMessage callback is called after

an error occured with libzrtpcpp. Also, exceptions in AudioRtpFactory are
now derived from some more specialized types.
parent 41c7a67e
......@@ -754,6 +754,7 @@ show_account_window (account_t * a)
gchar* keyExchange = (gchar *)gtk_combo_box_get_active_text(GTK_COMBO_BOX(keyExchangeCombo));
if (g_strcasecmp(keyExchange, "ZRTP") == 0) {
g_hash_table_replace(currentAccount->properties, g_strdup(ACCOUNT_SRTP_ENABLED), g_strdup("TRUE"));
g_hash_table_replace(currentAccount->properties, g_strdup(ACCOUNT_KEY_EXCHANGE), g_strdup("1"));
} else {
g_hash_table_replace(currentAccount->properties, g_strdup(ACCOUNT_SRTP_ENABLED), g_strdup("FALSE"));
}
......
......@@ -58,8 +58,8 @@ namespace sfl {
assert(ca);
if (_rtpSession != NULL) {
_debugException("An audio rtp thread was already created but not \
destroyed. Forcing it before continuing.\n");
_debugException("An audio rtp thread was already created but not" \
"destroyed. Forcing it before continuing.\n");
stop();
}
......@@ -113,27 +113,23 @@ namespace sfl {
void AudioRtpFactory::start(void)
{
if (_rtpSession == NULL) {
throw AudioRtpFactoryException();
}
try {
switch(_rtpSessionType) {
case Sdes:
case Symmetric:
_debug("Starting symmetric rtp thread\n");
if(static_cast<AudioSymmetricRtpSession *>(_rtpSession)->startRtpThread() != 0) {
throw AudioRtpFactoryException();
}
break;
case Zrtp:
if(static_cast<AudioZrtpSession *>(_rtpSession)->startRtpThread() != 0) {
throw AudioRtpFactoryException();
}
break;
}
} catch (...) {
throw AudioRtpFactoryException();
throw AudioRtpFactoryException("_rtpSession was null when trying to start audio thread");
}
switch(_rtpSessionType) {
case Sdes:
case Symmetric:
_debug("Starting symmetric rtp thread\n");
if(static_cast<AudioSymmetricRtpSession *>(_rtpSession)->startRtpThread() != 0) {
throw AudioRtpFactoryException("Failed to start AudioSymmetricRtpSession thread");
}
break;
case Zrtp:
if(static_cast<AudioZrtpSession *>(_rtpSession)->startRtpThread() != 0) {
throw AudioRtpFactoryException("Failed to start AudioZrtpSession thread");
}
break;
}
}
void AudioRtpFactory::stop(void)
......@@ -141,8 +137,7 @@ namespace sfl {
ost::MutexLock mutex(_audioRtpThreadMutex);
_debug("Stopping audio rtp session\n");
if (_rtpSession == NULL) {
_debugException("_rtpSession is null\n");
throw AudioRtpFactoryException();
throw AudioRtpFactoryException("_rtpSession is null when trying to stop");
}
try {
switch(_rtpSessionType) {
......
......@@ -19,7 +19,7 @@
#ifndef __SFL_AUDIO_RTP_FACTORY_H__
#define __SFL_AUDIO_RTP_FACTORY_H__
#include <exception>
#include <stdexcept>
#include <cc++/thread.h>
class SIPCall;
......@@ -38,20 +38,15 @@ namespace sfl {
Sdes
} RtpMethod;
class UnsupportedRtpSessionType: public std::exception
{
virtual const char* what() const throw()
{
return "Could not create RTP session of the given type";
}
};
class AudioRtpFactoryException: public std::exception
{
virtual const char* what() const throw()
{
return "An AudioRtpFactoryException occured";
}
class UnsupportedRtpSessionType : public std::logic_error {
public:
UnsupportedRtpSessionType(const std::string& msg = "") : std::logic_error(msg) {}
};
class AudioRtpFactoryException : public std::logic_error {
public:
AudioRtpFactoryException(const std::string& msg = "") : std::logic_error(msg) {}
};
class AudioRtpFactory {
......
......@@ -143,29 +143,30 @@ namespace sfl {
if (sev == Info) {
msg = _infoMap[subCode];
if (msg != NULL) {
_debug("ZRTP Debug: %s\n", msg->c_str());
_debug("ZRTP Debug:\n", msg->c_str());
}
}
if (sev == Warning) {
msg = _warningMap[subCode];
if (msg != NULL) {
_debug("ZRTP Debug: %s\n", msg->c_str());
_debug("ZRTP Debug:\n", msg->c_str());
}
}
if (sev == Severe) {
msg = _severeMap[subCode];
if (msg != NULL) {
_debug("ZRTP Debug: %s\n", msg->c_str());
_debug("ZRTP Debug:\n", msg->c_str());
}
}
if (sev == ZrtpError) {
if (subCode < 0) { // received an error packet from peer
subCode *= -1;
_debug("Received an error packet from peer: %s\n", msg->c_str());
_debug("Received an error packet from peer:\n");
}
else {
_debug("Sent error packet to peer: %s\n", msg->c_str());
_debug("Sent error packet to peer:\n");
}
msg = _zrtpMap[subCode];
if (msg != NULL) {
_debug("ZRTP Debug: %s\n", msg->c_str());
......@@ -180,10 +181,10 @@ namespace sfl {
if (severity == ZrtpError) {
if (subCode < 0) { // received an error packet from peer
subCode *= -1;
_debug("Received error packet: ");
_debug("Received error packet: \n");
}
else {
_debug("Sent error packet: ");
_debug("Sent error packet: \n");
}
msg = _zrtpMap[subCode];
if (msg != NULL) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment