mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-09-03 07:25:18 +00:00
[trac742] Log error events
This commit is contained in:
@@ -13,3 +13,23 @@
|
|||||||
# PERFORMANCE OF THIS SOFTWARE.
|
# PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
$NAMESPACE isc::cc
|
$NAMESPACE isc::cc
|
||||||
|
|
||||||
|
% CC_CONN_ERROR error connecting to message queue (%1)
|
||||||
|
|
||||||
|
% CC_NO_MSGQ unable to connect to message queue (%1)
|
||||||
|
|
||||||
|
% CC_WRITE_ERROR error writing data to command channel (%1)
|
||||||
|
|
||||||
|
% CC_LENGTH_NOT_READY length not ready
|
||||||
|
|
||||||
|
% CC_READ_EXCEPTION error reading data from command channel (%1)
|
||||||
|
|
||||||
|
% CC_TIMEOUT timeout reading data from command channel
|
||||||
|
|
||||||
|
% CC_READ_ERROR error reading data from command channel (%1)
|
||||||
|
|
||||||
|
% CC_ZERO_LENGTH invalid message length (0)
|
||||||
|
|
||||||
|
% CC_ASYNC_READ_FAILED asynchronous read failed
|
||||||
|
|
||||||
|
% CC_INVALID_LENGTHS invalid length parameters (%1, %2)
|
||||||
|
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <cc/session_config.h>
|
#include <cc/session_config.h>
|
||||||
|
#include <cc/logger.h>
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
@@ -121,9 +122,11 @@ SessionImpl::establish(const char& socket_file) {
|
|||||||
socket_.connect(asio::local::stream_protocol::endpoint(&socket_file),
|
socket_.connect(asio::local::stream_protocol::endpoint(&socket_file),
|
||||||
error_);
|
error_);
|
||||||
} catch(const asio::system_error& se) {
|
} catch(const asio::system_error& se) {
|
||||||
|
LOG_FATAL(logger, CC_CONN_ERROR).arg(se.what());
|
||||||
isc_throw(SessionError, se.what());
|
isc_throw(SessionError, se.what());
|
||||||
}
|
}
|
||||||
if (error_) {
|
if (error_) {
|
||||||
|
LOG_FATAL(logger, CC_NO_MSGQ).arg(error_.message());
|
||||||
isc_throw(SessionError, "Unable to connect to message queue: " <<
|
isc_throw(SessionError, "Unable to connect to message queue: " <<
|
||||||
error_.message());
|
error_.message());
|
||||||
}
|
}
|
||||||
@@ -140,6 +143,7 @@ SessionImpl::writeData(const void* data, size_t datalen) {
|
|||||||
try {
|
try {
|
||||||
asio::write(socket_, asio::buffer(data, datalen));
|
asio::write(socket_, asio::buffer(data, datalen));
|
||||||
} catch (const asio::system_error& asio_ex) {
|
} 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());
|
isc_throw(SessionError, "ASIO write failed: " << asio_ex.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -151,6 +155,7 @@ SessionImpl::readDataLength() {
|
|||||||
if (ret_len == 0) {
|
if (ret_len == 0) {
|
||||||
readData(&data_length_, sizeof(data_length_));
|
readData(&data_length_, sizeof(data_length_));
|
||||||
if (data_length_ == 0) {
|
if (data_length_ == 0) {
|
||||||
|
LOG_ERROR(logger, CC_LENGTH_NOT_READY);
|
||||||
isc_throw(SessionError, "ASIO read: data length is not ready");
|
isc_throw(SessionError, "ASIO read: data length is not ready");
|
||||||
}
|
}
|
||||||
ret_len = ntohl(data_length_);
|
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
|
// asio::error_code evaluates to false if there was no error
|
||||||
if (*read_result) {
|
if (*read_result) {
|
||||||
if (*read_result == asio::error::operation_aborted) {
|
if (*read_result == asio::error::operation_aborted) {
|
||||||
|
LOG_ERROR(logger, CC_TIMEOUT);
|
||||||
isc_throw(SessionTimeout,
|
isc_throw(SessionTimeout,
|
||||||
"Timeout while reading data from cc session");
|
"Timeout while reading data from cc session");
|
||||||
} else {
|
} else {
|
||||||
|
LOG_ERROR(logger, CC_READ_ERROR).arg(read_result->message());
|
||||||
isc_throw(SessionError,
|
isc_throw(SessionError,
|
||||||
"Error while reading data from cc session: " <<
|
"Error while reading data from cc session: " <<
|
||||||
read_result->message());
|
read_result->message());
|
||||||
@@ -210,6 +217,7 @@ SessionImpl::readData(void* data, size_t datalen) {
|
|||||||
} catch (const asio::system_error& asio_ex) {
|
} catch (const asio::system_error& asio_ex) {
|
||||||
// to hide ASIO specific exceptions, we catch them explicitly
|
// to hide ASIO specific exceptions, we catch them explicitly
|
||||||
// and convert it to SessionError.
|
// and convert it to SessionError.
|
||||||
|
LOG_FATAL(logger, CC_READ_EXCEPTION).arg(asio_ex.what());
|
||||||
isc_throw(SessionError, "ASIO read failed: " << 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_));
|
assert(bytes_transferred == sizeof(data_length_));
|
||||||
data_length_ = ntohl(data_length_);
|
data_length_ = ntohl(data_length_);
|
||||||
if (data_length_ == 0) {
|
if (data_length_ == 0) {
|
||||||
|
LOG_ERROR(logger, CC_ZERO_LENGTH);
|
||||||
isc_throw(SessionError, "Invalid message length (0)");
|
isc_throw(SessionError, "Invalid message length (0)");
|
||||||
}
|
}
|
||||||
user_handler_();
|
user_handler_();
|
||||||
} else {
|
} else {
|
||||||
|
LOG_ERROR(logger, CC_ASYNC_READ_FAILED);
|
||||||
isc_throw(SessionError, "asynchronous 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);
|
unsigned short header_length = ntohs(header_length_net);
|
||||||
if (header_length > length || length < 2) {
|
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
|
isc_throw(SessionError, "Length parameters invalid: total=" << length
|
||||||
<< ", header=" << header_length);
|
<< ", header=" << header_length);
|
||||||
}
|
}
|
||||||
|
@@ -14,9 +14,13 @@
|
|||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <util/unittests/run_all.h>
|
#include <util/unittests/run_all.h>
|
||||||
|
#include <log/logger_support.h>
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char* argv[]) {
|
main(int argc, char* argv[]) {
|
||||||
::testing::InitGoogleTest(&argc, argv);
|
::testing::InitGoogleTest(&argc, argv);
|
||||||
|
|
||||||
|
isc::log::initLogger();
|
||||||
|
|
||||||
return (isc::util::unittests::run_all());
|
return (isc::util::unittests::run_all());
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user