mirror of
https://github.com/boostorg/beast.git
synced 2025-07-31 13:27:33 +02:00
committed by
Richard Hodges
parent
cbeb6ffed1
commit
18ce21d5c9
@ -1,5 +1,6 @@
|
|||||||
Version XXX:
|
Version XXX:
|
||||||
|
|
||||||
|
* Translate some win32 errors to net error codes
|
||||||
* enable circleci integration
|
* enable circleci integration
|
||||||
* flat_buffer shrink_to_fit is noexcept
|
* flat_buffer shrink_to_fit is noexcept
|
||||||
* moved-from dynamic buffers do not clear if different allocator
|
* moved-from dynamic buffers do not clear if different allocator
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include <boost/make_unique.hpp>
|
#include <boost/make_unique.hpp>
|
||||||
#include <boost/smart_ptr/make_shared_array.hpp>
|
#include <boost/smart_ptr/make_shared_array.hpp>
|
||||||
#include <boost/winapi/basic_types.hpp>
|
#include <boost/winapi/basic_types.hpp>
|
||||||
|
#include <boost/winapi/error_codes.hpp>
|
||||||
#include <boost/winapi/get_last_error.hpp>
|
#include <boost/winapi/get_last_error.hpp>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
@ -337,6 +338,47 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// https://github.com/boostorg/beast/issues/1815
|
||||||
|
// developer commentary:
|
||||||
|
// This function mimics the behaviour of ASIO.
|
||||||
|
// Perhaps the correct fix is to insist on the use
|
||||||
|
// of an appropriate error_condition to detect
|
||||||
|
// connection_reset and connection_refused?
|
||||||
|
inline
|
||||||
|
error_code
|
||||||
|
make_win32_error(
|
||||||
|
boost::winapi::DWORD_ dwError) noexcept
|
||||||
|
{
|
||||||
|
// from
|
||||||
|
// https://github.com/boostorg/asio/blob/6534af41b471288091ae39f9ab801594189b6fc9/include/boost/asio/detail/impl/socket_ops.ipp#L842
|
||||||
|
switch(dwError)
|
||||||
|
{
|
||||||
|
case boost::winapi::ERROR_NETNAME_DELETED_:
|
||||||
|
return net::error::connection_reset;
|
||||||
|
case boost::winapi::ERROR_PORT_UNREACHABLE_:
|
||||||
|
return net::error::connection_refused;
|
||||||
|
case boost::winapi::WSAEMSGSIZE_:
|
||||||
|
case boost::winapi::ERROR_MORE_DATA_:
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
return error_code(
|
||||||
|
static_cast<int>(dwError),
|
||||||
|
system_category());
|
||||||
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
error_code
|
||||||
|
make_win32_error(
|
||||||
|
error_code ec) noexcept
|
||||||
|
{
|
||||||
|
if(ec.category() !=
|
||||||
|
system_category())
|
||||||
|
return ec;
|
||||||
|
return make_win32_error(
|
||||||
|
static_cast<boost::winapi::DWORD_>(
|
||||||
|
ec.value()));
|
||||||
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
#if BOOST_ASIO_HAS_WINDOWS_OVERLAPPED_PTR
|
#if BOOST_ASIO_HAS_WINDOWS_OVERLAPPED_PTR
|
||||||
@ -415,8 +457,8 @@ public:
|
|||||||
{
|
{
|
||||||
// VFALCO This needs review, is 0 the right number?
|
// VFALCO This needs review, is 0 the right number?
|
||||||
// completed immediately (with error?)
|
// completed immediately (with error?)
|
||||||
overlapped.complete(error_code{static_cast<int>(dwError),
|
overlapped.complete(
|
||||||
system_category()}, 0);
|
make_win32_error(dwError), 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
overlapped.release();
|
overlapped.release();
|
||||||
@ -427,7 +469,11 @@ public:
|
|||||||
error_code ec,
|
error_code ec,
|
||||||
std::size_t bytes_transferred = 0)
|
std::size_t bytes_transferred = 0)
|
||||||
{
|
{
|
||||||
if(! ec && ! header_)
|
if(ec)
|
||||||
|
{
|
||||||
|
ec = make_win32_error(ec);
|
||||||
|
}
|
||||||
|
else if(! ec && ! header_)
|
||||||
{
|
{
|
||||||
auto& w = sr_.writer_impl();
|
auto& w = sr_.writer_impl();
|
||||||
w.pos_ += bytes_transferred;
|
w.pos_ += bytes_transferred;
|
||||||
@ -527,9 +573,8 @@ write_some(
|
|||||||
0);
|
0);
|
||||||
if(! bSuccess)
|
if(! bSuccess)
|
||||||
{
|
{
|
||||||
ec.assign(static_cast<int>(
|
ec = detail::make_win32_error(
|
||||||
boost::winapi::GetLastError()),
|
boost::winapi::GetLastError());
|
||||||
system_category());
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
w.pos_ += nNumberOfBytesToWrite;
|
w.pos_ += nNumberOfBytesToWrite;
|
||||||
|
Reference in New Issue
Block a user