From c3a1e5668e5af72e45d1240661e9de5a8156ee6b Mon Sep 17 00:00:00 2001 From: Marcin Siodelski Date: Mon, 24 Aug 2015 14:25:15 +0200 Subject: [3970] Propagate errors emitted when closing the WatchSocket. --- src/lib/dhcp_ddns/dhcp_ddns_messages.mes | 14 ++++---------- src/lib/dhcp_ddns/ncr_udp.cc | 14 +++++++++++++- src/lib/dhcp_ddns/ncr_udp.h | 7 +++++++ 3 files changed, 24 insertions(+), 11 deletions(-) (limited to 'src/lib/dhcp_ddns') diff --git a/src/lib/dhcp_ddns/dhcp_ddns_messages.mes b/src/lib/dhcp_ddns/dhcp_ddns_messages.mes index fd0091a368..b379d477d5 100644 --- a/src/lib/dhcp_ddns/dhcp_ddns_messages.mes +++ b/src/lib/dhcp_ddns/dhcp_ddns_messages.mes @@ -89,14 +89,8 @@ caught in the application's send completion handler. This is a programmatic error that needs to be reported. Dependent upon the nature of the error the client may or may not continue operating normally. -% DHCP_DDNS_WATCH_SINK_CLOSE_ERROR Sink-side watch socket failed to close: %1 +% DHCP_DDNS_UDP_SENDER_WATCH_SOCKET_CLOSE_ERROR watch socket failed to close: %1 This is an error message that indicates the application was unable to close -the inbound side of a NCR sender's watch socket. While technically possible -this error is highly unlikely to occur and should not impair the application's -ability to process requests. - -% DHCP_DDNS_WATCH_SOURCE_CLOSE_ERROR Source-side watch socket failed to close: %1 -This is an error message that indicates the application was unable to close -the outbound side of a NCR sender's watch socket. While technically possible -this error is highly unlikely to occur and should not impair the application's -ability to process requests. +the inbound or outbound side of a NCR sender's watch socket. While technically +possible the error is highly unlikely to occur and should not impair the +application's ability to process requests. diff --git a/src/lib/dhcp_ddns/ncr_udp.cc b/src/lib/dhcp_ddns/ncr_udp.cc index 683147f04b..28e665f8d6 100644 --- a/src/lib/dhcp_ddns/ncr_udp.cc +++ b/src/lib/dhcp_ddns/ncr_udp.cc @@ -260,6 +260,7 @@ NameChangeUDPSender::open(isc::asiolink::IOService& io_service) { send_callback_->setDataSource(server_endpoint_); + closeWatchSocket(); watch_socket_.reset(new util::WatchSocket()); } @@ -288,6 +289,7 @@ NameChangeUDPSender::close() { socket_.reset(); + closeWatchSocket(); watch_socket_.reset(); } @@ -372,7 +374,17 @@ NameChangeUDPSender::ioReady() { return (false); } - +void +NameChangeUDPSender::closeWatchSocket() { + if (watch_socket_) { + std::string error_string; + watch_socket_->closeSocket(error_string); + if (!error_string.empty()) { + LOG_ERROR(dhcp_ddns_logger, DHCP_DDNS_UDP_SENDER_WATCH_SOCKET_CLOSE_ERROR) + .arg(error_string); + } + } +} }; // end of isc::dhcp_ddns namespace }; // end of isc namespace diff --git a/src/lib/dhcp_ddns/ncr_udp.h b/src/lib/dhcp_ddns/ncr_udp.h index 89646d118c..c927f9220e 100644 --- a/src/lib/dhcp_ddns/ncr_udp.h +++ b/src/lib/dhcp_ddns/ncr_udp.h @@ -548,6 +548,13 @@ public: virtual bool ioReady(); private: + + /// @brief Closes watch socket if the socket is open. + /// + /// This method closes watch socket if its instance exists and if the + /// socket is open. An error message is logged when this operation fails. + void closeWatchSocket(); + /// @brief IP address from which to send. isc::asiolink::IOAddress ip_address_; -- cgit v1.2.3