mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-31 00:34:20 +00:00
[win32] handle WinAPI errors in SSU
Windows can throw WinAPI errors which are not handled by boost asio Signed-off-by: R4SAS <r4sas@i2pmail.org>
This commit is contained in:
parent
cc0367b079
commit
56f3bdd746
@ -13,6 +13,10 @@
|
|||||||
#include "NetDb.hpp"
|
#include "NetDb.hpp"
|
||||||
#include "SSU.h"
|
#include "SSU.h"
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <boost/winapi/error_codes.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace i2p
|
namespace i2p
|
||||||
{
|
{
|
||||||
namespace transport
|
namespace transport
|
||||||
@ -247,11 +251,17 @@ namespace transport
|
|||||||
|
|
||||||
void SSUServer::HandleReceivedFrom (const boost::system::error_code& ecode, std::size_t bytes_transferred, SSUPacket * packet)
|
void SSUServer::HandleReceivedFrom (const boost::system::error_code& ecode, std::size_t bytes_transferred, SSUPacket * packet)
|
||||||
{
|
{
|
||||||
if (!ecode ||
|
if (!ecode
|
||||||
ecode == boost::asio::error::connection_refused ||
|
|| ecode == boost::asio::error::connection_refused
|
||||||
ecode == boost::asio::error::connection_reset ||
|
|| ecode == boost::asio::error::connection_reset
|
||||||
ecode == boost::asio::error::network_unreachable ||
|
|| ecode == boost::asio::error::network_unreachable
|
||||||
ecode == boost::asio::error::host_unreachable)
|
|| ecode == boost::asio::error::host_unreachable
|
||||||
|
#ifdef _WIN32 // windows can throw WinAPI error, which is not handled by ASIO
|
||||||
|
|| ecode.value() == boost::winapi::ERROR_CONNECTION_REFUSED_
|
||||||
|
|| ecode.value() == boost::winapi::ERROR_NETWORK_UNREACHABLE_
|
||||||
|
|| ecode.value() == boost::winapi::ERROR_HOST_UNREACHABLE_
|
||||||
|
#endif
|
||||||
|
)
|
||||||
// just try continue reading when received ICMP response otherwise socket can crash,
|
// just try continue reading when received ICMP response otherwise socket can crash,
|
||||||
// but better to find out which host were sent it and mark that router as unreachable
|
// but better to find out which host were sent it and mark that router as unreachable
|
||||||
{
|
{
|
||||||
@ -300,11 +310,17 @@ namespace transport
|
|||||||
|
|
||||||
void SSUServer::HandleReceivedFromV6 (const boost::system::error_code& ecode, std::size_t bytes_transferred, SSUPacket * packet)
|
void SSUServer::HandleReceivedFromV6 (const boost::system::error_code& ecode, std::size_t bytes_transferred, SSUPacket * packet)
|
||||||
{
|
{
|
||||||
if (!ecode ||
|
if (!ecode
|
||||||
ecode == boost::asio::error::connection_refused ||
|
|| ecode == boost::asio::error::connection_refused
|
||||||
ecode == boost::asio::error::connection_reset ||
|
|| ecode == boost::asio::error::connection_reset
|
||||||
ecode == boost::asio::error::network_unreachable ||
|
|| ecode == boost::asio::error::network_unreachable
|
||||||
ecode == boost::asio::error::host_unreachable)
|
|| ecode == boost::asio::error::host_unreachable
|
||||||
|
#ifdef _WIN32 // windows can throw WinAPI error, which is not handled by ASIO
|
||||||
|
|| ecode.value() == boost::winapi::ERROR_CONNECTION_REFUSED_
|
||||||
|
|| ecode.value() == boost::winapi::ERROR_NETWORK_UNREACHABLE_
|
||||||
|
|| ecode.value() == boost::winapi::ERROR_HOST_UNREACHABLE_
|
||||||
|
#endif
|
||||||
|
)
|
||||||
// just try continue reading when received ICMP response otherwise socket can crash,
|
// just try continue reading when received ICMP response otherwise socket can crash,
|
||||||
// but better to find out which host were sent it and mark that router as unreachable
|
// but better to find out which host were sent it and mark that router as unreachable
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user