From: JINMEI Tatuya Date: Fri, 30 Dec 2011 09:09:01 +0000 (-0800) Subject: [1522] added some logging messages for the socket requestor. X-Git-Tag: trac2351_base~304^2~15^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=199ebdc9c9db2f7744bfc50f0b13eec40eeed5ed;p=thirdparty%2Fkea.git [1522] added some logging messages for the socket requestor. --- diff --git a/src/lib/server_common/server_common_messages.mes b/src/lib/server_common/server_common_messages.mes index 5fbbb0ba58..ababa08f02 100644 --- a/src/lib/server_common/server_common_messages.mes +++ b/src/lib/server_common/server_common_messages.mes @@ -71,3 +71,28 @@ specification is outside the valid range of 0 to 65535. % SRVCOMM_SET_LISTEN setting addresses to listen to Debug message, noting that the server is about to start listening on a different set of IP addresses and ports than before. + +% SOCKETREQUESTOR_CREATED Socket requestor created +Debug message. A socket requesor (client of the socket creator) is created +for the corresponding application. Normally this should happen at most +one time throughout the lifetime of the application. + +% SOCKETREQUESTOR_DESTROYED Socket requestor destoryed +Debug message. The socket requestor created at SOCKETREQUESTOR_CREATED +has been destroyed. This event is generally unexpected other than in +test cases. + +% SOCKETREQUESTOR_GETSOCKET Received a %1 socket for [%2]:%3, FD=%4, token=%5, path=%6 +Debug message. The socket requestor for the corresponding application +has requested a socket for a set of address, port and protocol (shown +in the log message) and successfully got it from the creator. The +corresponding file descriptor and the associated "token" (an internal +ID used between the creator and requestor) are shown in the log +message. + +% SOCKETREQUESTOR_RELEASESOCKET Released a socket of token %1 +Debug message. The socket requestor has released a socket passed by +the creator. The associated token of the socket is shown in the +log message. If the corresponding SOCKETREQUESTOR_GETSOCKET was logged +more detailed information of the socket can be identified by matching +the token. diff --git a/src/lib/server_common/socket_request.cc b/src/lib/server_common/socket_request.cc index 8f85334aec..cdbcf3b60b 100644 --- a/src/lib/server_common/socket_request.cc +++ b/src/lib/server_common/socket_request.cc @@ -14,6 +14,7 @@ #include #include "socket_request.h" +#include #include #include @@ -230,6 +231,20 @@ getSocketFd(const std::string& token, int sock_pass_fd) { return (passed_sock_fd); } +namespace { +inline const char* +protocolString(SocketRequestor::Protocol protocol) { + switch (protocol) { + case SocketRequestor::TCP: + return ("TCP"); + case SocketRequestor::UDP: + return ("UDP"); + default: + return ("unknown protocol"); + } +} +} + // This implementation class for SocketRequestor uses // a ModuleCCSession for communication with the boss process, // and fd_share to read out the socket(s). @@ -251,10 +266,12 @@ public: isc_throw(Unexpected, "Failed to filter SIGPIPE: " << strerror(errno)); } + LOG_DEBUG(logger, DBGLVL_TRACE_BASIC, SOCKETREQUESTOR_CREATED); } ~SocketRequestorCCSession() { closeFdShareSockets(); + LOG_DEBUG(logger, DBGLVL_TRACE_BASIC, SOCKETREQUESTOR_DESTROYED); } virtual SocketID requestSocket(Protocol protocol, @@ -286,6 +303,9 @@ public: // and finally get the socket itself const int passed_sock_fd = getSocketFd(token, sock_pass_fd); + LOG_DEBUG(logger, DBGLVL_TRACE_DETAIL, SOCKETREQUESTOR_GETSOCKET). + arg(protocolString(protocol)).arg(address).arg(port). + arg(passed_sock_fd).arg(token).arg(path); return (SocketID(passed_sock_fd, token)); } @@ -295,6 +315,8 @@ public: // Send it to boss const int seq = session_.groupSendMsg(release_msg, "Boss"); + LOG_DEBUG(logger, DBGLVL_TRACE_DETAIL, SOCKETREQUESTOR_RELEASESOCKET). + arg(token); // Get the answer from the boss. // Just do a blocking read, we can't really do much anyway