Parcourir la source

[4009] error_ and system_code in system (vs asio) namespace

Francis Dupont il y a 9 ans
Parent
commit
68e83d82ca

+ 1 - 1
src/bin/d2/tests/nc_test_utils.cc

@@ -87,7 +87,7 @@ FauxServer::receive (const ResponseMode& response_mode,
 }
 }
 
 
 void
 void
-FauxServer::requestHandler(const boost::asio::error_code& error,
+FauxServer::requestHandler(const boost::system::error_code& error,
                            std::size_t bytes_recvd,
                            std::size_t bytes_recvd,
                            const ResponseMode& response_mode,
                            const ResponseMode& response_mode,
                            const dns::Rcode& response_rcode) {
                            const dns::Rcode& response_rcode) {

+ 1 - 1
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_mode type of response the handler should produce
     /// @param response_rcode value of Rcode in the response constructed by
     /// @param response_rcode value of Rcode in the response constructed by
     /// handler
     /// handler
-    void requestHandler(const boost::asio::error_code& error,
+    void requestHandler(const boost::system::error_code& error,
                         std::size_t bytes_recvd,
                         std::size_t bytes_recvd,
                         const ResponseMode& response_mode,
                         const ResponseMode& response_mode,
                         const dns::Rcode& response_rcode);
                         const dns::Rcode& response_rcode);

+ 1 - 1
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
 asynchronous operation completes. This object can be of any type, but must
 include an operator() method with the signature:
 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 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
 the number of bytes transferred. (In the case of the open method, the second

+ 2 - 2
src/lib/asiodns/io_fetch.cc

@@ -243,7 +243,7 @@ IOFetch::getProtocol() const {
 /// pattern; see internal/coroutine.h for details.
 /// pattern; see internal/coroutine.h for details.
 
 
 void
 void
-IOFetch::operator()(boost::asio::error_code ec, size_t length) {
+IOFetch::operator()(boost::system::error_code ec, size_t length) {
 
 
     if (data_->stopped) {
     if (data_->stopped) {
         return;
         return;
@@ -402,7 +402,7 @@ IOFetch::stop(Result result) {
 
 
 // Log an error - called on I/O failure
 // 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.
     // Should only get here with a known error code.
     assert((data_->origin == ASIODNS_OPEN_SOCKET) ||
     assert((data_->origin == ASIODNS_OPEN_SOCKET) ||

+ 2 - 2
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 ec Error code, the result of the last asynchronous I/O operation.
     /// \param length Amount of data received on the last asynchronous read
     /// \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
     /// \brief Terminate query
     ///
     ///
@@ -215,7 +215,7 @@ private:
     /// Records an I/O failure to the log file
     /// Records an I/O failure to the log file
     ///
     ///
     /// \param ec ASIO error code
     /// \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
     // 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
     // pointer.  The IOFetch object is copied a number of times during its

+ 4 - 4
src/lib/asiodns/tests/io_fetch_unittest.cc

@@ -176,7 +176,7 @@ public:
     ///        sent with the correct QID.
     ///        sent with the correct QID.
     /// \param length Amount of data received.
     /// \param length Amount of data received.
     void udpReceiveHandler(udp::endpoint* remote, udp::socket* socket,
     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,
                            size_t length = 0, bool bad_qid = false,
                            bool second_send = false)
                            bool second_send = false)
     {
     {
@@ -228,7 +228,7 @@ public:
     /// \param socket Socket on which data will be received
     /// \param socket Socket on which data will be received
     /// \param ec Boost error code, value should be zero.
     /// \param ec Boost error code, value should be zero.
     void tcpAcceptHandler(tcp::socket* socket,
     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_) {
         if (debug_) {
             cout << "tcpAcceptHandler(): error = " << ec.value() << endl;
             cout << "tcpAcceptHandler(): error = " << ec.value() << endl;
@@ -268,7 +268,7 @@ public:
     ///        by the "server" to receive data.
     ///        by the "server" to receive data.
     /// \param length Amount of data received.
     /// \param length Amount of data received.
     void tcpReceiveHandler(tcp::socket* socket,
     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)
                            size_t length = 0)
     {
     {
         if (debug_) {
         if (debug_) {
@@ -401,7 +401,7 @@ public:
     /// \param ec Boost error code, value should be zero.
     /// \param ec Boost error code, value should be zero.
     /// \param length Number of bytes sent.
     /// \param length Number of bytes sent.
     void tcpSendHandler(size_t expected, tcp::socket* socket,
     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)
                         size_t length = 0)
     {
     {
         if (debug_) {
         if (debug_) {

+ 2 - 2
src/lib/asiolink/dummy_io_cb.h

@@ -44,7 +44,7 @@ public:
     /// Should never be called, as this class is a convenience class provided
     /// 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
     /// for instances where a socket is required but it is known that no
     /// asynchronous operations will be carried out.
     /// 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
         // If the function is called, there is a serious logic error in
         // the program (this class should not be used as the callback
         // the program (this class should not be used as the callback
         // class).  As the asiolink module is too low-level for logging
         // 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
     /// 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
     /// for instances where a socket is required but it is known that no
     /// asynchronous operations will be carried out.
     /// 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
         // If the function is called, there is a serious logic error in
         // the program (this class should not be used as the callback
         // the program (this class should not be used as the callback
         // class).  As the asiolink module is too low-level for logging
         // class).  As the asiolink module is too low-level for logging

+ 3 - 3
src/lib/asiolink/interval_timer.cc

@@ -47,7 +47,7 @@ public:
     void setup(const IntervalTimer::Callback& cbfunc, const long interval,
     void setup(const IntervalTimer::Callback& cbfunc, const long interval,
                const IntervalTimer::Mode& interval_mode
                const IntervalTimer::Mode& interval_mode
                = IntervalTimer::REPEATING);
                = IntervalTimer::REPEATING);
-    void callback(const boost::asio::error_code& error);
+    void callback(const boost::system::error_code& error);
     void cancel() {
     void cancel() {
         timer_.cancel();
         timer_.cancel();
         interval_ = 0;
         interval_ = 0;
@@ -114,7 +114,7 @@ IntervalTimerImpl::update() {
         timer_.async_wait(boost::bind(&IntervalTimerImpl::callback,
         timer_.async_wait(boost::bind(&IntervalTimerImpl::callback,
                                       shared_from_this(),
                                       shared_from_this(),
                                       boost::asio::placeholders::error));
                                       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());
         isc_throw(isc::Unexpected, "Failed to update timer: " << e.what());
     } catch (const boost::bad_weak_ptr&) {
     } catch (const boost::bad_weak_ptr&) {
         // Can't happen. It means a severe internal bug.
         // Can't happen. It means a severe internal bug.
@@ -123,7 +123,7 @@ IntervalTimerImpl::update() {
 }
 }
 
 
 void
 void
-IntervalTimerImpl::callback(const boost::asio::error_code& ec) {
+IntervalTimerImpl::callback(const boost::system::error_code& ec) {
     assert(interval_ != INVALIDATED_INTERVAL);
     assert(interval_ != INVALIDATED_INTERVAL);
     if (interval_ == 0 || ec) {
     if (interval_ == 0 || ec) {
         // timer has been canceled. Do nothing.
         // timer has been canceled. Do nothing.

+ 2 - 2
src/lib/asiolink/interval_timer.h

@@ -85,7 +85,7 @@ public:
     ///
     ///
     /// This constructor may throw a standard exception if
     /// This constructor may throw a standard exception if
     /// memory allocation fails inside the method.
     /// 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
     /// \param io_service A reference to an instance of IOService
     IntervalTimer(IOService& io_service);
     IntervalTimer(IOService& io_service);
@@ -111,7 +111,7 @@ public:
     /// each expiration (the default) or behave as a one-shot which will run
     /// each expiration (the default) or behave as a one-shot which will run
     /// for a single interval and not reschedule.
     /// 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
     /// call back function. In case the timer is canceled, the function
     /// will not be called.
     /// will not be called.
     ///
     ///

+ 1 - 1
src/lib/asiolink/io_address.cc

@@ -38,7 +38,7 @@ namespace asiolink {
 // XXX: we cannot simply construct the address in the initialization list,
 // XXX: we cannot simply construct the address in the initialization list,
 // because we'd like to throw our own exception on failure.
 // because we'd like to throw our own exception on failure.
 IOAddress::IOAddress(const std::string& address_str) {
 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);
     asio_address_ = ip::address::from_string(address_str, err);
     if (err) {
     if (err) {
         isc_throw(IOError, "Failed to convert string to address '"
         isc_throw(IOError, "Failed to convert string to address '"

+ 1 - 1
src/lib/asiolink/tests/dummy_io_callback_unittest.cc

@@ -26,7 +26,7 @@ namespace { // begin unnamed namespace
 
 
 TEST(DummyIOCallbackTest, throws) {
 TEST(DummyIOCallbackTest, throws) {
     DummyIOCallback cb;
     DummyIOCallback cb;
-    boost::asio::error_code error_code;
+    boost::system::error_code error_code;
 
 
     // All methods should throw isc::Unexpected.
     // All methods should throw isc::Unexpected.
     EXPECT_THROW(cb(error_code), isc::Unexpected);
     EXPECT_THROW(cb(error_code), isc::Unexpected);

+ 4 - 4
src/lib/asiolink/tests/tcp_socket_unittest.cc

@@ -87,7 +87,7 @@ public:
             name_(""), queued_(NONE), called_(NONE), data_(MIN_SIZE, 0)
             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                     length_;        ///< Bytes transferred in this I/O
         size_t                     cumulative_;    ///< Cumulative bytes transferred
         size_t                     cumulative_;    ///< Cumulative bytes transferred
         size_t                     expected_;      ///< Expected amount of data
         size_t                     expected_;      ///< Expected amount of data
@@ -95,7 +95,7 @@ public:
         std::string                name_;          ///< Which of the objects this is
         std::string                name_;          ///< Which of the objects this is
         Operation                  queued_;        ///< Queued operation
         Operation                  queued_;        ///< Queued operation
         Operation                  called_;        ///< Which callback called
         Operation                  called_;        ///< Which callback called
-        std::vector<uint8_t>        data_;         ///< Receive buffer
+        std::vector<uint8_t>       data_;          ///< Receive buffer
     };
     };
 
 
     /// \brief Constructor
     /// \brief Constructor
@@ -128,7 +128,7 @@ public:
     ///
     ///
     /// \param ec I/O completion error code passed to callback function.
     /// \param ec I/O completion error code passed to callback function.
     /// \param length Number of bytes transferred
     /// \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)
                             size_t length = 0)
     {
     {
         setCode(ec.value());
         setCode(ec.value());
@@ -145,7 +145,7 @@ public:
     ///
     ///
     /// \param code New value of completion code
     /// \param code New value of completion code
     void setCode(int 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
     /// \brief Get number of bytes transferred in I/O

+ 3 - 3
src/lib/asiolink/tests/udp_socket_unittest.cc

@@ -74,7 +74,7 @@ public:
             error_code_(), length_(0), called_(false), name_("")
             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
         size_t                     length_;        ///< Number of bytes transferred
         bool                       called_;        ///< Set true when callback called
         bool                       called_;        ///< Set true when callback called
         std::string                name_;          ///< Which of the objects this is
         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 ec I/O completion error code passed to callback function.
     /// \param length Number of bytes transferred
     /// \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;
         ptr_->error_code_ = ec;
         setLength(length);
         setLength(length);
         setCalled(true);
         setCalled(true);
@@ -125,7 +125,7 @@ public:
     ///
     ///
     /// \param code New value of completion code
     /// \param code New value of completion code
     void setCode(int 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
     /// \brief Get number of bytes transferred in I/O

+ 1 - 1
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::io_service io_service;
     boost::asio::ip::udp::socket sock(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
     // If remote address is broadcast address we have to
     // allow this on the socket.
     // allow this on the socket.
     if (remote_addr.isV4() &&
     if (remote_addr.isV4() &&

+ 7 - 7
src/lib/dhcp_ddns/ncr_udp.cc

@@ -39,7 +39,7 @@ UDPCallback::UDPCallback (RawBufferPtr& buffer, const size_t buf_size,
 }
 }
 
 
 void
 void
-UDPCallback::operator ()(const boost::asio::error_code error_code,
+UDPCallback::operator ()(const boost::system::error_code error_code,
                          const size_t bytes_transferred) {
                          const size_t bytes_transferred) {
 
 
     // Save the result state and number of 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.
         // Bind the low level socket to our endpoint.
         asio_socket_->bind(endpoint.getASIOEndpoint());
         asio_socket_->bind(endpoint.getASIOEndpoint());
-    } catch (boost::asio::system_error& ex) {
+    } catch (boost::system::system_error& ex) {
         asio_socket_.reset();
         asio_socket_.reset();
         isc_throw (NcrUDPError, ex.code().message());
         isc_throw (NcrUDPError, ex.code().message());
     }
     }
@@ -142,7 +142,7 @@ NameChangeUDPListener::close() {
         if (asio_socket_->is_open()) {
         if (asio_socket_->is_open()) {
             try {
             try {
                 asio_socket_->close();
                 asio_socket_->close();
-            } catch (boost::asio::system_error& ex) {
+            } catch (boost::system::system_error& ex) {
                 // It is really unlikely that this will occur.
                 // It is really unlikely that this will occur.
                 // If we do reopen later it will be with a new socket
                 // If we do reopen later it will be with a new socket
                 // instance. Repackage exception as one that is conformant
                 // instance. Repackage exception as one that is conformant
@@ -180,7 +180,7 @@ NameChangeUDPListener::receiveCompletionHandler(const bool successful,
             return;
             return;
         }
         }
     } else {
     } 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) {
         if (error_code.value() == boost::asio::error::operation_aborted) {
             // A shutdown cancels all outstanding reads.  For this reason,
             // A shutdown cancels all outstanding reads.  For this reason,
             // it can be an expected event, so log it as a debug message.
             // 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.
         // Bind the low leve socket to our endpoint.
         asio_socket_->bind(endpoint.getASIOEndpoint());
         asio_socket_->bind(endpoint.getASIOEndpoint());
-    } catch (boost::asio::system_error& ex) {
+    } catch (boost::system::system_error& ex) {
         isc_throw (NcrUDPError, ex.code().message());
         isc_throw (NcrUDPError, ex.code().message());
     }
     }
 
 
@@ -274,7 +274,7 @@ NameChangeUDPSender::close() {
         if (asio_socket_->is_open()) {
         if (asio_socket_->is_open()) {
             try {
             try {
                 asio_socket_->close();
                 asio_socket_->close();
-            } catch (boost::asio::system_error& ex) {
+            } catch (boost::system::system_error& ex) {
                 // It is really unlikely that this will occur.
                 // It is really unlikely that this will occur.
                 // If we do reopen later it will be with a new socket
                 // If we do reopen later it will be with a new socket
                 // instance. Repackage exception as one that is conformant
                 // instance. Repackage exception as one that is conformant
@@ -337,7 +337,7 @@ NameChangeUDPSender::sendCompletionHandler(const bool successful,
     }
     }
     else {
     else {
         // On a failure, log the error and set the result to ERROR.
         // 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) {
         if (error_code.value() == boost::asio::error::operation_aborted) {
             LOG_ERROR(dhcp_ddns_logger, DHCP_DDNS_NCR_UDP_SEND_CANCELED)
             LOG_ERROR(dhcp_ddns_logger, DHCP_DDNS_NCR_UDP_SEND_CANCELED)
                       .arg(error_code.message());
                       .arg(error_code.message());

+ 5 - 5
src/lib/dhcp_ddns/ncr_udp.h

@@ -56,7 +56,7 @@
 ///
 ///
 /// The callback class must provide an operator() with the following signature:
 /// The callback class must provide an operator() with the following signature:
 /// @code
 /// @code
-///    void operator ()(const boost::asio::error_code error_code,
+///    void operator ()(const boost::system::error_code error_code,
 ///                     const size_t bytes_transferred);
 ///                     const size_t bytes_transferred);
 /// @endcode
 /// @endcode
 ///
 ///
@@ -190,7 +190,7 @@ public:
         size_t put_len_;
         size_t put_len_;
 
 
         /// @brief Stores the IO layer result code of the completed IO service.
         /// @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
         /// @brief Stores the number of bytes transferred by completed IO
         /// service.
         /// service.
@@ -226,7 +226,7 @@ public:
     /// For a read it is the number of bytes written into the
     /// 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.  For a write it is the number of bytes read from the
     /// buffer.
     /// buffer.
-    void operator ()(const boost::asio::error_code error_code,
+    void operator ()(const boost::system::error_code error_code,
                      const size_t bytes_transferred);
                      const size_t bytes_transferred);
 
 
     /// @brief Returns the number of bytes transferred by the completed IO
     /// @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.
     /// @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_);
         return (data_->error_code_);
     }
     }
 
 
     /// @brief Sets the completed IO layer service outcome status.
     /// @brief Sets the completed IO layer service outcome status.
     ///
     ///
     /// @param value is the new value to assign to 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;
         data_->error_code_  = value;
     }
     }