Changeset - a330a1580744
[Not reviewed]
0 3 0
HanzZ - 13 years ago 2012-04-14 09:14:52
hanzz.k@gmail.com
Shutdown logging before exit() call to fix potential freeze
3 files changed with 14 insertions and 0 deletions:
0 comments (0 inline, 0 general)
backends/skype/main.cpp
Show inline comments
 
@@ -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);
 
}
 

	
include/transport/logging.h
Show inline comments
 
@@ -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();
 

	
 
}
 

	
src/logging.cpp
Show inline comments
 
@@ -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 */
 

	
0 comments (0 inline, 0 general)