|
@@ -14,6 +14,7 @@
|
|
|
|
|
|
#include <config.h>
|
|
|
#include <cc/session_config.h>
|
|
|
+#include <cc/logger.h>
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
@@ -121,9 +122,11 @@ SessionImpl::establish(const char& socket_file) {
|
|
|
socket_.connect(asio::local::stream_protocol::endpoint(&socket_file),
|
|
|
error_);
|
|
|
} catch(const asio::system_error& se) {
|
|
|
+ LOG_FATAL(logger, CC_CONN_ERROR).arg(se.what());
|
|
|
isc_throw(SessionError, se.what());
|
|
|
}
|
|
|
if (error_) {
|
|
|
+ LOG_FATAL(logger, CC_NO_MSGQ).arg(error_.message());
|
|
|
isc_throw(SessionError, "Unable to connect to message queue: " <<
|
|
|
error_.message());
|
|
|
}
|
|
@@ -140,6 +143,7 @@ SessionImpl::writeData(const void* data, size_t datalen) {
|
|
|
try {
|
|
|
asio::write(socket_, asio::buffer(data, datalen));
|
|
|
} catch (const asio::system_error& asio_ex) {
|
|
|
+ LOG_FATAL(logger, CC_WRITE_ERROR).arg(asio_ex.what());
|
|
|
isc_throw(SessionError, "ASIO write failed: " << asio_ex.what());
|
|
|
}
|
|
|
}
|
|
@@ -151,6 +155,7 @@ SessionImpl::readDataLength() {
|
|
|
if (ret_len == 0) {
|
|
|
readData(&data_length_, sizeof(data_length_));
|
|
|
if (data_length_ == 0) {
|
|
|
+ LOG_ERROR(logger, CC_LENGTH_NOT_READY);
|
|
|
isc_throw(SessionError, "ASIO read: data length is not ready");
|
|
|
}
|
|
|
ret_len = ntohl(data_length_);
|
|
@@ -199,9 +204,11 @@ SessionImpl::readData(void* data, size_t datalen) {
|
|
|
// asio::error_code evaluates to false if there was no error
|
|
|
if (*read_result) {
|
|
|
if (*read_result == asio::error::operation_aborted) {
|
|
|
+ LOG_ERROR(logger, CC_TIMEOUT);
|
|
|
isc_throw(SessionTimeout,
|
|
|
"Timeout while reading data from cc session");
|
|
|
} else {
|
|
|
+ LOG_ERROR(logger, CC_READ_ERROR).arg(read_result->message());
|
|
|
isc_throw(SessionError,
|
|
|
"Error while reading data from cc session: " <<
|
|
|
read_result->message());
|
|
@@ -210,6 +217,7 @@ SessionImpl::readData(void* data, size_t datalen) {
|
|
|
} catch (const asio::system_error& asio_ex) {
|
|
|
// to hide ASIO specific exceptions, we catch them explicitly
|
|
|
// and convert it to SessionError.
|
|
|
+ LOG_FATAL(logger, CC_READ_EXCEPTION).arg(asio_ex.what());
|
|
|
isc_throw(SessionError, "ASIO read failed: " << asio_ex.what());
|
|
|
}
|
|
|
}
|
|
@@ -233,10 +241,12 @@ SessionImpl::internalRead(const asio::error_code& error,
|
|
|
assert(bytes_transferred == sizeof(data_length_));
|
|
|
data_length_ = ntohl(data_length_);
|
|
|
if (data_length_ == 0) {
|
|
|
+ LOG_ERROR(logger, CC_ZERO_LENGTH);
|
|
|
isc_throw(SessionError, "Invalid message length (0)");
|
|
|
}
|
|
|
user_handler_();
|
|
|
} else {
|
|
|
+ LOG_ERROR(logger, CC_ASYNC_READ_FAILED);
|
|
|
isc_throw(SessionError, "asynchronous read failed");
|
|
|
}
|
|
|
}
|
|
@@ -374,6 +384,7 @@ Session::recvmsg(ConstElementPtr& env, ConstElementPtr& msg,
|
|
|
|
|
|
unsigned short header_length = ntohs(header_length_net);
|
|
|
if (header_length > length || length < 2) {
|
|
|
+ LOG_ERROR(logger, CC_INVALID_LENGTHS).arg(length).arg(header_length);
|
|
|
isc_throw(SessionError, "Length parameters invalid: total=" << length
|
|
|
<< ", header=" << header_length);
|
|
|
}
|