1
0
Fork 0

Remove native socket handle...just used for debugging and on windows it

seems to be template infected (das isses nicht wert)
This commit is contained in:
Andreas Streichardt 2016-10-20 23:45:40 +02:00
parent 1379087dd1
commit fdb21044de
4 changed files with 10 additions and 26 deletions

View File

@ -90,7 +90,6 @@ class Socket {
virtual void close() = 0;
virtual void close(boost::system::error_code& ec) = 0;
virtual void setNonBlocking(bool) = 0;
virtual boost::asio::serial_port_service::native_handle_type nativeHandle() = 0;
virtual std::string peerAddress() = 0;
virtual int peerPort() = 0;
bool handshake();

View File

@ -86,8 +86,7 @@ void SocketTask::start() {
}
LOG_TOPIC(DEBUG, Logger::COMMUNICATION)
<< "starting communication between server <-> client on socket: "
<< _peer->nativeHandle();
<< "starting communication between server <-> client on socket";
LOG_TOPIC(DEBUG, Logger::COMMUNICATION)
<< _connectionInfo.serverAddress << ":" << _connectionInfo.serverPort
<< " <-> " << _connectionInfo.clientAddress << ":"
@ -161,7 +160,6 @@ void SocketTask::addWriteBuffer(StringBuffer* buffer,
if (err != boost::system::errc::success) {
LOG_TOPIC(DEBUG, Logger::COMMUNICATION)
<< "SocketTask::addWriteBuffer (write_some) - write on stream "
<< _peer->nativeHandle()
<< " failed with: " << err.message();
closeStream();
return;
@ -173,7 +171,6 @@ void SocketTask::addWriteBuffer(StringBuffer* buffer,
if (ec) {
LOG_TOPIC(DEBUG, Logger::COMMUNICATION)
<< "SocketTask::addWriterBuffer(async_write) - write on stream "
<< _peer->nativeHandle()
<< " failed with: " << ec.message();
closeStream();
} else {
@ -234,7 +231,6 @@ void SocketTask::closeStream() {
if (err && err != boost::asio::error::not_connected) {
LOG_TOPIC(DEBUG, Logger::COMMUNICATION)
<< "SocketTask::closeStream - shutdown send stream "
<< _peer->nativeHandle()
<< " failed with: " << err.message();
}
@ -246,7 +242,6 @@ void SocketTask::closeStream() {
if (err && err != boost::asio::error::not_connected) {
LOG_TOPIC(DEBUG, Logger::COMMUNICATION)
<< "SocketTask::CloseStream - shutdown send stream "
<< _peer->nativeHandle()
<< " failed with: " << err.message();
}
@ -258,7 +253,7 @@ void SocketTask::closeStream() {
if (err && err != boost::asio::error::not_connected) {
LOG_TOPIC(DEBUG, Logger::COMMUNICATION)
<< "SocketTask::CloseStream - shutdown send stream "
<< _peer->nativeHandle() << " failed with: " << err.message();
<< "failed with: " << err.message();
}
_closeRequested = false;
@ -351,8 +346,6 @@ bool SocketTask::trySyncRead() {
}
void SocketTask::asyncReadSome() {
auto info = _peer->nativeHandle();
try {
JobGuard guard(_loop);
guard.enterLoop();
@ -363,7 +356,7 @@ void SocketTask::asyncReadSome() {
while (++n <= MAX_DIRECT_TRIES) {
if (!reserveMemory()) {
LOG_TOPIC(TRACE, Logger::COMMUNICATION)
<< "failed to reserve memory for " << info;
<< "failed to reserve memory";
return;
}
@ -385,7 +378,7 @@ void SocketTask::asyncReadSome() {
if (_closeRequested) {
LOG_TOPIC(DEBUG, Logger::COMMUNICATION)
<< "close requested, closing receive stream " << info;
<< "close requested, closing receive stream ";
closeReceiveStream();
return;
@ -393,14 +386,13 @@ void SocketTask::asyncReadSome() {
}
} catch (boost::system::system_error& err) {
LOG_TOPIC(DEBUG, Logger::COMMUNICATION)
<< "SocketTask::asyncReadSome - i/o stream " << info
<< "SocketTask::asyncReadSome - i/o stream "
<< " failed with: " << err.what();
closeStream();
return;
} catch (...) {
LOG_TOPIC(DEBUG, Logger::COMMUNICATION) << "general error on stream "
<< info;
LOG_TOPIC(DEBUG, Logger::COMMUNICATION) << "general error on stream";
closeStream();
return;
@ -408,18 +400,17 @@ void SocketTask::asyncReadSome() {
// try to read more bytes
if (!reserveMemory()) {
LOG_TOPIC(TRACE, Logger::COMMUNICATION) << "failed to reserve memory for "
<< info;
LOG_TOPIC(TRACE, Logger::COMMUNICATION) << "failed to reserve memory";
return;
}
auto self = shared_from_this();
auto handler = [self, this, info](const boost::system::error_code& ec,
auto handler = [self, this](const boost::system::error_code& ec,
std::size_t transferred) {
if (ec) {
LOG_TOPIC(DEBUG, Logger::COMMUNICATION)
<< "SocketTask::asyncReadSome (async_read_some) - read on stream "
<< info << " failed with: " << ec.message();
<< " failed with: " << ec.message();
closeStream();
} else {
JobGuard guard(_loop);
@ -449,13 +440,11 @@ void SocketTask::asyncReadSome() {
}
void SocketTask::closeReceiveStream() {
auto info = _peer->nativeHandle();
if (!_closedReceive) {
try {
_peer->shutdownReceive();
} catch (boost::system::system_error& err) {
LOG(WARN) << "shutdown receive stream " << info
LOG(WARN) << "shutdown receive stream "
<< " failed with: " << err.what();
}

View File

@ -45,8 +45,6 @@ class SocketTcp: public Socket {
void setNonBlocking(bool v) override { _socket.non_blocking(v); }
boost::asio::serial_port_service::native_handle_type nativeHandle() override { return _socket.native_handle(); }
std::string peerAddress() override { return _peerEndpoint.address().to_string(); }
int peerPort() override { return _peerEndpoint.port(); }

View File

@ -45,8 +45,6 @@ class SocketUnixDomain: public Socket {
void setNonBlocking(bool v) override { _socket.non_blocking(v); }
boost::asio::serial_port_service::native_handle_type nativeHandle() override { return _socket.native_handle(); }
std::string peerAddress() override { return "local"; }
int peerPort() override { return 0; }