summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2016-03-31 14:57:35 (GMT)
committerTobias Markmann <tm@ayena.de>2016-03-31 14:57:35 (GMT)
commitcfbdb43d2cadd40aa87338d41548e4bf89e146e6 (patch)
tree18d94153a302445196fc0c18586abf44a1ce4a38 /Swiften/Network/BoostConnectionServer.cpp
parent1d545a4a7fb877f021508094b88c1f17b30d8b4e (diff)
downloadswift-cfbdb43d2cadd40aa87338d41548e4bf89e146e6.zip
swift-cfbdb43d2cadd40aa87338d41548e4bf89e146e6.tar.bz2
Convert tabs to 4 spaces for all source files
Removed trailing spaces and whitespace on empty lines in the process. Changed CheckTabs.py tool to disallow hard tabs in source files. Test-Information: Manually checked 30 random files that the conversion worked as expected. Change-Id: I874f99d617bd3d2bb55f02d58f22f58f9b094480
Diffstat (limited to 'Swiften/Network/BoostConnectionServer.cpp')
-rw-r--r--Swiften/Network/BoostConnectionServer.cpp118
1 files changed, 59 insertions, 59 deletions
diff --git a/Swiften/Network/BoostConnectionServer.cpp b/Swiften/Network/BoostConnectionServer.cpp
index 48b323d..0b20a7f 100644
--- a/Swiften/Network/BoostConnectionServer.cpp
+++ b/Swiften/Network/BoostConnectionServer.cpp
@@ -26,84 +26,84 @@ BoostConnectionServer::BoostConnectionServer(const HostAddress &address, int por
}
void BoostConnectionServer::start() {
- boost::optional<Error> error = tryStart();
- if (error) {
- eventLoop->postEvent(boost::bind(boost::ref(onStopped), *error), shared_from_this());
- }
+ boost::optional<Error> error = tryStart();
+ if (error) {
+ eventLoop->postEvent(boost::bind(boost::ref(onStopped), *error), shared_from_this());
+ }
}
boost::optional<BoostConnectionServer::Error> BoostConnectionServer::tryStart() {
- try {
- assert(!acceptor_);
- boost::asio::ip::tcp::endpoint endpoint;
- if (address_.isValid()) {
- endpoint = boost::asio::ip::tcp::endpoint(address_.getRawAddress(), boost::numeric_cast<unsigned short>(port_));
- }
- else {
- endpoint = boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v6(), boost::numeric_cast<unsigned short>(port_));
- }
- acceptor_ = new boost::asio::ip::tcp::acceptor(*ioService_, endpoint);
- if (endpoint.protocol() == boost::asio::ip::tcp::v6()) {
- boost::system::error_code ec;
- acceptor_->set_option(boost::asio::ip::v6_only(false), ec);
- SWIFT_LOG_ASSERT(ec, warning) << "IPv4/IPv6 dual-stack support is not supported on this platform." << std::endl;
- }
- acceptNextConnection();
- }
- catch (const boost::system::system_error& e) {
- if (e.code() == boost::asio::error::address_in_use) {
- return Conflict;
- }
- else {
- return UnknownError;
- }
- }
- return boost::optional<Error>();
+ try {
+ assert(!acceptor_);
+ boost::asio::ip::tcp::endpoint endpoint;
+ if (address_.isValid()) {
+ endpoint = boost::asio::ip::tcp::endpoint(address_.getRawAddress(), boost::numeric_cast<unsigned short>(port_));
+ }
+ else {
+ endpoint = boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v6(), boost::numeric_cast<unsigned short>(port_));
+ }
+ acceptor_ = new boost::asio::ip::tcp::acceptor(*ioService_, endpoint);
+ if (endpoint.protocol() == boost::asio::ip::tcp::v6()) {
+ boost::system::error_code ec;
+ acceptor_->set_option(boost::asio::ip::v6_only(false), ec);
+ SWIFT_LOG_ASSERT(ec, warning) << "IPv4/IPv6 dual-stack support is not supported on this platform." << std::endl;
+ }
+ acceptNextConnection();
+ }
+ catch (const boost::system::system_error& e) {
+ if (e.code() == boost::asio::error::address_in_use) {
+ return Conflict;
+ }
+ else {
+ return UnknownError;
+ }
+ }
+ return boost::optional<Error>();
}
void BoostConnectionServer::stop() {
- stop(boost::optional<Error>());
+ stop(boost::optional<Error>());
}
void BoostConnectionServer::stop(boost::optional<Error> e) {
- if (acceptor_) {
- acceptor_->close();
- delete acceptor_;
- acceptor_ = NULL;
- }
- eventLoop->postEvent(boost::bind(boost::ref(onStopped), e), shared_from_this());
+ if (acceptor_) {
+ acceptor_->close();
+ delete acceptor_;
+ acceptor_ = NULL;
+ }
+ eventLoop->postEvent(boost::bind(boost::ref(onStopped), e), shared_from_this());
}
void BoostConnectionServer::acceptNextConnection() {
- BoostConnection::ref newConnection(BoostConnection::create(ioService_, eventLoop));
- acceptor_->async_accept(newConnection->getSocket(),
- boost::bind(&BoostConnectionServer::handleAccept, shared_from_this(), newConnection, boost::asio::placeholders::error));
+ BoostConnection::ref newConnection(BoostConnection::create(ioService_, eventLoop));
+ acceptor_->async_accept(newConnection->getSocket(),
+ boost::bind(&BoostConnectionServer::handleAccept, shared_from_this(), newConnection, boost::asio::placeholders::error));
}
void BoostConnectionServer::handleAccept(boost::shared_ptr<BoostConnection> newConnection, const boost::system::error_code& error) {
- if (error) {
- eventLoop->postEvent(
- boost::bind(
- &BoostConnectionServer::stop, shared_from_this(), UnknownError),
- shared_from_this());
- }
- else {
- eventLoop->postEvent(
- boost::bind(boost::ref(onNewConnection), newConnection),
- shared_from_this());
- newConnection->listen();
- acceptNextConnection();
- }
+ if (error) {
+ eventLoop->postEvent(
+ boost::bind(
+ &BoostConnectionServer::stop, shared_from_this(), UnknownError),
+ shared_from_this());
+ }
+ else {
+ eventLoop->postEvent(
+ boost::bind(boost::ref(onNewConnection), newConnection),
+ shared_from_this());
+ newConnection->listen();
+ acceptNextConnection();
+ }
}
HostAddressPort BoostConnectionServer::getAddressPort() const {
- if (acceptor_) {
- return HostAddressPort(acceptor_->local_endpoint());
- }
- else {
- return HostAddressPort();
- }
+ if (acceptor_) {
+ return HostAddressPort(acceptor_->local_endpoint());
+ }
+ else {
+ return HostAddressPort();
+ }
}
}