mirror of
https://github.com/boostorg/asio.git
synced 2026-02-14 12:02:07 +00:00
Use enum-based error code constants.
[SVN r39189]
This commit is contained in:
@@ -158,7 +158,8 @@ public:
|
||||
int result = epoll_ctl(epoll_fd_, EPOLL_CTL_MOD, descriptor, &ev);
|
||||
if (result != 0)
|
||||
{
|
||||
boost::system::error_code ec(errno, boost::system::native_ecat);
|
||||
boost::system::error_code ec(errno,
|
||||
boost::asio::error::system_category);
|
||||
read_op_queue_.dispatch_all_operations(descriptor, ec);
|
||||
}
|
||||
}
|
||||
@@ -191,7 +192,8 @@ public:
|
||||
int result = epoll_ctl(epoll_fd_, EPOLL_CTL_MOD, descriptor, &ev);
|
||||
if (result != 0)
|
||||
{
|
||||
boost::system::error_code ec(errno, boost::system::native_ecat);
|
||||
boost::system::error_code ec(errno,
|
||||
boost::asio::error::system_category);
|
||||
write_op_queue_.dispatch_all_operations(descriptor, ec);
|
||||
}
|
||||
}
|
||||
@@ -220,7 +222,8 @@ public:
|
||||
int result = epoll_ctl(epoll_fd_, EPOLL_CTL_MOD, descriptor, &ev);
|
||||
if (result != 0)
|
||||
{
|
||||
boost::system::error_code ec(errno, boost::system::native_ecat);
|
||||
boost::system::error_code ec(errno,
|
||||
boost::asio::error::system_category);
|
||||
except_op_queue_.dispatch_all_operations(descriptor, ec);
|
||||
}
|
||||
}
|
||||
@@ -251,7 +254,8 @@ public:
|
||||
int result = epoll_ctl(epoll_fd_, EPOLL_CTL_MOD, descriptor, &ev);
|
||||
if (result != 0)
|
||||
{
|
||||
boost::system::error_code ec(errno, boost::system::native_ecat);
|
||||
boost::system::error_code ec(errno,
|
||||
boost::asio::error::system_category);
|
||||
write_op_queue_.dispatch_all_operations(descriptor, ec);
|
||||
except_op_queue_.dispatch_all_operations(descriptor, ec);
|
||||
}
|
||||
@@ -428,7 +432,8 @@ private:
|
||||
int result = epoll_ctl(epoll_fd_, EPOLL_CTL_MOD, descriptor, &ev);
|
||||
if (result != 0)
|
||||
{
|
||||
ec = boost::system::error_code(errno, boost::system::native_ecat);
|
||||
ec = boost::system::error_code(errno,
|
||||
boost::asio::error::system_category);
|
||||
read_op_queue_.dispatch_all_operations(descriptor, ec);
|
||||
write_op_queue_.dispatch_all_operations(descriptor, ec);
|
||||
except_op_queue_.dispatch_all_operations(descriptor, ec);
|
||||
@@ -486,8 +491,10 @@ private:
|
||||
int fd = epoll_create(epoll_size);
|
||||
if (fd == -1)
|
||||
{
|
||||
boost::throw_exception(boost::system::system_error(
|
||||
boost::system::error_code(errno, boost::system::native_ecat),
|
||||
boost::throw_exception(
|
||||
boost::system::system_error(
|
||||
boost::system::error_code(errno,
|
||||
boost::asio::error::system_category),
|
||||
"epoll"));
|
||||
}
|
||||
return fd;
|
||||
|
||||
@@ -151,7 +151,8 @@ public:
|
||||
EV_SET(&event, descriptor, EVFILT_READ, EV_ADD, 0, 0, 0);
|
||||
if (::kevent(kqueue_fd_, &event, 1, 0, 0, 0) == -1)
|
||||
{
|
||||
boost::system::error_code ec(errno, boost::system::native_ecat);
|
||||
boost::system::error_code ec(errno,
|
||||
boost::asio::error::system_category);
|
||||
read_op_queue_.dispatch_all_operations(descriptor, ec);
|
||||
}
|
||||
}
|
||||
@@ -177,7 +178,8 @@ public:
|
||||
EV_SET(&event, descriptor, EVFILT_WRITE, EV_ADD, 0, 0, 0);
|
||||
if (::kevent(kqueue_fd_, &event, 1, 0, 0, 0) == -1)
|
||||
{
|
||||
boost::system::error_code ec(errno, boost::system::native_ecat);
|
||||
boost::system::error_code ec(errno,
|
||||
boost::asio::error::system_category);
|
||||
write_op_queue_.dispatch_all_operations(descriptor, ec);
|
||||
}
|
||||
}
|
||||
@@ -202,7 +204,8 @@ public:
|
||||
EV_SET(&event, descriptor, EVFILT_READ, EV_ADD, EV_OOBAND, 0, 0);
|
||||
if (::kevent(kqueue_fd_, &event, 1, 0, 0, 0) == -1)
|
||||
{
|
||||
boost::system::error_code ec(errno, boost::system::native_ecat);
|
||||
boost::system::error_code ec(errno,
|
||||
boost::asio::error::system_category);
|
||||
except_op_queue_.dispatch_all_operations(descriptor, ec);
|
||||
}
|
||||
}
|
||||
@@ -225,7 +228,8 @@ public:
|
||||
EV_SET(&event, descriptor, EVFILT_WRITE, EV_ADD, 0, 0, 0);
|
||||
if (::kevent(kqueue_fd_, &event, 1, 0, 0, 0) == -1)
|
||||
{
|
||||
boost::system::error_code ec(errno, boost::system::native_ecat);
|
||||
boost::system::error_code ec(errno,
|
||||
boost::asio::error::system_category);
|
||||
write_op_queue_.dispatch_all_operations(descriptor, ec);
|
||||
}
|
||||
}
|
||||
@@ -239,7 +243,8 @@ public:
|
||||
EV_SET(&event, descriptor, EVFILT_READ, EV_ADD, EV_OOBAND, 0, 0);
|
||||
if (::kevent(kqueue_fd_, &event, 1, 0, 0, 0) == -1)
|
||||
{
|
||||
boost::system::error_code ec(errno, boost::system::native_ecat);
|
||||
boost::system::error_code ec(errno,
|
||||
boost::asio::error::system_category);
|
||||
except_op_queue_.dispatch_all_operations(descriptor, ec);
|
||||
write_op_queue_.dispatch_all_operations(descriptor, ec);
|
||||
}
|
||||
@@ -393,7 +398,7 @@ private:
|
||||
if (events[i].flags & EV_ERROR)
|
||||
{
|
||||
boost::system::error_code error(
|
||||
events[i].data, boost::system::native_ecat);
|
||||
events[i].data, boost::asio::error::system_category);
|
||||
except_op_queue_.dispatch_all_operations(descriptor, error);
|
||||
read_op_queue_.dispatch_all_operations(descriptor, error);
|
||||
}
|
||||
@@ -423,7 +428,8 @@ private:
|
||||
EV_SET(&event, descriptor, EVFILT_READ, EV_DELETE, 0, 0, 0);
|
||||
if (::kevent(kqueue_fd_, &event, 1, 0, 0, 0) == -1)
|
||||
{
|
||||
boost::system::error_code error(errno, boost::system::native_ecat);
|
||||
boost::system::error_code error(errno,
|
||||
boost::asio::error::system_category);
|
||||
except_op_queue_.dispatch_all_operations(descriptor, error);
|
||||
read_op_queue_.dispatch_all_operations(descriptor, error);
|
||||
}
|
||||
@@ -435,7 +441,7 @@ private:
|
||||
if (events[i].flags & EV_ERROR)
|
||||
{
|
||||
boost::system::error_code error(
|
||||
events[i].data, boost::system::native_ecat);
|
||||
events[i].data, boost::asio::error::system_category);
|
||||
write_op_queue_.dispatch_all_operations(descriptor, error);
|
||||
}
|
||||
else
|
||||
@@ -452,7 +458,8 @@ private:
|
||||
EV_SET(&event, descriptor, EVFILT_WRITE, EV_DELETE, 0, 0, 0);
|
||||
if (::kevent(kqueue_fd_, &event, 1, 0, 0, 0) == -1)
|
||||
{
|
||||
boost::system::error_code error(errno, boost::system::native_ecat);
|
||||
boost::system::error_code error(errno,
|
||||
boost::asio::error::system_category);
|
||||
write_op_queue_.dispatch_all_operations(descriptor, error);
|
||||
}
|
||||
}
|
||||
@@ -506,8 +513,10 @@ private:
|
||||
int fd = kqueue();
|
||||
if (fd == -1)
|
||||
{
|
||||
boost::throw_exception(boost::system::system_error(
|
||||
boost::system::error_code(errno, boost::system::native_ecat),
|
||||
boost::throw_exception(
|
||||
boost::system::system_error(
|
||||
boost::system::error_code(errno,
|
||||
boost::asio::error::system_category),
|
||||
"kqueue"));
|
||||
}
|
||||
return fd;
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <pthread.h>
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#include <boost/asio/error.hpp>
|
||||
#include <boost/asio/detail/noncopyable.hpp>
|
||||
|
||||
namespace boost {
|
||||
@@ -48,7 +49,7 @@ public:
|
||||
if (error != 0)
|
||||
{
|
||||
boost::system::system_error e(
|
||||
boost::system::error_code(error, boost::system::native_ecat),
|
||||
boost::system::error_code(error, boost::asio::error::system_category),
|
||||
"event");
|
||||
boost::throw_exception(e);
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <pthread.h>
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#include <boost/asio/error.hpp>
|
||||
#include <boost/asio/detail/noncopyable.hpp>
|
||||
#include <boost/asio/detail/scoped_lock.hpp>
|
||||
|
||||
@@ -51,7 +52,7 @@ public:
|
||||
if (error != 0)
|
||||
{
|
||||
boost::system::system_error e(
|
||||
boost::system::error_code(error, boost::system::native_ecat),
|
||||
boost::system::error_code(error, boost::asio::error::system_category),
|
||||
"mutex");
|
||||
boost::throw_exception(e);
|
||||
}
|
||||
@@ -70,7 +71,7 @@ public:
|
||||
if (error != 0)
|
||||
{
|
||||
boost::system::system_error e(
|
||||
boost::system::error_code(error, boost::system::native_ecat),
|
||||
boost::system::error_code(error, boost::asio::error::system_category),
|
||||
"mutex");
|
||||
boost::throw_exception(e);
|
||||
}
|
||||
@@ -83,7 +84,7 @@ public:
|
||||
if (error != 0)
|
||||
{
|
||||
boost::system::system_error e(
|
||||
boost::system::error_code(error, boost::system::native_ecat),
|
||||
boost::system::error_code(error, boost::asio::error::system_category),
|
||||
"mutex");
|
||||
boost::throw_exception(e);
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <pthread.h>
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#include <boost/asio/error.hpp>
|
||||
#include <boost/asio/detail/noncopyable.hpp>
|
||||
|
||||
namespace boost {
|
||||
@@ -53,7 +54,7 @@ public:
|
||||
if (error != 0)
|
||||
{
|
||||
boost::system::system_error e(
|
||||
boost::system::error_code(error, boost::system::native_ecat),
|
||||
boost::system::error_code(error, boost::asio::error::system_category),
|
||||
"thread");
|
||||
boost::throw_exception(e);
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <pthread.h>
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#include <boost/asio/error.hpp>
|
||||
#include <boost/asio/detail/noncopyable.hpp>
|
||||
|
||||
namespace boost {
|
||||
@@ -47,7 +48,7 @@ public:
|
||||
if (error != 0)
|
||||
{
|
||||
boost::system::system_error e(
|
||||
boost::system::error_code(error, boost::system::native_ecat),
|
||||
boost::system::error_code(error, boost::asio::error::system_category),
|
||||
"tss");
|
||||
boost::throw_exception(e);
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ public:
|
||||
|
||||
if (int err = reactor_.register_descriptor(sock.get()))
|
||||
{
|
||||
ec = boost::system::error_code(err, boost::system::native_ecat);
|
||||
ec = boost::system::error_code(err, boost::asio::error::system_category);
|
||||
return ec;
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ public:
|
||||
|
||||
if (int err = reactor_.register_descriptor(native_socket))
|
||||
{
|
||||
ec = boost::system::error_code(err, boost::system::native_ecat);
|
||||
ec = boost::system::error_code(err, boost::asio::error::system_category);
|
||||
return ec;
|
||||
}
|
||||
|
||||
@@ -1125,7 +1125,7 @@ public:
|
||||
bool operator()(const boost::system::error_code& result)
|
||||
{
|
||||
// Check whether the operation was successful.
|
||||
if (result != 0)
|
||||
if (result)
|
||||
{
|
||||
io_service_.post(bind_handler(handler_, result, 0));
|
||||
return true;
|
||||
@@ -1490,7 +1490,7 @@ public:
|
||||
if (connect_error)
|
||||
{
|
||||
ec = boost::system::error_code(connect_error,
|
||||
boost::system::native_ecat);
|
||||
boost::asio::error::system_category);
|
||||
io_service_.post(bind_handler(handler_, ec));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -53,9 +53,10 @@ inline ReturnType error_wrapper(ReturnType return_value,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
#if defined(BOOST_WINDOWS) || defined(__CYGWIN__)
|
||||
ec = boost::system::error_code(WSAGetLastError(), boost::system::native_ecat);
|
||||
ec = boost::system::error_code(WSAGetLastError(),
|
||||
boost::asio::error::system_category);
|
||||
#else
|
||||
ec = boost::system::error_code(errno, boost::system::native_ecat);
|
||||
ec = boost::system::error_code(errno, boost::asio::error::system_category);
|
||||
#endif
|
||||
return return_value;
|
||||
}
|
||||
@@ -1519,10 +1520,10 @@ inline boost::system::error_code translate_addrinfo_error(int error)
|
||||
default: // Possibly the non-portable EAI_SYSTEM.
|
||||
#if defined(BOOST_WINDOWS) || defined(__CYGWIN__)
|
||||
return boost::system::error_code(
|
||||
WSAGetLastError(), boost::system::native_ecat);
|
||||
WSAGetLastError(), boost::asio::error::system_category);
|
||||
#else
|
||||
return boost::system::error_code(
|
||||
errno, boost::system::native_ecat);
|
||||
errno, boost::asio::error::system_category);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#if defined(BOOST_WINDOWS)
|
||||
|
||||
#include <boost/asio/error.hpp>
|
||||
#include <boost/asio/detail/noncopyable.hpp>
|
||||
#include <boost/asio/detail/socket_types.hpp>
|
||||
|
||||
@@ -48,7 +49,8 @@ public:
|
||||
{
|
||||
DWORD last_error = ::GetLastError();
|
||||
boost::system::system_error e(
|
||||
boost::system::error_code(last_error, boost::system::native_ecat),
|
||||
boost::system::error_code(last_error,
|
||||
boost::asio::error::system_category),
|
||||
"event");
|
||||
boost::throw_exception(e);
|
||||
}
|
||||
|
||||
@@ -64,7 +64,8 @@ public:
|
||||
{
|
||||
DWORD last_error = ::GetLastError();
|
||||
boost::system::system_error e(
|
||||
boost::system::error_code(last_error, boost::system::native_ecat),
|
||||
boost::system::error_code(last_error,
|
||||
boost::asio::error::system_category),
|
||||
"iocp");
|
||||
boost::throw_exception(e);
|
||||
}
|
||||
@@ -174,7 +175,8 @@ public:
|
||||
{
|
||||
DWORD last_error = ::GetLastError();
|
||||
boost::system::system_error e(
|
||||
boost::system::error_code(last_error, boost::system::native_ecat),
|
||||
boost::system::error_code(last_error,
|
||||
boost::asio::error::system_category),
|
||||
"pqcs");
|
||||
boost::throw_exception(e);
|
||||
}
|
||||
@@ -229,7 +231,8 @@ public:
|
||||
{
|
||||
DWORD last_error = ::GetLastError();
|
||||
boost::system::system_error e(
|
||||
boost::system::error_code(last_error, boost::system::native_ecat),
|
||||
boost::system::error_code(last_error,
|
||||
boost::asio::error::system_category),
|
||||
"pqcs");
|
||||
boost::throw_exception(e);
|
||||
}
|
||||
@@ -248,7 +251,8 @@ public:
|
||||
{
|
||||
DWORD last_error = ::GetLastError();
|
||||
boost::system::system_error e(
|
||||
boost::system::error_code(last_error, boost::system::native_ecat),
|
||||
boost::system::error_code(last_error,
|
||||
boost::asio::error::system_category),
|
||||
"pqcs");
|
||||
boost::throw_exception(e);
|
||||
}
|
||||
@@ -313,7 +317,7 @@ private:
|
||||
{
|
||||
DWORD last_error = ::GetLastError();
|
||||
ec = boost::system::error_code(last_error,
|
||||
boost::system::native_ecat);
|
||||
boost::asio::error::system_category);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -338,7 +338,8 @@ public:
|
||||
if (!cancel_io_ex(sock_as_handle, 0))
|
||||
{
|
||||
DWORD last_error = ::GetLastError();
|
||||
ec = boost::system::error_code(last_error, boost::system::native_ecat);
|
||||
ec = boost::system::error_code(last_error,
|
||||
boost::asio::error::system_category);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -359,7 +360,8 @@ public:
|
||||
if (!::CancelIo(sock_as_handle))
|
||||
{
|
||||
DWORD last_error = ::GetLastError();
|
||||
ec = boost::system::error_code(last_error, boost::system::native_ecat);
|
||||
ec = boost::system::error_code(last_error,
|
||||
boost::asio::error::system_category);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -665,7 +667,8 @@ public:
|
||||
last_error = WSAECONNRESET;
|
||||
else if (last_error == ERROR_PORT_UNREACHABLE)
|
||||
last_error = WSAECONNREFUSED;
|
||||
ec = boost::system::error_code(last_error, boost::system::native_ecat);
|
||||
ec = boost::system::error_code(last_error,
|
||||
boost::asio::error::system_category);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -716,7 +719,8 @@ public:
|
||||
#endif // defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING)
|
||||
|
||||
// Map non-portable errors to their portable counterparts.
|
||||
boost::system::error_code ec(last_error, boost::system::native_ecat);
|
||||
boost::system::error_code ec(last_error,
|
||||
boost::asio::error::system_category);
|
||||
if (ec.value() == ERROR_NETNAME_DELETED)
|
||||
{
|
||||
if (handler_op->cancel_token_.expired())
|
||||
@@ -818,7 +822,8 @@ public:
|
||||
{
|
||||
boost::asio::io_service::work work(this->io_service());
|
||||
ptr.reset();
|
||||
boost::system::error_code ec(last_error, boost::system::native_ecat);
|
||||
boost::system::error_code ec(last_error,
|
||||
boost::asio::error::system_category);
|
||||
iocp_service_.post(bind_handler(handler, ec, bytes_transferred));
|
||||
}
|
||||
else
|
||||
@@ -862,7 +867,8 @@ public:
|
||||
DWORD last_error = ::WSAGetLastError();
|
||||
if (last_error == ERROR_PORT_UNREACHABLE)
|
||||
last_error = WSAECONNREFUSED;
|
||||
ec = boost::system::error_code(last_error, boost::system::native_ecat);
|
||||
ec = boost::system::error_code(last_error,
|
||||
boost::asio::error::system_category);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -911,7 +917,8 @@ public:
|
||||
#endif // defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING)
|
||||
|
||||
// Map non-portable errors to their portable counterparts.
|
||||
boost::system::error_code ec(last_error, boost::system::native_ecat);
|
||||
boost::system::error_code ec(last_error,
|
||||
boost::asio::error::system_category);
|
||||
if (ec.value() == ERROR_PORT_UNREACHABLE)
|
||||
{
|
||||
ec = boost::asio::error::connection_refused;
|
||||
@@ -994,7 +1001,8 @@ public:
|
||||
{
|
||||
boost::asio::io_service::work work(this->io_service());
|
||||
ptr.reset();
|
||||
boost::system::error_code ec(last_error, boost::system::native_ecat);
|
||||
boost::system::error_code ec(last_error,
|
||||
boost::asio::error::system_category);
|
||||
iocp_service_.post(bind_handler(handler, ec, bytes_transferred));
|
||||
}
|
||||
else
|
||||
@@ -1048,7 +1056,8 @@ public:
|
||||
last_error = WSAECONNRESET;
|
||||
else if (last_error == ERROR_PORT_UNREACHABLE)
|
||||
last_error = WSAECONNREFUSED;
|
||||
ec = boost::system::error_code(last_error, boost::system::native_ecat);
|
||||
ec = boost::system::error_code(last_error,
|
||||
boost::asio::error::system_category);
|
||||
return 0;
|
||||
}
|
||||
if (bytes_transferred == 0)
|
||||
@@ -1106,7 +1115,8 @@ public:
|
||||
#endif // defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING)
|
||||
|
||||
// Map non-portable errors to their portable counterparts.
|
||||
boost::system::error_code ec(last_error, boost::system::native_ecat);
|
||||
boost::system::error_code ec(last_error,
|
||||
boost::asio::error::system_category);
|
||||
if (ec.value() == ERROR_NETNAME_DELETED)
|
||||
{
|
||||
if (handler_op->cancel_token_.expired())
|
||||
@@ -1213,7 +1223,8 @@ public:
|
||||
{
|
||||
boost::asio::io_service::work work(this->io_service());
|
||||
ptr.reset();
|
||||
boost::system::error_code ec(last_error, boost::system::native_ecat);
|
||||
boost::system::error_code ec(last_error,
|
||||
boost::asio::error::system_category);
|
||||
iocp_service_.post(bind_handler(handler, ec, bytes_transferred));
|
||||
}
|
||||
else
|
||||
@@ -1259,7 +1270,8 @@ public:
|
||||
DWORD last_error = ::WSAGetLastError();
|
||||
if (last_error == ERROR_PORT_UNREACHABLE)
|
||||
last_error = WSAECONNREFUSED;
|
||||
ec = boost::system::error_code(last_error, boost::system::native_ecat);
|
||||
ec = boost::system::error_code(last_error,
|
||||
boost::asio::error::system_category);
|
||||
return 0;
|
||||
}
|
||||
if (bytes_transferred == 0)
|
||||
@@ -1325,7 +1337,8 @@ public:
|
||||
#endif // defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING)
|
||||
|
||||
// Map non-portable errors to their portable counterparts.
|
||||
boost::system::error_code ec(last_error, boost::system::native_ecat);
|
||||
boost::system::error_code ec(last_error,
|
||||
boost::asio::error::system_category);
|
||||
if (ec.value() == ERROR_PORT_UNREACHABLE)
|
||||
{
|
||||
ec = boost::asio::error::connection_refused;
|
||||
@@ -1419,7 +1432,8 @@ public:
|
||||
{
|
||||
boost::asio::io_service::work work(this->io_service());
|
||||
ptr.reset();
|
||||
boost::system::error_code ec(last_error, boost::system::native_ecat);
|
||||
boost::system::error_code ec(last_error,
|
||||
boost::asio::error::system_category);
|
||||
iocp_service_.post(bind_handler(handler, ec, bytes_transferred));
|
||||
}
|
||||
else
|
||||
@@ -1656,7 +1670,8 @@ public:
|
||||
ptr.reset();
|
||||
|
||||
// Call the handler.
|
||||
boost::system::error_code ec(last_error, boost::system::native_ecat);
|
||||
boost::system::error_code ec(last_error,
|
||||
boost::asio::error::system_category);
|
||||
asio_handler_invoke_helpers::invoke(
|
||||
detail::bind_handler(handler, ec), &handler);
|
||||
}
|
||||
@@ -1756,7 +1771,8 @@ public:
|
||||
{
|
||||
boost::asio::io_service::work work(this->io_service());
|
||||
ptr.reset();
|
||||
boost::system::error_code ec(last_error, boost::system::native_ecat);
|
||||
boost::system::error_code ec(last_error,
|
||||
boost::asio::error::system_category);
|
||||
iocp_service_.post(bind_handler(handler, ec));
|
||||
}
|
||||
}
|
||||
@@ -1832,8 +1848,8 @@ public:
|
||||
// If connection failed then post the handler with the error code.
|
||||
if (connect_error)
|
||||
{
|
||||
ec = boost::system::error_code(
|
||||
connect_error, boost::system::native_ecat);
|
||||
ec = boost::system::error_code(connect_error,
|
||||
boost::asio::error::system_category);
|
||||
io_service_.post(bind_handler(handler_, ec));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#if defined(BOOST_WINDOWS)
|
||||
|
||||
#include <boost/asio/error.hpp>
|
||||
#include <boost/asio/detail/noncopyable.hpp>
|
||||
#include <boost/asio/detail/socket_types.hpp>
|
||||
#include <boost/asio/detail/scoped_lock.hpp>
|
||||
@@ -49,7 +50,7 @@ public:
|
||||
if (error != 0)
|
||||
{
|
||||
boost::system::system_error e(
|
||||
boost::system::error_code(error, boost::system::native_ecat),
|
||||
boost::system::error_code(error, boost::asio::error::system_category),
|
||||
"mutex");
|
||||
boost::throw_exception(e);
|
||||
}
|
||||
@@ -68,7 +69,7 @@ public:
|
||||
if (error != 0)
|
||||
{
|
||||
boost::system::system_error e(
|
||||
boost::system::error_code(error, boost::system::native_ecat),
|
||||
boost::system::error_code(error, boost::asio::error::system_category),
|
||||
"mutex");
|
||||
boost::throw_exception(e);
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#if defined(BOOST_WINDOWS)
|
||||
|
||||
#include <boost/asio/error.hpp>
|
||||
#include <boost/asio/detail/noncopyable.hpp>
|
||||
#include <boost/asio/detail/socket_types.hpp>
|
||||
|
||||
@@ -55,7 +56,8 @@ public:
|
||||
{
|
||||
DWORD last_error = ::GetLastError();
|
||||
boost::system::system_error e(
|
||||
boost::system::error_code(last_error, boost::system::native_ecat),
|
||||
boost::system::error_code(last_error,
|
||||
boost::asio::error::system_category),
|
||||
"thread");
|
||||
boost::throw_exception(e);
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#if defined(BOOST_WINDOWS)
|
||||
|
||||
#include <boost/asio/error.hpp>
|
||||
#include <boost/asio/detail/noncopyable.hpp>
|
||||
#include <boost/asio/detail/socket_types.hpp>
|
||||
|
||||
@@ -48,7 +49,8 @@ public:
|
||||
{
|
||||
DWORD last_error = ::GetLastError();
|
||||
boost::system::system_error e(
|
||||
boost::system::error_code(last_error, boost::system::native_ecat),
|
||||
boost::system::error_code(last_error,
|
||||
boost::asio::error::system_category),
|
||||
"tss");
|
||||
boost::throw_exception(e);
|
||||
}
|
||||
|
||||
@@ -86,7 +86,8 @@ public:
|
||||
if (this != &instance_ && ref_->result() != 0)
|
||||
{
|
||||
boost::system::system_error e(
|
||||
boost::system::error_code(ref_->result(), boost::system::native_ecat),
|
||||
boost::system::error_code(ref_->result(),
|
||||
boost::asio::error::system_category),
|
||||
"winsock");
|
||||
boost::throw_exception(e);
|
||||
}
|
||||
|
||||
@@ -37,493 +37,372 @@
|
||||
/// INTERNAL ONLY.
|
||||
# define BOOST_ASIO_WIN_OR_POSIX(e_win, e_posix) implementation_defined
|
||||
#elif defined(BOOST_WINDOWS) || defined(__CYGWIN__)
|
||||
# define BOOST_ASIO_NATIVE_ERROR(e) \
|
||||
boost::system::error_code(e, \
|
||||
boost::system::native_ecat)
|
||||
# define BOOST_ASIO_SOCKET_ERROR(e) \
|
||||
boost::system::error_code(WSA ## e, \
|
||||
boost::system::native_ecat)
|
||||
# define BOOST_ASIO_NETDB_ERROR(e) \
|
||||
boost::system::error_code(WSA ## e, \
|
||||
boost::system::native_ecat)
|
||||
# define BOOST_ASIO_GETADDRINFO_ERROR(e) \
|
||||
boost::system::error_code(WSA ## e, \
|
||||
boost::system::native_ecat)
|
||||
# define BOOST_ASIO_MISC_ERROR(e) \
|
||||
boost::system::error_code(e, \
|
||||
boost::asio::detail::error_base<T>::misc_ecat())
|
||||
# define BOOST_ASIO_NATIVE_ERROR(e) e
|
||||
# define BOOST_ASIO_SOCKET_ERROR(e) WSA ## e
|
||||
# define BOOST_ASIO_NETDB_ERROR(e) WSA ## e
|
||||
# define BOOST_ASIO_GETADDRINFO_ERROR(e) WSA ## e
|
||||
# define BOOST_ASIO_WIN_OR_POSIX(e_win, e_posix) e_win
|
||||
#else
|
||||
# define BOOST_ASIO_NATIVE_ERROR(e) \
|
||||
boost::system::error_code(e, \
|
||||
boost::system::native_ecat)
|
||||
# define BOOST_ASIO_SOCKET_ERROR(e) \
|
||||
boost::system::error_code(e, \
|
||||
boost::system::native_ecat)
|
||||
# define BOOST_ASIO_NETDB_ERROR(e) \
|
||||
boost::system::error_code(e, \
|
||||
boost::asio::detail::error_base<T>::netdb_ecat())
|
||||
# define BOOST_ASIO_GETADDRINFO_ERROR(e) \
|
||||
boost::system::error_code(e, \
|
||||
boost::asio::detail::error_base<T>::addrinfo_ecat())
|
||||
# define BOOST_ASIO_MISC_ERROR(e) \
|
||||
boost::system::error_code(e, \
|
||||
boost::asio::detail::error_base<T>::misc_ecat())
|
||||
# define BOOST_ASIO_NATIVE_ERROR(e) e
|
||||
# define BOOST_ASIO_SOCKET_ERROR(e) e
|
||||
# define BOOST_ASIO_NETDB_ERROR(e) e
|
||||
# define BOOST_ASIO_GETADDRINFO_ERROR(e) e
|
||||
# define BOOST_ASIO_WIN_OR_POSIX(e_win, e_posix) e_posix
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
namespace error {
|
||||
|
||||
enum basic_errors
|
||||
{
|
||||
/// Permission denied.
|
||||
access_denied = BOOST_ASIO_SOCKET_ERROR(EACCES),
|
||||
|
||||
/// Address family not supported by protocol.
|
||||
address_family_not_supported = BOOST_ASIO_SOCKET_ERROR(EAFNOSUPPORT),
|
||||
|
||||
/// Address already in use.
|
||||
address_in_use = BOOST_ASIO_SOCKET_ERROR(EADDRINUSE),
|
||||
|
||||
/// Transport endpoint is already connected.
|
||||
already_connected = BOOST_ASIO_SOCKET_ERROR(EISCONN),
|
||||
|
||||
/// Operation already in progress.
|
||||
already_started = BOOST_ASIO_SOCKET_ERROR(EALREADY),
|
||||
|
||||
/// A connection has been aborted.
|
||||
connection_aborted = BOOST_ASIO_SOCKET_ERROR(ECONNABORTED),
|
||||
|
||||
/// Connection refused.
|
||||
connection_refused = BOOST_ASIO_SOCKET_ERROR(ECONNREFUSED),
|
||||
|
||||
/// Connection reset by peer.
|
||||
connection_reset = BOOST_ASIO_SOCKET_ERROR(ECONNRESET),
|
||||
|
||||
/// Bad file descriptor.
|
||||
bad_descriptor = BOOST_ASIO_SOCKET_ERROR(EBADF),
|
||||
|
||||
/// Bad address.
|
||||
fault = BOOST_ASIO_SOCKET_ERROR(EFAULT),
|
||||
|
||||
/// No route to host.
|
||||
host_unreachable = BOOST_ASIO_SOCKET_ERROR(EHOSTUNREACH),
|
||||
|
||||
/// Operation now in progress.
|
||||
in_progress = BOOST_ASIO_SOCKET_ERROR(EINPROGRESS),
|
||||
|
||||
/// Interrupted system call.
|
||||
interrupted = BOOST_ASIO_SOCKET_ERROR(EINTR),
|
||||
|
||||
/// Invalid argument.
|
||||
invalid_argument = BOOST_ASIO_SOCKET_ERROR(EINVAL),
|
||||
|
||||
/// Message too long.
|
||||
message_size = BOOST_ASIO_SOCKET_ERROR(EMSGSIZE),
|
||||
|
||||
/// Network is down.
|
||||
network_down = BOOST_ASIO_SOCKET_ERROR(ENETDOWN),
|
||||
|
||||
/// Network dropped connection on reset.
|
||||
network_reset = BOOST_ASIO_SOCKET_ERROR(ENETRESET),
|
||||
|
||||
/// Network is unreachable.
|
||||
network_unreachable = BOOST_ASIO_SOCKET_ERROR(ENETUNREACH),
|
||||
|
||||
/// Too many open files.
|
||||
no_descriptors = BOOST_ASIO_SOCKET_ERROR(EMFILE),
|
||||
|
||||
/// No buffer space available.
|
||||
no_buffer_space = BOOST_ASIO_SOCKET_ERROR(ENOBUFS),
|
||||
|
||||
/// Cannot allocate memory.
|
||||
no_memory = BOOST_ASIO_WIN_OR_POSIX(
|
||||
BOOST_ASIO_NATIVE_ERROR(ERROR_OUTOFMEMORY),
|
||||
BOOST_ASIO_NATIVE_ERROR(ENOMEM)),
|
||||
|
||||
/// Operation not permitted.
|
||||
no_permission = BOOST_ASIO_WIN_OR_POSIX(
|
||||
BOOST_ASIO_NATIVE_ERROR(ERROR_ACCESS_DENIED),
|
||||
BOOST_ASIO_NATIVE_ERROR(EPERM)),
|
||||
|
||||
/// Protocol not available.
|
||||
no_protocol_option = BOOST_ASIO_SOCKET_ERROR(ENOPROTOOPT),
|
||||
|
||||
/// Transport endpoint is not connected.
|
||||
not_connected = BOOST_ASIO_SOCKET_ERROR(ENOTCONN),
|
||||
|
||||
/// Socket operation on non-socket.
|
||||
not_socket = BOOST_ASIO_SOCKET_ERROR(ENOTSOCK),
|
||||
|
||||
/// Operation cancelled.
|
||||
operation_aborted = BOOST_ASIO_WIN_OR_POSIX(
|
||||
BOOST_ASIO_NATIVE_ERROR(ERROR_OPERATION_ABORTED),
|
||||
BOOST_ASIO_NATIVE_ERROR(ECANCELED)),
|
||||
|
||||
/// Operation not supported.
|
||||
operation_not_supported = BOOST_ASIO_SOCKET_ERROR(EOPNOTSUPP),
|
||||
|
||||
/// Cannot send after transport endpoint shutdown.
|
||||
shut_down = BOOST_ASIO_SOCKET_ERROR(ESHUTDOWN),
|
||||
|
||||
/// Connection timed out.
|
||||
timed_out = BOOST_ASIO_SOCKET_ERROR(ETIMEDOUT),
|
||||
|
||||
/// Resource temporarily unavailable.
|
||||
try_again = BOOST_ASIO_WIN_OR_POSIX(
|
||||
BOOST_ASIO_NATIVE_ERROR(ERROR_RETRY),
|
||||
BOOST_ASIO_NATIVE_ERROR(EAGAIN)),
|
||||
|
||||
/// The socket is marked non-blocking and the requested operation would block.
|
||||
would_block = BOOST_ASIO_SOCKET_ERROR(EWOULDBLOCK)
|
||||
};
|
||||
|
||||
enum netdb_errors
|
||||
{
|
||||
/// Host not found (authoritative).
|
||||
host_not_found = BOOST_ASIO_NETDB_ERROR(HOST_NOT_FOUND),
|
||||
|
||||
/// Host not found (non-authoritative).
|
||||
host_not_found_try_again = BOOST_ASIO_NETDB_ERROR(TRY_AGAIN),
|
||||
|
||||
/// The query is valid but does not have associated address data.
|
||||
no_data = BOOST_ASIO_NETDB_ERROR(NO_DATA),
|
||||
|
||||
/// A non-recoverable error occurred.
|
||||
no_recovery = BOOST_ASIO_NETDB_ERROR(NO_RECOVERY)
|
||||
};
|
||||
|
||||
enum addrinfo_errors
|
||||
{
|
||||
/// The service is not supported for the given socket type.
|
||||
service_not_found = BOOST_ASIO_WIN_OR_POSIX(
|
||||
BOOST_ASIO_NATIVE_ERROR(WSATYPE_NOT_FOUND),
|
||||
BOOST_ASIO_GETADDRINFO_ERROR(EAI_SERVICE)),
|
||||
|
||||
/// The socket type is not supported.
|
||||
socket_type_not_supported = BOOST_ASIO_WIN_OR_POSIX(
|
||||
BOOST_ASIO_NATIVE_ERROR(WSAESOCKTNOSUPPORT),
|
||||
BOOST_ASIO_GETADDRINFO_ERROR(EAI_SOCKTYPE))
|
||||
};
|
||||
|
||||
enum misc_errors
|
||||
{
|
||||
/// Already open.
|
||||
already_open = 1,
|
||||
|
||||
/// End of file or stream.
|
||||
eof,
|
||||
|
||||
/// Element not found.
|
||||
not_found
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
/// Hack to keep asio library header-file-only.
|
||||
template <typename T>
|
||||
class error_base
|
||||
inline const boost::system::error_category& get_system_category()
|
||||
{
|
||||
return boost::system::system_category;
|
||||
}
|
||||
|
||||
#if !defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
|
||||
|
||||
class netdb_category : public boost::system::error_category
|
||||
{
|
||||
public:
|
||||
#if !defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
|
||||
static boost::system::error_category netdb_ecat();
|
||||
static int netdb_ed(const boost::system::error_code& ec);
|
||||
static std::string netdb_md(const boost::system::error_code& ec);
|
||||
static boost::system::wstring_t netdb_wmd(
|
||||
const boost::system::error_code& ec);
|
||||
const char* name() const
|
||||
{
|
||||
return "asio.netdb";
|
||||
}
|
||||
|
||||
static boost::system::error_category addrinfo_ecat();
|
||||
static int addrinfo_ed(const boost::system::error_code& ec);
|
||||
static std::string addrinfo_md(const boost::system::error_code& ec);
|
||||
static boost::system::wstring_t addrinfo_wmd(
|
||||
const boost::system::error_code& ec);
|
||||
#endif // !defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
|
||||
|
||||
static boost::system::error_category misc_ecat();
|
||||
static int misc_ed(const boost::system::error_code& ec);
|
||||
static std::string misc_md(const boost::system::error_code& ec);
|
||||
static boost::system::wstring_t misc_wmd(const boost::system::error_code& ec);
|
||||
|
||||
static boost::system::error_category ssl_ecat();
|
||||
static int ssl_ed(const boost::system::error_code& ec);
|
||||
static std::string ssl_md(const boost::system::error_code& ec);
|
||||
static boost::system::wstring_t ssl_wmd(const boost::system::error_code& ec);
|
||||
|
||||
/// Permission denied.
|
||||
static const boost::system::error_code access_denied;
|
||||
|
||||
/// Address family not supported by protocol.
|
||||
static const boost::system::error_code address_family_not_supported;
|
||||
|
||||
/// Address already in use.
|
||||
static const boost::system::error_code address_in_use;
|
||||
|
||||
/// Transport endpoint is already connected.
|
||||
static const boost::system::error_code already_connected;
|
||||
|
||||
/// Already open.
|
||||
static const boost::system::error_code already_open;
|
||||
|
||||
/// Operation already in progress.
|
||||
static const boost::system::error_code already_started;
|
||||
|
||||
/// A connection has been aborted.
|
||||
static const boost::system::error_code connection_aborted;
|
||||
|
||||
/// Connection refused.
|
||||
static const boost::system::error_code connection_refused;
|
||||
|
||||
/// Connection reset by peer.
|
||||
static const boost::system::error_code connection_reset;
|
||||
|
||||
/// Bad file descriptor.
|
||||
static const boost::system::error_code bad_descriptor;
|
||||
|
||||
/// End of file or stream.
|
||||
static const boost::system::error_code eof;
|
||||
|
||||
/// Bad address.
|
||||
static const boost::system::error_code fault;
|
||||
|
||||
/// Host not found (authoritative).
|
||||
static const boost::system::error_code host_not_found;
|
||||
|
||||
/// Host not found (non-authoritative).
|
||||
static const boost::system::error_code host_not_found_try_again;
|
||||
|
||||
/// No route to host.
|
||||
static const boost::system::error_code host_unreachable;
|
||||
|
||||
/// Operation now in progress.
|
||||
static const boost::system::error_code in_progress;
|
||||
|
||||
/// Interrupted system call.
|
||||
static const boost::system::error_code interrupted;
|
||||
|
||||
/// Invalid argument.
|
||||
static const boost::system::error_code invalid_argument;
|
||||
|
||||
/// Message too long.
|
||||
static const boost::system::error_code message_size;
|
||||
|
||||
/// Network is down.
|
||||
static const boost::system::error_code network_down;
|
||||
|
||||
/// Network dropped connection on reset.
|
||||
static const boost::system::error_code network_reset;
|
||||
|
||||
/// Network is unreachable.
|
||||
static const boost::system::error_code network_unreachable;
|
||||
|
||||
/// Too many open files.
|
||||
static const boost::system::error_code no_descriptors;
|
||||
|
||||
/// No buffer space available.
|
||||
static const boost::system::error_code no_buffer_space;
|
||||
|
||||
/// The query is valid but does not have associated address data.
|
||||
static const boost::system::error_code no_data;
|
||||
|
||||
/// Cannot allocate memory.
|
||||
static const boost::system::error_code no_memory;
|
||||
|
||||
/// Operation not permitted.
|
||||
static const boost::system::error_code no_permission;
|
||||
|
||||
/// Protocol not available.
|
||||
static const boost::system::error_code no_protocol_option;
|
||||
|
||||
/// A non-recoverable error occurred.
|
||||
static const boost::system::error_code no_recovery;
|
||||
|
||||
/// Transport endpoint is not connected.
|
||||
static const boost::system::error_code not_connected;
|
||||
|
||||
/// Element not found.
|
||||
static const boost::system::error_code not_found;
|
||||
|
||||
/// Socket operation on non-socket.
|
||||
static const boost::system::error_code not_socket;
|
||||
|
||||
/// Operation cancelled.
|
||||
static const boost::system::error_code operation_aborted;
|
||||
|
||||
/// Operation not supported.
|
||||
static const boost::system::error_code operation_not_supported;
|
||||
|
||||
/// The service is not supported for the given socket type.
|
||||
static const boost::system::error_code service_not_found;
|
||||
|
||||
/// The socket type is not supported.
|
||||
static const boost::system::error_code socket_type_not_supported;
|
||||
|
||||
/// Cannot send after transport endpoint shutdown.
|
||||
static const boost::system::error_code shut_down;
|
||||
|
||||
/// Connection timed out.
|
||||
static const boost::system::error_code timed_out;
|
||||
|
||||
/// Resource temporarily unavailable.
|
||||
static const boost::system::error_code try_again;
|
||||
|
||||
/// The socket is marked non-blocking and the requested operation would block.
|
||||
static const boost::system::error_code would_block;
|
||||
|
||||
private:
|
||||
error_base();
|
||||
std::string message(int value) const
|
||||
{
|
||||
if (value == error::host_not_found)
|
||||
return "Host not found (authoritative)";
|
||||
if (value == error::host_not_found_try_again)
|
||||
return "Host not found (non-authoritative), try again later";
|
||||
if (value == error::no_data)
|
||||
return "The query is valid, but it does not have associated data";
|
||||
if (value == error::no_recovery)
|
||||
return "A non-recoverable error occurred during database lookup";
|
||||
return "asio.netdb error";
|
||||
}
|
||||
};
|
||||
|
||||
#if !defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
|
||||
|
||||
template <typename T>
|
||||
boost::system::error_category error_base<T>::netdb_ecat()
|
||||
inline const boost::system::error_category& get_netdb_category()
|
||||
{
|
||||
static boost::system::error_category ecat =
|
||||
boost::system::error_code::new_category(&error_base<T>::netdb_ed,
|
||||
&error_base<T>::netdb_md, &error_base<T>::netdb_wmd);
|
||||
return ecat;
|
||||
static netdb_category instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
int error_base<T>::netdb_ed(const boost::system::error_code&)
|
||||
class addrinfo_category : public boost::system::error_category
|
||||
{
|
||||
return EOTHER;
|
||||
public:
|
||||
const char* name() const
|
||||
{
|
||||
return "asio.addrinfo";
|
||||
}
|
||||
|
||||
std::string message(int value) const
|
||||
{
|
||||
if (value == error::service_not_found)
|
||||
return "Service not found";
|
||||
if (value == error::socket_type_not_supported)
|
||||
return "Socket type not supported";
|
||||
return "asio.addrinfo error";
|
||||
}
|
||||
};
|
||||
|
||||
inline const boost::system::error_category& get_addrinfo_category()
|
||||
{
|
||||
static addrinfo_category instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::string error_base<T>::netdb_md(const boost::system::error_code& ec)
|
||||
#else // !defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
|
||||
|
||||
inline const boost::system::error_category& get_netdb_category()
|
||||
{
|
||||
if (ec == error_base<T>::host_not_found)
|
||||
return "Host not found (authoritative)";
|
||||
if (ec == error_base<T>::host_not_found_try_again)
|
||||
return "Host not found (non-authoritative), try again later";
|
||||
if (ec == error_base<T>::no_data)
|
||||
return "The query is valid, but it does not have associated data";
|
||||
if (ec == error_base<T>::no_recovery)
|
||||
return "A non-recoverable error occurred during database lookup";
|
||||
return "EINVAL";
|
||||
return get_system_category();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
boost::system::wstring_t error_base<T>::netdb_wmd(
|
||||
const boost::system::error_code& ec)
|
||||
inline const boost::system::error_category& get_addrinfo_category()
|
||||
{
|
||||
if (ec == error_base<T>::host_not_found)
|
||||
return L"Host not found (authoritative)";
|
||||
if (ec == error_base<T>::host_not_found_try_again)
|
||||
return L"Host not found (non-authoritative), try again later";
|
||||
if (ec == error_base<T>::no_data)
|
||||
return L"The query is valid, but it does not have associated data";
|
||||
if (ec == error_base<T>::no_recovery)
|
||||
return L"A non-recoverable error occurred during database lookup";
|
||||
return L"EINVAL";
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
boost::system::error_category error_base<T>::addrinfo_ecat()
|
||||
{
|
||||
static boost::system::error_category ecat =
|
||||
boost::system::error_code::new_category(&error_base<T>::addrinfo_ed,
|
||||
&error_base<T>::addrinfo_md, &error_base<T>::addrinfo_wmd);
|
||||
return ecat;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
int error_base<T>::addrinfo_ed(const boost::system::error_code&)
|
||||
{
|
||||
return EOTHER;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::string error_base<T>::addrinfo_md(const boost::system::error_code& ec)
|
||||
{
|
||||
if (ec == error_base<T>::service_not_found)
|
||||
return "Service not found";
|
||||
if (ec == error_base<T>::socket_type_not_supported)
|
||||
return "Socket type not supported";
|
||||
return "EINVAL";
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
boost::system::wstring_t error_base<T>::addrinfo_wmd(
|
||||
const boost::system::error_code& ec)
|
||||
{
|
||||
if (ec == error_base<T>::service_not_found)
|
||||
return L"Service not found";
|
||||
if (ec == error_base<T>::socket_type_not_supported)
|
||||
return L"Socket type not supported";
|
||||
return L"EINVAL";
|
||||
return get_system_category();
|
||||
}
|
||||
|
||||
#endif // !defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
|
||||
|
||||
template <typename T>
|
||||
boost::system::error_category error_base<T>::misc_ecat()
|
||||
class misc_category : public boost::system::error_category
|
||||
{
|
||||
static boost::system::error_category ecat =
|
||||
boost::system::error_code::new_category(&error_base<T>::misc_ed,
|
||||
&error_base<T>::misc_md, &error_base<T>::misc_wmd);
|
||||
return ecat;
|
||||
public:
|
||||
const char* name() const
|
||||
{
|
||||
return "asio.misc";
|
||||
}
|
||||
|
||||
std::string message(int value) const
|
||||
{
|
||||
if (value == error::already_open)
|
||||
return "Already open";
|
||||
if (value == error::eof)
|
||||
return "End of file";
|
||||
if (value == error::not_found)
|
||||
return "Element not found";
|
||||
return "asio.misc error";
|
||||
}
|
||||
};
|
||||
|
||||
inline const boost::system::error_category& get_misc_category()
|
||||
{
|
||||
static misc_category instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
int error_base<T>::misc_ed(const boost::system::error_code&)
|
||||
class ssl_category : public boost::system::error_category
|
||||
{
|
||||
return EOTHER;
|
||||
}
|
||||
public:
|
||||
const char* name() const
|
||||
{
|
||||
return "asio.ssl";
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::string error_base<T>::misc_md(const boost::system::error_code& ec)
|
||||
std::string message(int value) const
|
||||
{
|
||||
return "asio.ssl error";
|
||||
}
|
||||
};
|
||||
|
||||
inline const boost::system::error_category& get_ssl_category()
|
||||
{
|
||||
if (ec == error_base<T>::already_open)
|
||||
return "Already open";
|
||||
if (ec == error_base<T>::eof)
|
||||
return "End of file";
|
||||
if (ec == error_base<T>::not_found)
|
||||
return "Element not found";
|
||||
return "EINVAL";
|
||||
static ssl_category instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
boost::system::wstring_t error_base<T>::misc_wmd(
|
||||
const boost::system::error_code& ec)
|
||||
{
|
||||
if (ec == error_base<T>::already_open)
|
||||
return L"Already open";
|
||||
if (ec == error_base<T>::eof)
|
||||
return L"End of file";
|
||||
if (ec == error_base<T>::not_found)
|
||||
return L"Element not found";
|
||||
return L"EINVAL";
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
boost::system::error_category error_base<T>::ssl_ecat()
|
||||
{
|
||||
static boost::system::error_category ecat =
|
||||
boost::system::error_code::new_category(&error_base<T>::ssl_ed,
|
||||
&error_base<T>::ssl_md, &error_base<T>::ssl_wmd);
|
||||
return ecat;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
int error_base<T>::ssl_ed(const boost::system::error_code&)
|
||||
{
|
||||
return EOTHER;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::string error_base<T>::ssl_md(const boost::system::error_code&)
|
||||
{
|
||||
return "SSL error";
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
boost::system::wstring_t error_base<T>::ssl_wmd(
|
||||
const boost::system::error_code&)
|
||||
{
|
||||
return L"SSL error";
|
||||
}
|
||||
|
||||
template <typename T> const boost::system::error_code
|
||||
error_base<T>::access_denied = BOOST_ASIO_SOCKET_ERROR(EACCES);
|
||||
|
||||
template <typename T> const boost::system::error_code
|
||||
error_base<T>::address_family_not_supported = BOOST_ASIO_SOCKET_ERROR(
|
||||
EAFNOSUPPORT);
|
||||
|
||||
template <typename T> const boost::system::error_code
|
||||
error_base<T>::address_in_use = BOOST_ASIO_SOCKET_ERROR(EADDRINUSE);
|
||||
|
||||
template <typename T> const boost::system::error_code
|
||||
error_base<T>::already_connected = BOOST_ASIO_SOCKET_ERROR(EISCONN);
|
||||
|
||||
template <typename T> const boost::system::error_code
|
||||
error_base<T>::already_open = BOOST_ASIO_MISC_ERROR(1);
|
||||
|
||||
template <typename T> const boost::system::error_code
|
||||
error_base<T>::already_started = BOOST_ASIO_SOCKET_ERROR(EALREADY);
|
||||
|
||||
template <typename T> const boost::system::error_code
|
||||
error_base<T>::connection_aborted = BOOST_ASIO_SOCKET_ERROR(ECONNABORTED);
|
||||
|
||||
template <typename T> const boost::system::error_code
|
||||
error_base<T>::connection_refused = BOOST_ASIO_SOCKET_ERROR(ECONNREFUSED);
|
||||
|
||||
template <typename T> const boost::system::error_code
|
||||
error_base<T>::connection_reset = BOOST_ASIO_SOCKET_ERROR(ECONNRESET);
|
||||
|
||||
template <typename T> const boost::system::error_code
|
||||
error_base<T>::bad_descriptor = BOOST_ASIO_SOCKET_ERROR(EBADF);
|
||||
|
||||
template <typename T> const boost::system::error_code
|
||||
error_base<T>::eof = BOOST_ASIO_MISC_ERROR(2);
|
||||
|
||||
template <typename T> const boost::system::error_code
|
||||
error_base<T>::fault = BOOST_ASIO_SOCKET_ERROR(EFAULT);
|
||||
|
||||
template <typename T> const boost::system::error_code
|
||||
error_base<T>::host_not_found = BOOST_ASIO_NETDB_ERROR(HOST_NOT_FOUND);
|
||||
|
||||
template <typename T> const boost::system::error_code
|
||||
error_base<T>::host_not_found_try_again = BOOST_ASIO_NETDB_ERROR(TRY_AGAIN);
|
||||
|
||||
template <typename T> const boost::system::error_code
|
||||
error_base<T>::host_unreachable = BOOST_ASIO_SOCKET_ERROR(EHOSTUNREACH);
|
||||
|
||||
template <typename T> const boost::system::error_code
|
||||
error_base<T>::in_progress = BOOST_ASIO_SOCKET_ERROR(EINPROGRESS);
|
||||
|
||||
template <typename T> const boost::system::error_code
|
||||
error_base<T>::interrupted = BOOST_ASIO_SOCKET_ERROR(EINTR);
|
||||
|
||||
template <typename T> const boost::system::error_code
|
||||
error_base<T>::invalid_argument = BOOST_ASIO_SOCKET_ERROR(EINVAL);
|
||||
|
||||
template <typename T> const boost::system::error_code
|
||||
error_base<T>::message_size = BOOST_ASIO_SOCKET_ERROR(EMSGSIZE);
|
||||
|
||||
template <typename T> const boost::system::error_code
|
||||
error_base<T>::network_down = BOOST_ASIO_SOCKET_ERROR(ENETDOWN);
|
||||
|
||||
template <typename T> const boost::system::error_code
|
||||
error_base<T>::network_reset = BOOST_ASIO_SOCKET_ERROR(ENETRESET);
|
||||
|
||||
template <typename T> const boost::system::error_code
|
||||
error_base<T>::network_unreachable = BOOST_ASIO_SOCKET_ERROR(ENETUNREACH);
|
||||
|
||||
template <typename T> const boost::system::error_code
|
||||
error_base<T>::no_descriptors = BOOST_ASIO_SOCKET_ERROR(EMFILE);
|
||||
|
||||
template <typename T> const boost::system::error_code
|
||||
error_base<T>::no_buffer_space = BOOST_ASIO_SOCKET_ERROR(ENOBUFS);
|
||||
|
||||
template <typename T> const boost::system::error_code
|
||||
error_base<T>::no_data = BOOST_ASIO_NETDB_ERROR(NO_DATA);
|
||||
|
||||
template <typename T> const boost::system::error_code
|
||||
error_base<T>::no_memory = BOOST_ASIO_WIN_OR_POSIX(
|
||||
BOOST_ASIO_NATIVE_ERROR(ERROR_OUTOFMEMORY),
|
||||
BOOST_ASIO_NATIVE_ERROR(ENOMEM));
|
||||
|
||||
template <typename T> const boost::system::error_code
|
||||
error_base<T>::no_permission = BOOST_ASIO_WIN_OR_POSIX(
|
||||
BOOST_ASIO_NATIVE_ERROR(ERROR_ACCESS_DENIED),
|
||||
BOOST_ASIO_NATIVE_ERROR(EPERM));
|
||||
|
||||
template <typename T> const boost::system::error_code
|
||||
error_base<T>::no_protocol_option = BOOST_ASIO_SOCKET_ERROR(ENOPROTOOPT);
|
||||
|
||||
template <typename T> const boost::system::error_code
|
||||
error_base<T>::no_recovery = BOOST_ASIO_NETDB_ERROR(NO_RECOVERY);
|
||||
|
||||
template <typename T> const boost::system::error_code
|
||||
error_base<T>::not_connected = BOOST_ASIO_SOCKET_ERROR(ENOTCONN);
|
||||
|
||||
template <typename T> const boost::system::error_code
|
||||
error_base<T>::not_found = BOOST_ASIO_MISC_ERROR(3);
|
||||
|
||||
template <typename T> const boost::system::error_code
|
||||
error_base<T>::not_socket = BOOST_ASIO_SOCKET_ERROR(ENOTSOCK);
|
||||
|
||||
template <typename T> const boost::system::error_code
|
||||
error_base<T>::operation_aborted = BOOST_ASIO_WIN_OR_POSIX(
|
||||
BOOST_ASIO_NATIVE_ERROR(ERROR_OPERATION_ABORTED),
|
||||
BOOST_ASIO_NATIVE_ERROR(ECANCELED));
|
||||
|
||||
template <typename T> const boost::system::error_code
|
||||
error_base<T>::operation_not_supported = BOOST_ASIO_SOCKET_ERROR(EOPNOTSUPP);
|
||||
|
||||
template <typename T> const boost::system::error_code
|
||||
error_base<T>::service_not_found = BOOST_ASIO_WIN_OR_POSIX(
|
||||
BOOST_ASIO_NATIVE_ERROR(WSATYPE_NOT_FOUND),
|
||||
BOOST_ASIO_GETADDRINFO_ERROR(EAI_SERVICE));
|
||||
|
||||
template <typename T> const boost::system::error_code
|
||||
error_base<T>::socket_type_not_supported = BOOST_ASIO_WIN_OR_POSIX(
|
||||
BOOST_ASIO_NATIVE_ERROR(WSAESOCKTNOSUPPORT),
|
||||
BOOST_ASIO_GETADDRINFO_ERROR(EAI_SOCKTYPE));
|
||||
|
||||
template <typename T> const boost::system::error_code
|
||||
error_base<T>::shut_down = BOOST_ASIO_SOCKET_ERROR(ESHUTDOWN);
|
||||
|
||||
template <typename T> const boost::system::error_code
|
||||
error_base<T>::timed_out = BOOST_ASIO_SOCKET_ERROR(ETIMEDOUT);
|
||||
|
||||
template <typename T> const boost::system::error_code
|
||||
error_base<T>::try_again = BOOST_ASIO_WIN_OR_POSIX(
|
||||
BOOST_ASIO_NATIVE_ERROR(ERROR_RETRY),
|
||||
BOOST_ASIO_NATIVE_ERROR(EAGAIN));
|
||||
|
||||
template <typename T> const boost::system::error_code
|
||||
error_base<T>::would_block = BOOST_ASIO_SOCKET_ERROR(EWOULDBLOCK);
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/// Contains error constants.
|
||||
class error : public boost::asio::detail::error_base<error>
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, < 1400)
|
||||
|
||||
static const boost::system::error_category& system_category
|
||||
= boost::asio::error::detail::get_system_category();
|
||||
static const boost::system::error_category& netdb_category
|
||||
= boost::asio::error::detail::get_netdb_category();
|
||||
static const boost::system::error_category& addrinfo_category
|
||||
= boost::asio::error::detail::get_addrinfo_category();
|
||||
static const boost::system::error_category& misc_category
|
||||
= boost::asio::error::detail::get_misc_category();
|
||||
static const boost::system::error_category& ssl_category
|
||||
= boost::asio::error::detail::get_ssl_category();
|
||||
|
||||
#else
|
||||
|
||||
namespace
|
||||
{
|
||||
private:
|
||||
error();
|
||||
const boost::system::error_category& system_category
|
||||
= boost::asio::error::detail::get_system_category();
|
||||
const boost::system::error_category& netdb_category
|
||||
= boost::asio::error::detail::get_netdb_category();
|
||||
const boost::system::error_category& addrinfo_category
|
||||
= boost::asio::error::detail::get_addrinfo_category();
|
||||
const boost::system::error_category& misc_category
|
||||
= boost::asio::error::detail::get_misc_category();
|
||||
const boost::system::error_category& ssl_category
|
||||
= boost::asio::error::detail::get_ssl_category();
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace error
|
||||
} // namespace asio
|
||||
|
||||
namespace system {
|
||||
|
||||
template<> struct is_error_code_enum<boost::asio::error::basic_errors>
|
||||
{
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
template<> struct is_error_code_enum<boost::asio::error::netdb_errors>
|
||||
{
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
template<> struct is_error_code_enum<boost::asio::error::addrinfo_errors>
|
||||
{
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
template<> struct is_error_code_enum<boost::asio::error::misc_errors>
|
||||
{
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
} // namespace system
|
||||
|
||||
namespace asio {
|
||||
namespace error {
|
||||
|
||||
inline boost::system::error_code make_error_code(basic_errors e)
|
||||
{
|
||||
return boost::system::error_code(static_cast<int>(e), system_category);
|
||||
}
|
||||
|
||||
inline boost::system::error_code make_error_code(netdb_errors e)
|
||||
{
|
||||
return boost::system::error_code(static_cast<int>(e), netdb_category);
|
||||
}
|
||||
|
||||
inline boost::system::error_code make_error_code(addrinfo_errors e)
|
||||
{
|
||||
return boost::system::error_code(static_cast<int>(e), addrinfo_category);
|
||||
}
|
||||
|
||||
inline boost::system::error_code make_error_code(misc_errors e)
|
||||
{
|
||||
return boost::system::error_code(static_cast<int>(e), misc_category);
|
||||
}
|
||||
|
||||
} // namespace error
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
@@ -531,7 +410,6 @@ private:
|
||||
#undef BOOST_ASIO_SOCKET_ERROR
|
||||
#undef BOOST_ASIO_NETDB_ERROR
|
||||
#undef BOOST_ASIO_GETADDRINFO_ERROR
|
||||
#undef BOOST_ASIO_MISC_ERROR
|
||||
#undef BOOST_ASIO_WIN_OR_POSIX
|
||||
|
||||
|
||||
|
||||
@@ -312,7 +312,8 @@ namespace detail
|
||||
if (streambuf_.size() == streambuf_.max_size())
|
||||
{
|
||||
std::size_t bytes = 0;
|
||||
handler_(error::not_found, bytes);
|
||||
boost::system::error_code ec(error::not_found);
|
||||
handler_(ec, bytes);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -389,7 +390,8 @@ void async_read_until(AsyncReadStream& s,
|
||||
// No match. Check if buffer is full.
|
||||
if (b.size() == b.max_size())
|
||||
{
|
||||
s.io_service().post(detail::bind_handler(handler, error::not_found, 0));
|
||||
boost::system::error_code ec(error::not_found);
|
||||
s.io_service().post(detail::bind_handler(handler, ec, 0));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -470,7 +472,8 @@ namespace detail
|
||||
if (streambuf_.size() == streambuf_.max_size())
|
||||
{
|
||||
std::size_t bytes = 0;
|
||||
handler_(error::not_found, bytes);
|
||||
boost::system::error_code ec(error::not_found);
|
||||
handler_(ec, bytes);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -560,7 +563,8 @@ void async_read_until(AsyncReadStream& s,
|
||||
// Check if buffer is full.
|
||||
if (b.size() == b.max_size())
|
||||
{
|
||||
s.io_service().post(detail::bind_handler(handler, error::not_found, 0));
|
||||
boost::system::error_code ec(error::not_found);
|
||||
s.io_service().post(detail::bind_handler(handler, ec, 0));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -642,7 +646,8 @@ namespace detail
|
||||
if (streambuf_.size() == streambuf_.max_size())
|
||||
{
|
||||
std::size_t bytes = 0;
|
||||
handler_(error::not_found, bytes);
|
||||
boost::system::error_code ec(error::not_found);
|
||||
handler_(ec, bytes);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -732,7 +737,8 @@ void async_read_until(AsyncReadStream& s,
|
||||
// Check if buffer is full.
|
||||
if (b.size() == b.max_size())
|
||||
{
|
||||
s.io_service().post(detail::bind_handler(handler, error::not_found, 0));
|
||||
boost::system::error_code ec(error::not_found);
|
||||
s.io_service().post(detail::bind_handler(handler, ec, 0));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -175,12 +175,12 @@ public:
|
||||
if (error_code == SSL_ERROR_SYSCALL)
|
||||
{
|
||||
return handler_(boost::system::error_code(
|
||||
sys_error_code, boost::system::native_ecat), rc);
|
||||
sys_error_code, boost::asio::error::system_category), rc);
|
||||
}
|
||||
else
|
||||
{
|
||||
return handler_(boost::system::error_code(
|
||||
error_code, boost::asio::error::ssl_ecat()), rc);
|
||||
error_code, boost::asio::error::ssl_category), rc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user