reupping asio and some lt fixes

This commit is contained in:
Marcos Pinto 2007-09-12 22:43:51 +00:00
parent b0fdc2fab8
commit b7f0447228
33 changed files with 308 additions and 350 deletions

View File

@ -157,7 +157,8 @@ public:
int result = epoll_ctl(epoll_fd_, EPOLL_CTL_MOD, descriptor, &ev);
if (result != 0)
{
asio::error_code ec(errno, asio::native_ecat);
asio::error_code ec(errno,
asio::error::system_category);
read_op_queue_.dispatch_all_operations(descriptor, ec);
}
}
@ -190,7 +191,8 @@ public:
int result = epoll_ctl(epoll_fd_, EPOLL_CTL_MOD, descriptor, &ev);
if (result != 0)
{
asio::error_code ec(errno, asio::native_ecat);
asio::error_code ec(errno,
asio::error::system_category);
write_op_queue_.dispatch_all_operations(descriptor, ec);
}
}
@ -219,7 +221,8 @@ public:
int result = epoll_ctl(epoll_fd_, EPOLL_CTL_MOD, descriptor, &ev);
if (result != 0)
{
asio::error_code ec(errno, asio::native_ecat);
asio::error_code ec(errno,
asio::error::system_category);
except_op_queue_.dispatch_all_operations(descriptor, ec);
}
}
@ -250,7 +253,8 @@ public:
int result = epoll_ctl(epoll_fd_, EPOLL_CTL_MOD, descriptor, &ev);
if (result != 0)
{
asio::error_code ec(errno, asio::native_ecat);
asio::error_code ec(errno,
asio::error::system_category);
write_op_queue_.dispatch_all_operations(descriptor, ec);
except_op_queue_.dispatch_all_operations(descriptor, ec);
}
@ -427,7 +431,8 @@ private:
int result = epoll_ctl(epoll_fd_, EPOLL_CTL_MOD, descriptor, &ev);
if (result != 0)
{
ec = asio::error_code(errno, asio::native_ecat);
ec = asio::error_code(errno,
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);
@ -485,8 +490,10 @@ private:
int fd = epoll_create(epoll_size);
if (fd == -1)
{
boost::throw_exception(asio::system_error(
asio::error_code(errno, asio::native_ecat),
boost::throw_exception(
asio::system_error(
asio::error_code(errno,
asio::error::system_category),
"epoll"));
}
return fd;

View File

@ -150,7 +150,8 @@ public:
EV_SET(&event, descriptor, EVFILT_READ, EV_ADD, 0, 0, 0);
if (::kevent(kqueue_fd_, &event, 1, 0, 0, 0) == -1)
{
asio::error_code ec(errno, asio::native_ecat);
asio::error_code ec(errno,
asio::error::system_category);
read_op_queue_.dispatch_all_operations(descriptor, ec);
}
}
@ -176,7 +177,8 @@ public:
EV_SET(&event, descriptor, EVFILT_WRITE, EV_ADD, 0, 0, 0);
if (::kevent(kqueue_fd_, &event, 1, 0, 0, 0) == -1)
{
asio::error_code ec(errno, asio::native_ecat);
asio::error_code ec(errno,
asio::error::system_category);
write_op_queue_.dispatch_all_operations(descriptor, ec);
}
}
@ -201,7 +203,8 @@ public:
EV_SET(&event, descriptor, EVFILT_READ, EV_ADD, EV_OOBAND, 0, 0);
if (::kevent(kqueue_fd_, &event, 1, 0, 0, 0) == -1)
{
asio::error_code ec(errno, asio::native_ecat);
asio::error_code ec(errno,
asio::error::system_category);
except_op_queue_.dispatch_all_operations(descriptor, ec);
}
}
@ -224,7 +227,8 @@ public:
EV_SET(&event, descriptor, EVFILT_WRITE, EV_ADD, 0, 0, 0);
if (::kevent(kqueue_fd_, &event, 1, 0, 0, 0) == -1)
{
asio::error_code ec(errno, asio::native_ecat);
asio::error_code ec(errno,
asio::error::system_category);
write_op_queue_.dispatch_all_operations(descriptor, ec);
}
}
@ -238,7 +242,8 @@ public:
EV_SET(&event, descriptor, EVFILT_READ, EV_ADD, EV_OOBAND, 0, 0);
if (::kevent(kqueue_fd_, &event, 1, 0, 0, 0) == -1)
{
asio::error_code ec(errno, asio::native_ecat);
asio::error_code ec(errno,
asio::error::system_category);
except_op_queue_.dispatch_all_operations(descriptor, ec);
write_op_queue_.dispatch_all_operations(descriptor, ec);
}
@ -392,7 +397,7 @@ private:
if (events[i].flags & EV_ERROR)
{
asio::error_code error(
events[i].data, asio::native_ecat);
events[i].data, asio::error::system_category);
except_op_queue_.dispatch_all_operations(descriptor, error);
read_op_queue_.dispatch_all_operations(descriptor, error);
}
@ -422,7 +427,8 @@ private:
EV_SET(&event, descriptor, EVFILT_READ, EV_DELETE, 0, 0, 0);
if (::kevent(kqueue_fd_, &event, 1, 0, 0, 0) == -1)
{
asio::error_code error(errno, asio::native_ecat);
asio::error_code error(errno,
asio::error::system_category);
except_op_queue_.dispatch_all_operations(descriptor, error);
read_op_queue_.dispatch_all_operations(descriptor, error);
}
@ -434,7 +440,7 @@ private:
if (events[i].flags & EV_ERROR)
{
asio::error_code error(
events[i].data, asio::native_ecat);
events[i].data, asio::error::system_category);
write_op_queue_.dispatch_all_operations(descriptor, error);
}
else
@ -451,7 +457,8 @@ private:
EV_SET(&event, descriptor, EVFILT_WRITE, EV_DELETE, 0, 0, 0);
if (::kevent(kqueue_fd_, &event, 1, 0, 0, 0) == -1)
{
asio::error_code error(errno, asio::native_ecat);
asio::error_code error(errno,
asio::error::system_category);
write_op_queue_.dispatch_all_operations(descriptor, error);
}
}
@ -505,8 +512,10 @@ private:
int fd = kqueue();
if (fd == -1)
{
boost::throw_exception(asio::system_error(
asio::error_code(errno, asio::native_ecat),
boost::throw_exception(
asio::system_error(
asio::error_code(errno,
asio::error::system_category),
"kqueue"));
}
return fd;

View File

@ -29,6 +29,7 @@
#include <pthread.h>
#include "asio/detail/pop_options.hpp"
#include "asio/error.hpp"
#include "asio/system_error.hpp"
#include "asio/detail/noncopyable.hpp"
@ -47,7 +48,7 @@ public:
if (error != 0)
{
asio::system_error e(
asio::error_code(error, asio::native_ecat),
asio::error_code(error, asio::error::system_category),
"event");
boost::throw_exception(e);
}

View File

@ -28,6 +28,7 @@
#include <pthread.h>
#include "asio/detail/pop_options.hpp"
#include "asio/error.hpp"
#include "asio/system_error.hpp"
#include "asio/detail/noncopyable.hpp"
#include "asio/detail/scoped_lock.hpp"
@ -50,7 +51,7 @@ public:
if (error != 0)
{
asio::system_error e(
asio::error_code(error, asio::native_ecat),
asio::error_code(error, asio::error::system_category),
"mutex");
boost::throw_exception(e);
}
@ -69,7 +70,7 @@ public:
if (error != 0)
{
asio::system_error e(
asio::error_code(error, asio::native_ecat),
asio::error_code(error, asio::error::system_category),
"mutex");
boost::throw_exception(e);
}
@ -82,7 +83,7 @@ public:
if (error != 0)
{
asio::system_error e(
asio::error_code(error, asio::native_ecat),
asio::error_code(error, asio::error::system_category),
"mutex");
boost::throw_exception(e);
}

View File

@ -29,6 +29,7 @@
#include <pthread.h>
#include "asio/detail/pop_options.hpp"
#include "asio/error.hpp"
#include "asio/system_error.hpp"
#include "asio/detail/noncopyable.hpp"
@ -52,7 +53,7 @@ public:
if (error != 0)
{
asio::system_error e(
asio::error_code(error, asio::native_ecat),
asio::error_code(error, asio::error::system_category),
"thread");
boost::throw_exception(e);
}

View File

@ -28,6 +28,7 @@
#include <pthread.h>
#include "asio/detail/pop_options.hpp"
#include "asio/error.hpp"
#include "asio/system_error.hpp"
#include "asio/detail/noncopyable.hpp"
@ -46,7 +47,7 @@ public:
if (error != 0)
{
asio::system_error e(
asio::error_code(error, asio::native_ecat),
asio::error_code(error, asio::error::system_category),
"tss");
boost::throw_exception(e);
}

View File

@ -157,7 +157,7 @@ public:
if (int err = reactor_.register_descriptor(sock.get()))
{
ec = asio::error_code(err, asio::native_ecat);
ec = asio::error_code(err, asio::error::system_category);
return ec;
}
@ -181,7 +181,7 @@ public:
if (int err = reactor_.register_descriptor(native_socket))
{
ec = asio::error_code(err, asio::native_ecat);
ec = asio::error_code(err, asio::error::system_category);
return ec;
}
@ -1124,7 +1124,7 @@ public:
bool operator()(const asio::error_code& result)
{
// Check whether the operation was successful.
if (result != 0)
if (result)
{
io_service_.post(bind_handler(handler_, result, 0));
return true;
@ -1489,7 +1489,7 @@ public:
if (connect_error)
{
ec = asio::error_code(connect_error,
asio::native_ecat);
asio::error::system_category);
io_service_.post(bind_handler(handler_, ec));
return true;
}

View File

@ -52,9 +52,10 @@ inline ReturnType error_wrapper(ReturnType return_value,
asio::error_code& ec)
{
#if defined(BOOST_WINDOWS) || defined(__CYGWIN__)
ec = asio::error_code(WSAGetLastError(), asio::native_ecat);
ec = asio::error_code(WSAGetLastError(),
asio::error::system_category);
#else
ec = asio::error_code(errno, asio::native_ecat);
ec = asio::error_code(errno, asio::error::system_category);
#endif
return return_value;
}
@ -923,6 +924,13 @@ inline void gai_free(void* p)
::operator delete(p);
}
inline void gai_strcpy(char* target, const char* source, std::size_t max_size)
{
using namespace std;
*target = 0;
strncat(target, source, max_size);
}
enum { gai_clone_flag = 1 << 30 };
inline int gai_aistruct(addrinfo_type*** next, const addrinfo_type* hints,
@ -1292,14 +1300,15 @@ inline int getaddrinfo_emulation(const char* host, const char* service,
if (host != 0 && host[0] != '\0' && hptr->h_name && hptr->h_name[0]
&& (hints.ai_flags & AI_CANONNAME) && canon == 0)
{
canon = gai_alloc<char>(strlen(hptr->h_name) + 1);
std::size_t canon_len = strlen(hptr->h_name) + 1;
canon = gai_alloc<char>(canon_len);
if (canon == 0)
{
freeaddrinfo_emulation(aihead);
socket_ops::freehostent(hptr);
return EAI_MEMORY;
}
strcpy(canon, hptr->h_name);
gai_strcpy(canon, hptr->h_name, canon_len);
}
// Create an addrinfo structure for each returned address.
@ -1335,13 +1344,14 @@ inline int getaddrinfo_emulation(const char* host, const char* service,
}
else
{
aihead->ai_canonname = gai_alloc<char>(strlen(search[0].host) + 1);
std::size_t canonname_len = strlen(search[0].host) + 1;
aihead->ai_canonname = gai_alloc<char>(canonname_len);
if (aihead->ai_canonname == 0)
{
freeaddrinfo_emulation(aihead);
return EAI_MEMORY;
}
strcpy(aihead->ai_canonname, search[0].host);
gai_strcpy(aihead->ai_canonname, search[0].host, canonname_len);
}
}
gai_free(canon);
@ -1424,8 +1434,7 @@ inline asio::error_code getnameinfo_emulation(
*dot = 0;
}
}
*host = '\0';
strncat(host, hptr->h_name, hostlen);
gai_strcpy(host, hptr->h_name, hostlen);
socket_ops::freehostent(hptr);
}
else
@ -1463,8 +1472,7 @@ inline asio::error_code getnameinfo_emulation(
servent* sptr = ::getservbyport(port, (flags & NI_DGRAM) ? "udp" : 0);
if (sptr && sptr->s_name && sptr->s_name[0] != '\0')
{
*serv = '\0';
strncat(serv, sptr->s_name, servlen);
gai_strcpy(serv, sptr->s_name, servlen);
}
else
{
@ -1518,10 +1526,10 @@ inline asio::error_code translate_addrinfo_error(int error)
default: // Possibly the non-portable EAI_SYSTEM.
#if defined(BOOST_WINDOWS) || defined(__CYGWIN__)
return asio::error_code(
WSAGetLastError(), asio::native_ecat);
WSAGetLastError(), asio::error::system_category);
#else
return asio::error_code(
errno, asio::native_ecat);
errno, asio::error::system_category);
#endif
}
}

View File

@ -23,6 +23,7 @@
#if defined(BOOST_WINDOWS)
#include "asio/error.hpp"
#include "asio/system_error.hpp"
#include "asio/detail/noncopyable.hpp"
#include "asio/detail/socket_types.hpp"
@ -47,7 +48,8 @@ public:
{
DWORD last_error = ::GetLastError();
asio::system_error e(
asio::error_code(last_error, asio::native_ecat),
asio::error_code(last_error,
asio::error::system_category),
"event");
boost::throw_exception(e);
}

View File

@ -63,7 +63,8 @@ public:
{
DWORD last_error = ::GetLastError();
asio::system_error e(
asio::error_code(last_error, asio::native_ecat),
asio::error_code(last_error,
asio::error::system_category),
"iocp");
boost::throw_exception(e);
}
@ -173,7 +174,8 @@ public:
{
DWORD last_error = ::GetLastError();
asio::system_error e(
asio::error_code(last_error, asio::native_ecat),
asio::error_code(last_error,
asio::error::system_category),
"pqcs");
boost::throw_exception(e);
}
@ -228,7 +230,8 @@ public:
{
DWORD last_error = ::GetLastError();
asio::system_error e(
asio::error_code(last_error, asio::native_ecat),
asio::error_code(last_error,
asio::error::system_category),
"pqcs");
boost::throw_exception(e);
}
@ -247,7 +250,8 @@ public:
{
DWORD last_error = ::GetLastError();
asio::system_error e(
asio::error_code(last_error, asio::native_ecat),
asio::error_code(last_error,
asio::error::system_category),
"pqcs");
boost::throw_exception(e);
}
@ -312,7 +316,7 @@ private:
{
DWORD last_error = ::GetLastError();
ec = asio::error_code(last_error,
asio::native_ecat);
asio::error::system_category);
return 0;
}

View File

@ -337,7 +337,8 @@ public:
if (!cancel_io_ex(sock_as_handle, 0))
{
DWORD last_error = ::GetLastError();
ec = asio::error_code(last_error, asio::native_ecat);
ec = asio::error_code(last_error,
asio::error::system_category);
}
else
{
@ -358,7 +359,8 @@ public:
if (!::CancelIo(sock_as_handle))
{
DWORD last_error = ::GetLastError();
ec = asio::error_code(last_error, asio::native_ecat);
ec = asio::error_code(last_error,
asio::error::system_category);
}
else
{
@ -664,7 +666,8 @@ public:
last_error = WSAECONNRESET;
else if (last_error == ERROR_PORT_UNREACHABLE)
last_error = WSAECONNREFUSED;
ec = asio::error_code(last_error, asio::native_ecat);
ec = asio::error_code(last_error,
asio::error::system_category);
return 0;
}
@ -715,7 +718,8 @@ public:
#endif // defined(ASIO_ENABLE_BUFFER_DEBUGGING)
// Map non-portable errors to their portable counterparts.
asio::error_code ec(last_error, asio::native_ecat);
asio::error_code ec(last_error,
asio::error::system_category);
if (ec.value() == ERROR_NETNAME_DELETED)
{
if (handler_op->cancel_token_.expired())
@ -817,7 +821,8 @@ public:
{
asio::io_service::work work(this->io_service());
ptr.reset();
asio::error_code ec(last_error, asio::native_ecat);
asio::error_code ec(last_error,
asio::error::system_category);
iocp_service_.post(bind_handler(handler, ec, bytes_transferred));
}
else
@ -861,7 +866,8 @@ public:
DWORD last_error = ::WSAGetLastError();
if (last_error == ERROR_PORT_UNREACHABLE)
last_error = WSAECONNREFUSED;
ec = asio::error_code(last_error, asio::native_ecat);
ec = asio::error_code(last_error,
asio::error::system_category);
return 0;
}
@ -910,7 +916,8 @@ public:
#endif // defined(ASIO_ENABLE_BUFFER_DEBUGGING)
// Map non-portable errors to their portable counterparts.
asio::error_code ec(last_error, asio::native_ecat);
asio::error_code ec(last_error,
asio::error::system_category);
if (ec.value() == ERROR_PORT_UNREACHABLE)
{
ec = asio::error::connection_refused;
@ -993,7 +1000,8 @@ public:
{
asio::io_service::work work(this->io_service());
ptr.reset();
asio::error_code ec(last_error, asio::native_ecat);
asio::error_code ec(last_error,
asio::error::system_category);
iocp_service_.post(bind_handler(handler, ec, bytes_transferred));
}
else
@ -1047,7 +1055,8 @@ public:
last_error = WSAECONNRESET;
else if (last_error == ERROR_PORT_UNREACHABLE)
last_error = WSAECONNREFUSED;
ec = asio::error_code(last_error, asio::native_ecat);
ec = asio::error_code(last_error,
asio::error::system_category);
return 0;
}
if (bytes_transferred == 0)
@ -1105,7 +1114,8 @@ public:
#endif // defined(ASIO_ENABLE_BUFFER_DEBUGGING)
// Map non-portable errors to their portable counterparts.
asio::error_code ec(last_error, asio::native_ecat);
asio::error_code ec(last_error,
asio::error::system_category);
if (ec.value() == ERROR_NETNAME_DELETED)
{
if (handler_op->cancel_token_.expired())
@ -1212,7 +1222,8 @@ public:
{
asio::io_service::work work(this->io_service());
ptr.reset();
asio::error_code ec(last_error, asio::native_ecat);
asio::error_code ec(last_error,
asio::error::system_category);
iocp_service_.post(bind_handler(handler, ec, bytes_transferred));
}
else
@ -1258,7 +1269,8 @@ public:
DWORD last_error = ::WSAGetLastError();
if (last_error == ERROR_PORT_UNREACHABLE)
last_error = WSAECONNREFUSED;
ec = asio::error_code(last_error, asio::native_ecat);
ec = asio::error_code(last_error,
asio::error::system_category);
return 0;
}
if (bytes_transferred == 0)
@ -1324,7 +1336,8 @@ public:
#endif // defined(ASIO_ENABLE_BUFFER_DEBUGGING)
// Map non-portable errors to their portable counterparts.
asio::error_code ec(last_error, asio::native_ecat);
asio::error_code ec(last_error,
asio::error::system_category);
if (ec.value() == ERROR_PORT_UNREACHABLE)
{
ec = asio::error::connection_refused;
@ -1418,7 +1431,8 @@ public:
{
asio::io_service::work work(this->io_service());
ptr.reset();
asio::error_code ec(last_error, asio::native_ecat);
asio::error_code ec(last_error,
asio::error::system_category);
iocp_service_.post(bind_handler(handler, ec, bytes_transferred));
}
else
@ -1655,7 +1669,8 @@ public:
ptr.reset();
// Call the handler.
asio::error_code ec(last_error, asio::native_ecat);
asio::error_code ec(last_error,
asio::error::system_category);
asio_handler_invoke_helpers::invoke(
detail::bind_handler(handler, ec), &handler);
}
@ -1755,7 +1770,8 @@ public:
{
asio::io_service::work work(this->io_service());
ptr.reset();
asio::error_code ec(last_error, asio::native_ecat);
asio::error_code ec(last_error,
asio::error::system_category);
iocp_service_.post(bind_handler(handler, ec));
}
}
@ -1831,8 +1847,8 @@ public:
// If connection failed then post the handler with the error code.
if (connect_error)
{
ec = asio::error_code(
connect_error, asio::native_ecat);
ec = asio::error_code(connect_error,
asio::error::system_category);
io_service_.post(bind_handler(handler_, ec));
return true;
}

View File

@ -23,6 +23,7 @@
#if defined(BOOST_WINDOWS)
#include "asio/error.hpp"
#include "asio/system_error.hpp"
#include "asio/detail/noncopyable.hpp"
#include "asio/detail/socket_types.hpp"
@ -48,7 +49,7 @@ public:
if (error != 0)
{
asio::system_error e(
asio::error_code(error, asio::native_ecat),
asio::error_code(error, asio::error::system_category),
"mutex");
boost::throw_exception(e);
}
@ -67,7 +68,7 @@ public:
if (error != 0)
{
asio::system_error e(
asio::error_code(error, asio::native_ecat),
asio::error_code(error, asio::error::system_category),
"mutex");
boost::throw_exception(e);
}

View File

@ -23,6 +23,7 @@
#if defined(BOOST_WINDOWS)
#include "asio/error.hpp"
#include "asio/system_error.hpp"
#include "asio/detail/noncopyable.hpp"
#include "asio/detail/socket_types.hpp"
@ -54,7 +55,8 @@ public:
{
DWORD last_error = ::GetLastError();
asio::system_error e(
asio::error_code(last_error, asio::native_ecat),
asio::error_code(last_error,
asio::error::system_category),
"thread");
boost::throw_exception(e);
}

View File

@ -23,6 +23,7 @@
#if defined(BOOST_WINDOWS)
#include "asio/error.hpp"
#include "asio/system_error.hpp"
#include "asio/detail/noncopyable.hpp"
#include "asio/detail/socket_types.hpp"
@ -47,7 +48,8 @@ public:
{
DWORD last_error = ::GetLastError();
asio::system_error e(
asio::error_code(last_error, asio::native_ecat),
asio::error_code(last_error,
asio::error::system_category),
"tss");
boost::throw_exception(e);
}

View File

@ -85,7 +85,8 @@ public:
if (this != &instance_ && ref_->result() != 0)
{
asio::system_error e(
asio::error_code(ref_->result(), asio::native_ecat),
asio::error_code(ref_->result(),
asio::error::system_category),
"winsock");
boost::throw_exception(e);
}

View File

@ -37,327 +37,195 @@
/// INTERNAL ONLY.
# define ASIO_WIN_OR_POSIX(e_win, e_posix) implementation_defined
#elif defined(BOOST_WINDOWS) || defined(__CYGWIN__)
# define ASIO_NATIVE_ERROR(e) \
asio::error_code(e, \
asio::native_ecat)
# define ASIO_SOCKET_ERROR(e) \
asio::error_code(WSA ## e, \
asio::native_ecat)
# define ASIO_NETDB_ERROR(e) \
asio::error_code(WSA ## e, \
asio::native_ecat)
# define ASIO_GETADDRINFO_ERROR(e) \
asio::error_code(WSA ## e, \
asio::native_ecat)
# define ASIO_MISC_ERROR(e) \
asio::error_code(e, \
asio::misc_ecat)
# define ASIO_NATIVE_ERROR(e) e
# define ASIO_SOCKET_ERROR(e) WSA ## e
# define ASIO_NETDB_ERROR(e) WSA ## e
# define ASIO_GETADDRINFO_ERROR(e) WSA ## e
# define ASIO_WIN_OR_POSIX(e_win, e_posix) e_win
#else
# define ASIO_NATIVE_ERROR(e) \
asio::error_code(e, \
asio::native_ecat)
# define ASIO_SOCKET_ERROR(e) \
asio::error_code(e, \
asio::native_ecat)
# define ASIO_NETDB_ERROR(e) \
asio::error_code(e, \
asio::netdb_ecat)
# define ASIO_GETADDRINFO_ERROR(e) \
asio::error_code(e, \
asio::addrinfo_ecat)
# define ASIO_MISC_ERROR(e) \
asio::error_code(e, \
asio::misc_ecat)
# define ASIO_NATIVE_ERROR(e) e
# define ASIO_SOCKET_ERROR(e) e
# define ASIO_NETDB_ERROR(e) e
# define ASIO_GETADDRINFO_ERROR(e) e
# define ASIO_WIN_OR_POSIX(e_win, e_posix) e_posix
#endif
namespace asio {
namespace error {
namespace detail {
/// Hack to keep asio library header-file-only.
template <typename T>
class error_base
enum basic_errors
{
public:
// boostify: error category declarations go here.
/// Permission denied.
static const asio::error_code access_denied;
access_denied = ASIO_SOCKET_ERROR(EACCES),
/// Address family not supported by protocol.
static const asio::error_code address_family_not_supported;
address_family_not_supported = ASIO_SOCKET_ERROR(EAFNOSUPPORT),
/// Address already in use.
static const asio::error_code address_in_use;
address_in_use = ASIO_SOCKET_ERROR(EADDRINUSE),
/// Transport endpoint is already connected.
static const asio::error_code already_connected;
/// Already open.
static const asio::error_code already_open;
already_connected = ASIO_SOCKET_ERROR(EISCONN),
/// Operation already in progress.
static const asio::error_code already_started;
already_started = ASIO_SOCKET_ERROR(EALREADY),
/// A connection has been aborted.
static const asio::error_code connection_aborted;
connection_aborted = ASIO_SOCKET_ERROR(ECONNABORTED),
/// Connection refused.
static const asio::error_code connection_refused;
connection_refused = ASIO_SOCKET_ERROR(ECONNREFUSED),
/// Connection reset by peer.
static const asio::error_code connection_reset;
connection_reset = ASIO_SOCKET_ERROR(ECONNRESET),
/// Bad file descriptor.
static const asio::error_code bad_descriptor;
/// End of file or stream.
static const asio::error_code eof;
bad_descriptor = ASIO_SOCKET_ERROR(EBADF),
/// Bad address.
static const asio::error_code fault;
/// Host not found (authoritative).
static const asio::error_code host_not_found;
/// Host not found (non-authoritative).
static const asio::error_code host_not_found_try_again;
fault = ASIO_SOCKET_ERROR(EFAULT),
/// No route to host.
static const asio::error_code host_unreachable;
host_unreachable = ASIO_SOCKET_ERROR(EHOSTUNREACH),
/// Operation now in progress.
static const asio::error_code in_progress;
in_progress = ASIO_SOCKET_ERROR(EINPROGRESS),
/// Interrupted system call.
static const asio::error_code interrupted;
interrupted = ASIO_SOCKET_ERROR(EINTR),
/// Invalid argument.
static const asio::error_code invalid_argument;
invalid_argument = ASIO_SOCKET_ERROR(EINVAL),
/// Message too long.
static const asio::error_code message_size;
message_size = ASIO_SOCKET_ERROR(EMSGSIZE),
/// Network is down.
static const asio::error_code network_down;
network_down = ASIO_SOCKET_ERROR(ENETDOWN),
/// Network dropped connection on reset.
static const asio::error_code network_reset;
network_reset = ASIO_SOCKET_ERROR(ENETRESET),
/// Network is unreachable.
static const asio::error_code network_unreachable;
network_unreachable = ASIO_SOCKET_ERROR(ENETUNREACH),
/// Too many open files.
static const asio::error_code no_descriptors;
no_descriptors = ASIO_SOCKET_ERROR(EMFILE),
/// No buffer space available.
static const asio::error_code no_buffer_space;
/// The query is valid but does not have associated address data.
static const asio::error_code no_data;
no_buffer_space = ASIO_SOCKET_ERROR(ENOBUFS),
/// Cannot allocate memory.
static const asio::error_code no_memory;
no_memory = ASIO_WIN_OR_POSIX(
ASIO_NATIVE_ERROR(ERROR_OUTOFMEMORY),
ASIO_NATIVE_ERROR(ENOMEM)),
/// Operation not permitted.
static const asio::error_code no_permission;
no_permission = ASIO_WIN_OR_POSIX(
ASIO_NATIVE_ERROR(ERROR_ACCESS_DENIED),
ASIO_NATIVE_ERROR(EPERM)),
/// Protocol not available.
static const asio::error_code no_protocol_option;
/// A non-recoverable error occurred.
static const asio::error_code no_recovery;
no_protocol_option = ASIO_SOCKET_ERROR(ENOPROTOOPT),
/// Transport endpoint is not connected.
static const asio::error_code not_connected;
/// Element not found.
static const asio::error_code not_found;
not_connected = ASIO_SOCKET_ERROR(ENOTCONN),
/// Socket operation on non-socket.
static const asio::error_code not_socket;
not_socket = ASIO_SOCKET_ERROR(ENOTSOCK),
/// Operation cancelled.
static const asio::error_code operation_aborted;
operation_aborted = ASIO_WIN_OR_POSIX(
ASIO_NATIVE_ERROR(ERROR_OPERATION_ABORTED),
ASIO_NATIVE_ERROR(ECANCELED)),
/// Operation not supported.
static const asio::error_code operation_not_supported;
/// The service is not supported for the given socket type.
static const asio::error_code service_not_found;
/// The socket type is not supported.
static const asio::error_code socket_type_not_supported;
operation_not_supported = ASIO_SOCKET_ERROR(EOPNOTSUPP),
/// Cannot send after transport endpoint shutdown.
static const asio::error_code shut_down;
shut_down = ASIO_SOCKET_ERROR(ESHUTDOWN),
/// Connection timed out.
static const asio::error_code timed_out;
timed_out = ASIO_SOCKET_ERROR(ETIMEDOUT),
/// Resource temporarily unavailable.
static const asio::error_code try_again;
try_again = ASIO_WIN_OR_POSIX(
ASIO_NATIVE_ERROR(ERROR_RETRY),
ASIO_NATIVE_ERROR(EAGAIN)),
/// The socket is marked non-blocking and the requested operation would block.
static const asio::error_code would_block;
would_block = ASIO_SOCKET_ERROR(EWOULDBLOCK)
};
private:
error_base();
enum netdb_errors
{
/// Host not found (authoritative).
host_not_found = ASIO_NETDB_ERROR(HOST_NOT_FOUND),
/// Host not found (non-authoritative).
host_not_found_try_again = ASIO_NETDB_ERROR(TRY_AGAIN),
/// The query is valid but does not have associated address data.
no_data = ASIO_NETDB_ERROR(NO_DATA),
/// A non-recoverable error occurred.
no_recovery = ASIO_NETDB_ERROR(NO_RECOVERY)
};
enum addrinfo_errors
{
/// The service is not supported for the given socket type.
service_not_found = ASIO_WIN_OR_POSIX(
ASIO_NATIVE_ERROR(WSATYPE_NOT_FOUND),
ASIO_GETADDRINFO_ERROR(EAI_SERVICE)),
/// The socket type is not supported.
socket_type_not_supported = ASIO_WIN_OR_POSIX(
ASIO_NATIVE_ERROR(WSAESOCKTNOSUPPORT),
ASIO_GETADDRINFO_ERROR(EAI_SOCKTYPE))
};
enum misc_errors
{
/// Already open.
already_open = 1,
/// End of file or stream.
eof,
/// Element not found.
not_found
};
// boostify: error category definitions go here.
template <typename T> const asio::error_code
error_base<T>::access_denied = ASIO_SOCKET_ERROR(EACCES);
template <typename T> const asio::error_code
error_base<T>::address_family_not_supported = ASIO_SOCKET_ERROR(
EAFNOSUPPORT);
template <typename T> const asio::error_code
error_base<T>::address_in_use = ASIO_SOCKET_ERROR(EADDRINUSE);
template <typename T> const asio::error_code
error_base<T>::already_connected = ASIO_SOCKET_ERROR(EISCONN);
template <typename T> const asio::error_code
error_base<T>::already_open = ASIO_MISC_ERROR(1);
template <typename T> const asio::error_code
error_base<T>::already_started = ASIO_SOCKET_ERROR(EALREADY);
template <typename T> const asio::error_code
error_base<T>::connection_aborted = ASIO_SOCKET_ERROR(ECONNABORTED);
template <typename T> const asio::error_code
error_base<T>::connection_refused = ASIO_SOCKET_ERROR(ECONNREFUSED);
template <typename T> const asio::error_code
error_base<T>::connection_reset = ASIO_SOCKET_ERROR(ECONNRESET);
template <typename T> const asio::error_code
error_base<T>::bad_descriptor = ASIO_SOCKET_ERROR(EBADF);
template <typename T> const asio::error_code
error_base<T>::eof = ASIO_MISC_ERROR(2);
template <typename T> const asio::error_code
error_base<T>::fault = ASIO_SOCKET_ERROR(EFAULT);
template <typename T> const asio::error_code
error_base<T>::host_not_found = ASIO_NETDB_ERROR(HOST_NOT_FOUND);
template <typename T> const asio::error_code
error_base<T>::host_not_found_try_again = ASIO_NETDB_ERROR(TRY_AGAIN);
template <typename T> const asio::error_code
error_base<T>::host_unreachable = ASIO_SOCKET_ERROR(EHOSTUNREACH);
template <typename T> const asio::error_code
error_base<T>::in_progress = ASIO_SOCKET_ERROR(EINPROGRESS);
template <typename T> const asio::error_code
error_base<T>::interrupted = ASIO_SOCKET_ERROR(EINTR);
template <typename T> const asio::error_code
error_base<T>::invalid_argument = ASIO_SOCKET_ERROR(EINVAL);
template <typename T> const asio::error_code
error_base<T>::message_size = ASIO_SOCKET_ERROR(EMSGSIZE);
template <typename T> const asio::error_code
error_base<T>::network_down = ASIO_SOCKET_ERROR(ENETDOWN);
template <typename T> const asio::error_code
error_base<T>::network_reset = ASIO_SOCKET_ERROR(ENETRESET);
template <typename T> const asio::error_code
error_base<T>::network_unreachable = ASIO_SOCKET_ERROR(ENETUNREACH);
template <typename T> const asio::error_code
error_base<T>::no_descriptors = ASIO_SOCKET_ERROR(EMFILE);
template <typename T> const asio::error_code
error_base<T>::no_buffer_space = ASIO_SOCKET_ERROR(ENOBUFS);
template <typename T> const asio::error_code
error_base<T>::no_data = ASIO_NETDB_ERROR(NO_DATA);
template <typename T> const asio::error_code
error_base<T>::no_memory = ASIO_WIN_OR_POSIX(
ASIO_NATIVE_ERROR(ERROR_OUTOFMEMORY),
ASIO_NATIVE_ERROR(ENOMEM));
template <typename T> const asio::error_code
error_base<T>::no_permission = ASIO_WIN_OR_POSIX(
ASIO_NATIVE_ERROR(ERROR_ACCESS_DENIED),
ASIO_NATIVE_ERROR(EPERM));
template <typename T> const asio::error_code
error_base<T>::no_protocol_option = ASIO_SOCKET_ERROR(ENOPROTOOPT);
template <typename T> const asio::error_code
error_base<T>::no_recovery = ASIO_NETDB_ERROR(NO_RECOVERY);
template <typename T> const asio::error_code
error_base<T>::not_connected = ASIO_SOCKET_ERROR(ENOTCONN);
template <typename T> const asio::error_code
error_base<T>::not_found = ASIO_MISC_ERROR(3);
template <typename T> const asio::error_code
error_base<T>::not_socket = ASIO_SOCKET_ERROR(ENOTSOCK);
template <typename T> const asio::error_code
error_base<T>::operation_aborted = ASIO_WIN_OR_POSIX(
ASIO_NATIVE_ERROR(ERROR_OPERATION_ABORTED),
ASIO_NATIVE_ERROR(ECANCELED));
template <typename T> const asio::error_code
error_base<T>::operation_not_supported = ASIO_SOCKET_ERROR(EOPNOTSUPP);
template <typename T> const asio::error_code
error_base<T>::service_not_found = ASIO_WIN_OR_POSIX(
ASIO_NATIVE_ERROR(WSATYPE_NOT_FOUND),
ASIO_GETADDRINFO_ERROR(EAI_SERVICE));
template <typename T> const asio::error_code
error_base<T>::socket_type_not_supported = ASIO_WIN_OR_POSIX(
ASIO_NATIVE_ERROR(WSAESOCKTNOSUPPORT),
ASIO_GETADDRINFO_ERROR(EAI_SOCKTYPE));
template <typename T> const asio::error_code
error_base<T>::shut_down = ASIO_SOCKET_ERROR(ESHUTDOWN);
template <typename T> const asio::error_code
error_base<T>::timed_out = ASIO_SOCKET_ERROR(ETIMEDOUT);
template <typename T> const asio::error_code
error_base<T>::try_again = ASIO_WIN_OR_POSIX(
ASIO_NATIVE_ERROR(ERROR_RETRY),
ASIO_NATIVE_ERROR(EAGAIN));
template <typename T> const asio::error_code
error_base<T>::would_block = ASIO_SOCKET_ERROR(EWOULDBLOCK);
} // namespace detail
/// Contains error constants.
class error : public asio::detail::error_base<error>
inline asio::error_code make_error_code(basic_errors e)
{
private:
error();
};
return asio::error_code(static_cast<int>(e), system_category);
}
inline asio::error_code make_error_code(netdb_errors e)
{
return asio::error_code(static_cast<int>(e), netdb_category);
}
inline asio::error_code make_error_code(addrinfo_errors e)
{
return asio::error_code(static_cast<int>(e), addrinfo_category);
}
inline asio::error_code make_error_code(misc_errors e)
{
return asio::error_code(static_cast<int>(e), misc_category);
}
} // namespace error
} // namespace asio
#undef ASIO_NATIVE_ERROR
#undef ASIO_SOCKET_ERROR
#undef ASIO_NETDB_ERROR
#undef ASIO_GETADDRINFO_ERROR
#undef ASIO_MISC_ERROR
#undef ASIO_WIN_OR_POSIX
#include "asio/impl/error_code.ipp"

View File

@ -32,24 +32,27 @@
namespace asio {
/// Available error code categories.
enum error_category
namespace error
{
/// Native error codes.
native_ecat = ASIO_WIN_OR_POSIX(0, 0),
/// Available error code categories.
enum error_category
{
/// System error codes.
system_category = ASIO_WIN_OR_POSIX(0, 0),
/// Error codes from NetDB functions.
netdb_ecat = ASIO_WIN_OR_POSIX(native_ecat, 1),
/// Error codes from NetDB functions.
netdb_category = ASIO_WIN_OR_POSIX(system_category, 1),
/// Error codes from getaddrinfo.
addrinfo_ecat = ASIO_WIN_OR_POSIX(native_ecat, 2),
/// Error codes from getaddrinfo.
addrinfo_category = ASIO_WIN_OR_POSIX(system_category, 2),
/// Miscellaneous error codes.
misc_ecat = ASIO_WIN_OR_POSIX(3, 3),
/// Miscellaneous error codes.
misc_category = ASIO_WIN_OR_POSIX(3, 3),
/// SSL error codes.
ssl_ecat = ASIO_WIN_OR_POSIX(4, 4)
};
/// SSL error codes.
ssl_category = ASIO_WIN_OR_POSIX(4, 4)
};
} // namespace error
/// Class to represent an error code value.
class error_code
@ -61,17 +64,24 @@ public:
/// Default constructor.
error_code()
: value_(0),
category_(native_ecat)
category_(error::system_category)
{
}
/// Construct with specific error code and category.
error_code(value_type v, error_category c)
error_code(value_type v, error::error_category c)
: value_(v),
category_(c)
{
}
/// Construct from an error code enum.
template <typename ErrorEnum>
error_code(ErrorEnum e)
{
*this = make_error_code(e);
}
/// Get the error value.
value_type value() const
{
@ -79,7 +89,7 @@ public:
}
/// Get the error category.
error_category category() const
error::error_category category() const
{
return category_;
}
@ -125,7 +135,7 @@ private:
value_type value_;
// The category associated with the error code.
error_category category_;
error::error_category category_;
};
} // namespace asio

View File

@ -35,10 +35,12 @@ inline std::string error_code::message() const
return "Already open.";
if (*this == error::not_found)
return "Not found.";
if (category_ == ssl_ecat)
if (category_ == error::ssl_category)
return "SSL error.";
#if defined(BOOST_WINDOWS) || defined(__CYGWIN__)
value_type value = value_;
if (category() != error::system_category && *this != error::eof)
return "asio error";
if (*this == error::eof)
value = ERROR_HANDLE_EOF;
char* msg = 0;
@ -76,6 +78,8 @@ inline std::string error_code::message() const
return "Service not found.";
if (*this == error::socket_type_not_supported)
return "Socket type not supported.";
if (category() != error::system_category)
return "asio error";
#if defined(__sun) || defined(__QNX__)
return strerror(value_);
#elif defined(__MACH__) && defined(__APPLE__) \

View File

@ -311,7 +311,8 @@ namespace detail
if (streambuf_.size() == streambuf_.max_size())
{
std::size_t bytes = 0;
handler_(error::not_found, bytes);
asio::error_code ec(error::not_found);
handler_(ec, bytes);
return;
}
@ -388,7 +389,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));
asio::error_code ec(error::not_found);
s.io_service().post(detail::bind_handler(handler, ec, 0));
return;
}
@ -469,7 +471,8 @@ namespace detail
if (streambuf_.size() == streambuf_.max_size())
{
std::size_t bytes = 0;
handler_(error::not_found, bytes);
asio::error_code ec(error::not_found);
handler_(ec, bytes);
return;
}
@ -559,7 +562,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));
asio::error_code ec(error::not_found);
s.io_service().post(detail::bind_handler(handler, ec, 0));
return;
}
@ -641,7 +645,8 @@ namespace detail
if (streambuf_.size() == streambuf_.max_size())
{
std::size_t bytes = 0;
handler_(error::not_found, bytes);
asio::error_code ec(error::not_found);
handler_(ec, bytes);
return;
}
@ -731,7 +736,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));
asio::error_code ec(error::not_found);
s.io_service().post(detail::bind_handler(handler, ec, 0));
return;
}

View File

@ -307,7 +307,7 @@ public:
private:
// Helper function to determine whether the endpoint is IPv4.
#if defined(_AIX)
template <typename T, unsigned short (T::*)> struct is_v4_helper {};
template <typename T, unsigned char (T::*)> struct is_v4_helper {};
template <typename T>
static bool is_v4(const T& ss, is_v4_helper<T, &T::ss_family>* = 0)

View File

@ -174,12 +174,12 @@ public:
if (error_code == SSL_ERROR_SYSCALL)
{
return handler_(asio::error_code(
sys_error_code, asio::native_ecat), rc);
sys_error_code, asio::error::system_category), rc);
}
else
{
return handler_(asio::error_code(
error_code, asio::ssl_ecat), rc);
error_code, asio::error::ssl_category), rc);
}
}

View File

@ -155,8 +155,7 @@ namespace libtorrent
int prefer_whole_pieces() const
{
if (m_prefer_whole_pieces == 0)
return peer_info_struct() && peer_info_struct()->on_parole ? 1 : 0;
if (on_parole()) return 1;
return m_prefer_whole_pieces;
}

View File

@ -117,6 +117,11 @@ namespace libtorrent
// for yet
int download_queue_length;
// the number of requests that is
// tried to be maintained (this is
// typically a function of download speed)
int target_dl_queue_length;
// this is the number of requests
// the peer has sent to us
// that we haven't sent yet

View File

@ -201,8 +201,8 @@ namespace libtorrent
void async_read(
peer_request const& r
, boost::function<void(int, disk_io_job const&)> const& handler
, char* buffer = 0);
, boost::function<void(int, disk_io_job const&)> const& handler
, char* buffer = 0);
void async_write(
peer_request const& r

View File

@ -97,4 +97,3 @@ libtorrent_la_LIBADD = @ZLIB@ -l@BOOST_DATE_TIME_LIB@ -l@BOOST_FILESYSTEM_LIB@ -
AM_CXXFLAGS= -ftemplate-depth-50 -I$(top_srcdir)/include -I$(top_srcdir)/include/libtorrent @ZLIBINCL@ @DEBUGFLAGS@ @PTHREAD_CFLAGS@ -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION
AM_LDFLAGS= $(LDFLAGS) -l@BOOST_DATE_TIME_LIB@ -l@BOOST_FILESYSTEM_LIB@ -l@BOOST_THREAD_LIB@ @PTHREAD_LIBS@

View File

@ -255,4 +255,3 @@ namespace libtorrent
}
}

View File

@ -385,4 +385,3 @@ void http_connection::rate_limit(int limit)
}

View File

@ -2019,8 +2019,9 @@ namespace libtorrent
p.load_balancing = total_free_upload();
p.download_queue_length = (int)download_queue().size();
p.upload_queue_length = (int)upload_queue().size();
p.download_queue_length = int(download_queue().size() + m_request_queue.size());
p.target_dl_queue_length = int(desired_queue_size());
p.upload_queue_length = int(upload_queue().size());
if (boost::optional<piece_block_progress> ret = downloading_piece_progress())
{

View File

@ -1125,7 +1125,7 @@ namespace libtorrent
, interesting_blocks, backup_blocks, num_blocks
, prefer_whole_pieces, peer, speed, on_parole);
if (num_blocks == 0) return;
if (num_blocks <= 0) return;
if (rarest_first)
{
@ -1364,6 +1364,13 @@ namespace libtorrent
if (prefer_whole_pieces > 0 && !exclusive_active) continue;
// don't pick too many back-up blocks
if (i->state != none
&& i->state != speed
&& !exclusive_active
&& int(backup_blocks.size()) >= num_blocks)
continue;
for (int j = 0; j < num_blocks_in_piece; ++j)
{
// ignore completed blocks and already requested blocks
@ -1412,9 +1419,15 @@ namespace libtorrent
if (num_blocks <= 0) return 0;
if (on_parole) return num_blocks;
int to_copy;
if (prefer_whole_pieces == 0)
to_copy = (std::min)(int(backup_blocks.size()), num_blocks);
else
to_copy = int(backup_blocks.size());
interesting_blocks.insert(interesting_blocks.end()
, backup_blocks.begin(), backup_blocks.end());
num_blocks -= int(backup_blocks.size());
, backup_blocks.begin(), backup_blocks.begin() + to_copy);
num_blocks -= to_copy;
backup_blocks.clear();
if (num_blocks <= 0) return 0;

View File

@ -284,6 +284,8 @@ namespace libtorrent
for (std::vector<piece_block>::iterator i = interesting_pieces.begin();
i != interesting_pieces.end(); ++i)
{
if (prefer_whole_pieces == 0 && num_requests <= 0) break;
if (p.is_requested(*i))
{
if (num_requests <= 0) break;

View File

@ -2380,4 +2380,3 @@ namespace detail
}
}}

View File

@ -2209,4 +2209,3 @@ namespace libtorrent
#endif
} // namespace libtorrent

View File

@ -994,4 +994,3 @@ void upnp::close()
}
}