From: Francis Dupont Date: Wed, 2 Sep 2015 19:15:14 +0000 (+0200) Subject: [4009] error_ and system_code in system (vs asio) namespace X-Git-Tag: trac4060_base~18 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=68e83d82ca5b38908d6b903ea49a8adef88b6336;p=thirdparty%2Fkea.git [4009] error_ and system_code in system (vs asio) namespace --- diff --git a/src/bin/d2/tests/nc_test_utils.cc b/src/bin/d2/tests/nc_test_utils.cc index 3e93425b88..0cb021bb53 100644 --- a/src/bin/d2/tests/nc_test_utils.cc +++ b/src/bin/d2/tests/nc_test_utils.cc @@ -87,7 +87,7 @@ FauxServer::receive (const ResponseMode& response_mode, } void -FauxServer::requestHandler(const boost::asio::error_code& error, +FauxServer::requestHandler(const boost::system::error_code& error, std::size_t bytes_recvd, const ResponseMode& response_mode, const dns::Rcode& response_rcode) { diff --git a/src/bin/d2/tests/nc_test_utils.h b/src/bin/d2/tests/nc_test_utils.h index 9e4057d3fe..b5e5e1b6e5 100644 --- a/src/bin/d2/tests/nc_test_utils.h +++ b/src/bin/d2/tests/nc_test_utils.h @@ -110,7 +110,7 @@ public: /// @param response_mode type of response the handler should produce /// @param response_rcode value of Rcode in the response constructed by /// handler - void requestHandler(const boost::asio::error_code& error, + void requestHandler(const boost::system::error_code& error, std::size_t bytes_recvd, const ResponseMode& response_mode, const dns::Rcode& response_rcode); diff --git a/src/lib/asiodns/README b/src/lib/asiodns/README index 5f44341a93..e47b166638 100644 --- a/src/lib/asiodns/README +++ b/src/lib/asiodns/README @@ -102,7 +102,7 @@ argument the class of the object that will be used as the callback when the asynchronous operation completes. This object can be of any type, but must include an operator() method with the signature: - operator()(boost::asio::error_code ec, size_t length) + operator()(boost::system::error_code ec, size_t length) ... the two arguments being the status of the completed I/O operation and the number of bytes transferred. (In the case of the open method, the second diff --git a/src/lib/asiodns/io_fetch.cc b/src/lib/asiodns/io_fetch.cc index 65192a889a..33ae3c838a 100644 --- a/src/lib/asiodns/io_fetch.cc +++ b/src/lib/asiodns/io_fetch.cc @@ -243,7 +243,7 @@ IOFetch::getProtocol() const { /// pattern; see internal/coroutine.h for details. void -IOFetch::operator()(boost::asio::error_code ec, size_t length) { +IOFetch::operator()(boost::system::error_code ec, size_t length) { if (data_->stopped) { return; @@ -402,7 +402,7 @@ IOFetch::stop(Result result) { // Log an error - called on I/O failure -void IOFetch::logIOFailure(boost::asio::error_code ec) { +void IOFetch::logIOFailure(boost::system::error_code ec) { // Should only get here with a known error code. assert((data_->origin == ASIODNS_OPEN_SOCKET) || diff --git a/src/lib/asiodns/io_fetch.h b/src/lib/asiodns/io_fetch.h index 4b0032b1cb..f95fb0765c 100644 --- a/src/lib/asiodns/io_fetch.h +++ b/src/lib/asiodns/io_fetch.h @@ -189,7 +189,7 @@ public: /// /// \param ec Error code, the result of the last asynchronous I/O operation. /// \param length Amount of data received on the last asynchronous read - void operator()(boost::asio::error_code ec = boost::asio::error_code(), size_t length = 0); + void operator()(boost::system::error_code ec = boost::system::error_code(), size_t length = 0); /// \brief Terminate query /// @@ -215,7 +215,7 @@ private: /// Records an I/O failure to the log file /// /// \param ec ASIO error code - void logIOFailure(boost::asio::error_code ec); + void logIOFailure(boost::system::error_code ec); // Member variables. All data is in a structure pointed to by a shared // pointer. The IOFetch object is copied a number of times during its diff --git a/src/lib/asiodns/tests/io_fetch_unittest.cc b/src/lib/asiodns/tests/io_fetch_unittest.cc index de83b830dc..ba6556f595 100644 --- a/src/lib/asiodns/tests/io_fetch_unittest.cc +++ b/src/lib/asiodns/tests/io_fetch_unittest.cc @@ -176,7 +176,7 @@ public: /// sent with the correct QID. /// \param length Amount of data received. void udpReceiveHandler(udp::endpoint* remote, udp::socket* socket, - boost::asio::error_code ec = boost::asio::error_code(), + boost::system::error_code ec = boost::system::error_code(), size_t length = 0, bool bad_qid = false, bool second_send = false) { @@ -228,7 +228,7 @@ public: /// \param socket Socket on which data will be received /// \param ec Boost error code, value should be zero. void tcpAcceptHandler(tcp::socket* socket, - boost::asio::error_code ec = boost::asio::error_code()) + boost::system::error_code ec = boost::system::error_code()) { if (debug_) { cout << "tcpAcceptHandler(): error = " << ec.value() << endl; @@ -268,7 +268,7 @@ public: /// by the "server" to receive data. /// \param length Amount of data received. void tcpReceiveHandler(tcp::socket* socket, - boost::asio::error_code ec = boost::asio::error_code(), + boost::system::error_code ec = boost::system::error_code(), size_t length = 0) { if (debug_) { @@ -401,7 +401,7 @@ public: /// \param ec Boost error code, value should be zero. /// \param length Number of bytes sent. void tcpSendHandler(size_t expected, tcp::socket* socket, - boost::asio::error_code ec = boost::asio::error_code(), + boost::system::error_code ec = boost::system::error_code(), size_t length = 0) { if (debug_) { diff --git a/src/lib/asiolink/dummy_io_cb.h b/src/lib/asiolink/dummy_io_cb.h index 9b2cb170b8..c1ce5b2b60 100644 --- a/src/lib/asiolink/dummy_io_cb.h +++ b/src/lib/asiolink/dummy_io_cb.h @@ -44,7 +44,7 @@ public: /// Should never be called, as this class is a convenience class provided /// for instances where a socket is required but it is known that no /// asynchronous operations will be carried out. - void operator()(boost::asio::error_code) { + void operator()(boost::system::error_code) { // If the function is called, there is a serious logic error in // the program (this class should not be used as the callback // class). As the asiolink module is too low-level for logging @@ -58,7 +58,7 @@ public: /// Should never be called, as this class is a convenience class provided /// for instances where a socket is required but it is known that no /// asynchronous operations will be carried out. - void operator()(boost::asio::error_code, size_t) { + void operator()(boost::system::error_code, size_t) { // If the function is called, there is a serious logic error in // the program (this class should not be used as the callback // class). As the asiolink module is too low-level for logging diff --git a/src/lib/asiolink/interval_timer.cc b/src/lib/asiolink/interval_timer.cc index 317a61ac03..68f5a791e5 100644 --- a/src/lib/asiolink/interval_timer.cc +++ b/src/lib/asiolink/interval_timer.cc @@ -47,7 +47,7 @@ public: void setup(const IntervalTimer::Callback& cbfunc, const long interval, const IntervalTimer::Mode& interval_mode = IntervalTimer::REPEATING); - void callback(const boost::asio::error_code& error); + void callback(const boost::system::error_code& error); void cancel() { timer_.cancel(); interval_ = 0; @@ -114,7 +114,7 @@ IntervalTimerImpl::update() { timer_.async_wait(boost::bind(&IntervalTimerImpl::callback, shared_from_this(), boost::asio::placeholders::error)); - } catch (const boost::asio::system_error& e) { + } catch (const boost::system::system_error& e) { isc_throw(isc::Unexpected, "Failed to update timer: " << e.what()); } catch (const boost::bad_weak_ptr&) { // Can't happen. It means a severe internal bug. @@ -123,7 +123,7 @@ IntervalTimerImpl::update() { } void -IntervalTimerImpl::callback(const boost::asio::error_code& ec) { +IntervalTimerImpl::callback(const boost::system::error_code& ec) { assert(interval_ != INVALIDATED_INTERVAL); if (interval_ == 0 || ec) { // timer has been canceled. Do nothing. diff --git a/src/lib/asiolink/interval_timer.h b/src/lib/asiolink/interval_timer.h index 40e7a7c27f..e60751636a 100644 --- a/src/lib/asiolink/interval_timer.h +++ b/src/lib/asiolink/interval_timer.h @@ -85,7 +85,7 @@ public: /// /// This constructor may throw a standard exception if /// memory allocation fails inside the method. - /// This constructor may also throw \c boost::asio::system_error. + /// This constructor may also throw \c boost::system::system_error. /// /// \param io_service A reference to an instance of IOService IntervalTimer(IOService& io_service); @@ -111,7 +111,7 @@ public: /// each expiration (the default) or behave as a one-shot which will run /// for a single interval and not reschedule. /// - /// Note: IntervalTimer will not pass \c boost::asio::error_code to + /// Note: IntervalTimer will not pass \c boost::system::error_code to /// call back function. In case the timer is canceled, the function /// will not be called. /// diff --git a/src/lib/asiolink/io_address.cc b/src/lib/asiolink/io_address.cc index 286e69ad94..918c26ae3e 100644 --- a/src/lib/asiolink/io_address.cc +++ b/src/lib/asiolink/io_address.cc @@ -38,7 +38,7 @@ namespace asiolink { // XXX: we cannot simply construct the address in the initialization list, // because we'd like to throw our own exception on failure. IOAddress::IOAddress(const std::string& address_str) { - boost::asio::error_code err; + boost::system::error_code err; asio_address_ = ip::address::from_string(address_str, err); if (err) { isc_throw(IOError, "Failed to convert string to address '" diff --git a/src/lib/asiolink/tests/dummy_io_callback_unittest.cc b/src/lib/asiolink/tests/dummy_io_callback_unittest.cc index e7b7ef2420..22bd4b12a6 100644 --- a/src/lib/asiolink/tests/dummy_io_callback_unittest.cc +++ b/src/lib/asiolink/tests/dummy_io_callback_unittest.cc @@ -26,7 +26,7 @@ namespace { // begin unnamed namespace TEST(DummyIOCallbackTest, throws) { DummyIOCallback cb; - boost::asio::error_code error_code; + boost::system::error_code error_code; // All methods should throw isc::Unexpected. EXPECT_THROW(cb(error_code), isc::Unexpected); diff --git a/src/lib/asiolink/tests/tcp_socket_unittest.cc b/src/lib/asiolink/tests/tcp_socket_unittest.cc index 6a4d4dfe47..80584cee48 100644 --- a/src/lib/asiolink/tests/tcp_socket_unittest.cc +++ b/src/lib/asiolink/tests/tcp_socket_unittest.cc @@ -87,7 +87,7 @@ public: name_(""), queued_(NONE), called_(NONE), data_(MIN_SIZE, 0) {} - boost::asio::error_code error_code_; ///< Completion error code + boost::system::error_code error_code_; ///< Completion error code size_t length_; ///< Bytes transferred in this I/O size_t cumulative_; ///< Cumulative bytes transferred size_t expected_; ///< Expected amount of data @@ -95,7 +95,7 @@ public: std::string name_; ///< Which of the objects this is Operation queued_; ///< Queued operation Operation called_; ///< Which callback called - std::vector data_; ///< Receive buffer + std::vector data_; ///< Receive buffer }; /// \brief Constructor @@ -128,7 +128,7 @@ public: /// /// \param ec I/O completion error code passed to callback function. /// \param length Number of bytes transferred - void operator()(boost::asio::error_code ec = boost::asio::error_code(), + void operator()(boost::system::error_code ec = boost::system::error_code(), size_t length = 0) { setCode(ec.value()); @@ -145,7 +145,7 @@ public: /// /// \param code New value of completion code void setCode(int code) { - ptr_->error_code_ = boost::asio::error_code(code, boost::asio::error_code().category()); + ptr_->error_code_ = boost::system::error_code(code, boost::system::error_code().category()); } /// \brief Get number of bytes transferred in I/O diff --git a/src/lib/asiolink/tests/udp_socket_unittest.cc b/src/lib/asiolink/tests/udp_socket_unittest.cc index 8e72051bf5..04c00ab53b 100644 --- a/src/lib/asiolink/tests/udp_socket_unittest.cc +++ b/src/lib/asiolink/tests/udp_socket_unittest.cc @@ -74,7 +74,7 @@ public: error_code_(), length_(0), called_(false), name_("") {} - boost::asio::error_code error_code_; ///< Completion error code + boost::system::error_code error_code_; ///< Completion error code size_t length_; ///< Number of bytes transferred bool called_; ///< Set true when callback called std::string name_; ///< Which of the objects this is @@ -110,7 +110,7 @@ public: /// /// \param ec I/O completion error code passed to callback function. /// \param length Number of bytes transferred - virtual void operator()(boost::asio::error_code ec, size_t length = 0) { + virtual void operator()(boost::system::error_code ec, size_t length = 0) { ptr_->error_code_ = ec; setLength(length); setCalled(true); @@ -125,7 +125,7 @@ public: /// /// \param code New value of completion code void setCode(int code) { - ptr_->error_code_ = boost::asio::error_code(code, boost::asio::error_code().category()); + ptr_->error_code_ = boost::system::error_code(code, boost::system::error_code().category()); } /// \brief Get number of bytes transferred in I/O diff --git a/src/lib/dhcp/iface_mgr.cc b/src/lib/dhcp/iface_mgr.cc index f9ab91c440..a2dbccae71 100644 --- a/src/lib/dhcp/iface_mgr.cc +++ b/src/lib/dhcp/iface_mgr.cc @@ -798,7 +798,7 @@ IfaceMgr::getLocalAddress(const IOAddress& remote_addr, const uint16_t port) { boost::asio::io_service io_service; boost::asio::ip::udp::socket sock(io_service); - boost::asio::error_code err_code; + boost::system::error_code err_code; // If remote address is broadcast address we have to // allow this on the socket. if (remote_addr.isV4() && diff --git a/src/lib/dhcp_ddns/ncr_udp.cc b/src/lib/dhcp_ddns/ncr_udp.cc index 528c382627..397618a384 100644 --- a/src/lib/dhcp_ddns/ncr_udp.cc +++ b/src/lib/dhcp_ddns/ncr_udp.cc @@ -39,7 +39,7 @@ UDPCallback::UDPCallback (RawBufferPtr& buffer, const size_t buf_size, } void -UDPCallback::operator ()(const boost::asio::error_code error_code, +UDPCallback::operator ()(const boost::system::error_code error_code, const size_t bytes_transferred) { // Save the result state and number of bytes transferred. @@ -112,7 +112,7 @@ NameChangeUDPListener::open(isc::asiolink::IOService& io_service) { // Bind the low level socket to our endpoint. asio_socket_->bind(endpoint.getASIOEndpoint()); - } catch (boost::asio::system_error& ex) { + } catch (boost::system::system_error& ex) { asio_socket_.reset(); isc_throw (NcrUDPError, ex.code().message()); } @@ -142,7 +142,7 @@ NameChangeUDPListener::close() { if (asio_socket_->is_open()) { try { asio_socket_->close(); - } catch (boost::asio::system_error& ex) { + } catch (boost::system::system_error& ex) { // It is really unlikely that this will occur. // If we do reopen later it will be with a new socket // instance. Repackage exception as one that is conformant @@ -180,7 +180,7 @@ NameChangeUDPListener::receiveCompletionHandler(const bool successful, return; } } else { - boost::asio::error_code error_code = callback->getErrorCode(); + boost::system::error_code error_code = callback->getErrorCode(); if (error_code.value() == boost::asio::error::operation_aborted) { // A shutdown cancels all outstanding reads. For this reason, // it can be an expected event, so log it as a debug message. @@ -247,7 +247,7 @@ NameChangeUDPSender::open(isc::asiolink::IOService& io_service) { // Bind the low leve socket to our endpoint. asio_socket_->bind(endpoint.getASIOEndpoint()); - } catch (boost::asio::system_error& ex) { + } catch (boost::system::system_error& ex) { isc_throw (NcrUDPError, ex.code().message()); } @@ -274,7 +274,7 @@ NameChangeUDPSender::close() { if (asio_socket_->is_open()) { try { asio_socket_->close(); - } catch (boost::asio::system_error& ex) { + } catch (boost::system::system_error& ex) { // It is really unlikely that this will occur. // If we do reopen later it will be with a new socket // instance. Repackage exception as one that is conformant @@ -337,7 +337,7 @@ NameChangeUDPSender::sendCompletionHandler(const bool successful, } else { // On a failure, log the error and set the result to ERROR. - boost::asio::error_code error_code = send_callback->getErrorCode(); + boost::system::error_code error_code = send_callback->getErrorCode(); if (error_code.value() == boost::asio::error::operation_aborted) { LOG_ERROR(dhcp_ddns_logger, DHCP_DDNS_NCR_UDP_SEND_CANCELED) .arg(error_code.message()); diff --git a/src/lib/dhcp_ddns/ncr_udp.h b/src/lib/dhcp_ddns/ncr_udp.h index 90eb3a9539..b14afafb3e 100644 --- a/src/lib/dhcp_ddns/ncr_udp.h +++ b/src/lib/dhcp_ddns/ncr_udp.h @@ -56,7 +56,7 @@ /// /// The callback class must provide an operator() with the following signature: /// @code -/// void operator ()(const boost::asio::error_code error_code, +/// void operator ()(const boost::system::error_code error_code, /// const size_t bytes_transferred); /// @endcode /// @@ -190,7 +190,7 @@ public: size_t put_len_; /// @brief Stores the IO layer result code of the completed IO service. - boost::asio::error_code error_code_; + boost::system::error_code error_code_; /// @brief Stores the number of bytes transferred by completed IO /// service. @@ -226,7 +226,7 @@ public: /// For a read it is the number of bytes written into the /// buffer. For a write it is the number of bytes read from the /// buffer. - void operator ()(const boost::asio::error_code error_code, + void operator ()(const boost::system::error_code error_code, const size_t bytes_transferred); /// @brief Returns the number of bytes transferred by the completed IO @@ -247,14 +247,14 @@ public: } /// @brief Returns the completed IO layer service outcome status. - boost::asio::error_code getErrorCode() const { + boost::system::error_code getErrorCode() const { return (data_->error_code_); } /// @brief Sets the completed IO layer service outcome status. /// /// @param value is the new value to assign to outcome status. - void setErrorCode(const boost::asio::error_code value) { + void setErrorCode(const boost::system::error_code value) { data_->error_code_ = value; }