Shutdown logging before exit() call to fix potential freeze
This commit is contained in:
parent
c031ba344e
commit
a330a15807
3 changed files with 14 additions and 0 deletions
|
@ -165,6 +165,7 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
|
|||
if (skype) {
|
||||
LOG4CXX_INFO(logger, "User wants to logout, logging out");
|
||||
skype->logout();
|
||||
Logging::shutdownLogging();
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -801,6 +802,7 @@ static int create_socket(char *host, int portno) {
|
|||
if ((hos = gethostbyname(host)) == NULL) {
|
||||
// strerror() will not work for gethostbyname() and hstrerror()
|
||||
// is supposedly obsolete
|
||||
Logging::shutdownLogging();
|
||||
exit(1);
|
||||
}
|
||||
serv_addr.sin_addr.s_addr = *((unsigned long *) hos->h_addr_list[0]);
|
||||
|
@ -823,6 +825,7 @@ static gboolean transportDataReceived(GIOChannel *source, GIOCondition condition
|
|||
ssize_t n = read(m_sock, ptr, sizeof(buffer));
|
||||
if (n <= 0) {
|
||||
LOG4CXX_INFO(logger, "Diconnecting from spectrum2 server");
|
||||
Logging::shutdownLogging();
|
||||
exit(errno);
|
||||
}
|
||||
std::string d = std::string(buffer, n);
|
||||
|
@ -831,6 +834,7 @@ static gboolean transportDataReceived(GIOChannel *source, GIOCondition condition
|
|||
}
|
||||
|
||||
static void io_destroy(gpointer data) {
|
||||
Logging::shutdownLogging();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "log4cxx/helpers/fileinputstream.h"
|
||||
#include "log4cxx/helpers/transcoder.h"
|
||||
#include "log4cxx/logger.h"
|
||||
#include "log4cxx/logmanager.h"
|
||||
|
||||
#define DEFINE_LOGGER(VAR, NAME) static log4cxx::LoggerPtr VAR = log4cxx::Logger::getLogger(NAME);
|
||||
|
||||
|
@ -55,6 +56,7 @@ namespace Logging {
|
|||
|
||||
void initBackendLogging(Config *config);
|
||||
void initMainLogging(Config *config);
|
||||
void shutdownLogging();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -139,11 +139,19 @@ void initMainLogging(Config *config) {
|
|||
initLogging(config, "logging.config");
|
||||
}
|
||||
|
||||
void shutdownLogging() {
|
||||
log4cxx::LogManager::shutdown();
|
||||
}
|
||||
|
||||
#else /* WITH_LOG4CXX */
|
||||
void initBackendLogging(Config */*config*/) {
|
||||
}
|
||||
|
||||
void initMainLogging(Config */*config*/) {
|
||||
}
|
||||
|
||||
void shutdownLogging() {
|
||||
|
||||
}
|
||||
#endif /* WITH_LOG4CXX */
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue