Changeset - e31c07794705
[Not reviewed]
0 7 0
HanzZ - 14 years ago 2011-07-20 02:16:58
hanzz.k@gmail.com
Call finishSession in User destructor in server mode
7 files changed with 49 insertions and 2 deletions:
0 comments (0 inline, 0 general)
include/Swiften/Server/Server.cpp
Show inline comments
 
@@ -141,6 +141,7 @@ void Server::handleSessionFinished(boost::shared_ptr<ServerFromClientSession> se
 
		dynamic_cast<ServerStanzaChannel *>(stanzaChannel_)->onPresenceReceived(presence);
 
	}
 
	serverFromClientSessions.erase(std::remove(serverFromClientSessions.begin(), serverFromClientSessions.end(), session), serverFromClientSessions.end());
 
	std::cout << "FINISH SESSION2 " << serverFromClientSessions.size() << "\n";
 
	session->onSessionStarted.disconnect(
 
			boost::bind(&Server::handleSessionStarted, this, session));
 
	session->onSessionFinished.disconnect(
include/Swiften/Server/ServerFromClientSession.cpp
Show inline comments
 
@@ -48,6 +48,8 @@ ServerFromClientSession::ServerFromClientSession(
 

	
 
ServerFromClientSession::~ServerFromClientSession() {
 
	std::cout << "DESTRUCTOR;\n";
 
	userRegistry_->onPasswordValid.disconnect(boost::bind(&ServerFromClientSession::handlePasswordValid, this, _1));
 
	userRegistry_->onPasswordInvalid.disconnect(boost::bind(&ServerFromClientSession::handlePasswordInvalid, this, _1));
 
	if (tlsLayer) {
 
		delete tlsLayer;
 
	}
include/Swiften/Server/ServerStanzaChannel.cpp
Show inline comments
 
@@ -6,6 +6,7 @@
 

	
 
#include "Swiften/Server/ServerStanzaChannel.h"
 
#include "Swiften/Base/Error.h"
 
#include <iostream>
 

	
 
#include <boost/bind.hpp>
 

	
 
@@ -55,13 +56,17 @@ void ServerStanzaChannel::sendPresence(boost::shared_ptr<Presence> presence) {
 
void ServerStanzaChannel::finishSession(const JID& to, boost::shared_ptr<Element> element) {
 
	std::vector<boost::shared_ptr<ServerFromClientSession> > candidateSessions;
 
	for (std::list<boost::shared_ptr<ServerFromClientSession> >::const_iterator i = sessions[to.toBare().toString()].begin(); i != sessions[to.toBare().toString()].end(); ++i) {
 
		if (element) {
 
			(*i)->sendElement(element);
 
		}
 
		candidateSessions.push_back(*i);
 
	}
 

	
 
	for (std::vector<boost::shared_ptr<ServerFromClientSession> >::const_iterator i = candidateSessions.begin(); i != candidateSessions.end(); ++i) {
 
		
 
		(*i)->finishSession();
 
		sessions[to.toBare().toString()].remove(*i);
 
		std::cout << "FINISH SESSION " << sessions[to.toBare().toString()].size() << "\n";
 
	}
 
}
 

	
spectrum/src/main.cpp
Show inline comments
 
@@ -7,13 +7,34 @@
 
#include "transport/networkpluginserver.h"
 
#include "transport/admininterface.h"
 
#include "Swiften/EventLoop/SimpleEventLoop.h"
 
#include "sys/signal.h"
 
 
using namespace Transport;
 
 
Swift::SimpleEventLoop *eventLoop_ = NULL;
 
 
static void spectrum_sigint_handler(int sig) {
 
	eventLoop_->stop();
 
}
 
 
static void spectrum_sigterm_handler(int sig) {
 
	eventLoop_->stop();
 
}
 
 
int main(int argc, char **argv)
 
{
 
	Config config;
 
 
	if (signal(SIGINT, spectrum_sigint_handler) == SIG_ERR) {
 
		std::cout << "SIGINT handler can't be set\n";
 
		return -1;
 
	}
 
 
	if (signal(SIGTERM, spectrum_sigterm_handler) == SIG_ERR) {
 
		std::cout << "SIGTERM handler can't be set\n";
 
		return -1;
 
	}
 
 
	boost::program_options::options_description desc("Usage: spectrum [OPTIONS] <config_file.cfg>\nAllowed options");
 
	desc.add_options()
 
		("help,h", "help")
 
@@ -69,8 +90,9 @@ int main(int argc, char **argv)
 
	}
 
 
	UserManager userManager(&transport, &userRegistry, storageBackend);
 
	UserRegistration *userRegistration = NULL;
 
	if (storageBackend) {
 
		UserRegistration *userRegistration = new UserRegistration(&transport, &userManager, storageBackend);
 
		userRegistration = new UserRegistration(&transport, &userManager, storageBackend);
 
		userRegistration->start();
 
// 		logger.setUserRegistration(&userRegistration);
 
	}
 
@@ -80,5 +102,12 @@ int main(int argc, char **argv)
 
 
	AdminInterface adminInterface(&transport, &userManager, &plugin, storageBackend);
 
 
	eventLoop_ = &eventLoop;
 
 
	eventLoop.run();
 
	if (userRegistration) {
 
		userRegistration->stop();
 
		delete userRegistration;
 
	}
 
	delete storageBackend;
 
}
src/networkpluginserver.cpp
Show inline comments
 
@@ -168,6 +168,9 @@ NetworkPluginServer::NetworkPluginServer(Component *component, Config *config, U
 

	
 
NetworkPluginServer::~NetworkPluginServer() {
 
	m_pingTimer->stop();
 
	m_server->stop();
 
	m_server.reset();
 
	delete m_component->m_factory;
 
	delete m_vcardResponder;
 
	delete m_rosterResponder;
 
}
src/transport.cpp
Show inline comments
 
@@ -134,10 +134,13 @@ Component::~Component() {
 
	delete m_capsManager;
 
	delete m_capsMemoryStorage;
 
	delete m_discoInfoResponder;
 
	delete m_discoItemsResponder;
 
	if (m_component)
 
		delete m_component;
 
	if (m_server)
 
	if (m_server) {
 
		m_server->stop();
 
		delete m_server;
 
	}
 
	delete m_factories;
 
}
 

	
src/user.cpp
Show inline comments
 
@@ -62,6 +62,10 @@ User::User(const Swift::JID &jid, UserInfo &userInfo, Component *component, User
 

	
 
User::~User(){
 
	LOG4CXX_INFO(logger, m_jid.toString() << ": Destroying");
 
	if (m_component->inServerMode()) {
 
		dynamic_cast<Swift::ServerStanzaChannel *>(m_component->getStanzaChannel())->finishSession(m_jid, boost::shared_ptr<Swift::Element>());
 
	}
 

	
 
	m_reconnectTimer->stop();
 
	delete m_rosterManager;
 
	delete m_conversationManager;
0 comments (0 inline, 0 general)