0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-11 06:28:55 +02:00

ircd::net: Consolidate all eof error_code related.

This commit is contained in:
Jason Volk 2019-09-13 11:49:08 -07:00
parent e71e93fe5f
commit b19ed6854b
4 changed files with 37 additions and 46 deletions

View file

@ -29,10 +29,9 @@ namespace ircd::net
IRCD_EXCEPTION(error, inauthentic)
IRCD_EXCEPTION(error, not_found)
// SNOMASK 'N' "net"
extern log::log log;
extern const std::error_code eof;
extern conf::item<bool> enable_ipv6;
extern log::log log;
}
#include "hostport.h"

View file

@ -498,11 +498,6 @@ ircd::handle_ec(client &client,
case int(errc::timed_out): return handle_ec_timeout(client);
default: return handle_ec_default(client, ec);
}
else if(ec.category() == get_misc_category()) switch(ec.value())
{
case asio::error::eof: return handle_ec_eof(client);
default: return handle_ec_default(client, ec);
}
else if(ec.category() == get_ssl_category()) switch(uint8_t(ec.value()))
{
#ifdef SSL_R_SHORT_READ
@ -510,7 +505,10 @@ ircd::handle_ec(client &client,
#endif
default: return handle_ec_default(client, ec);
}
else return handle_ec_default(client, ec);
else if(ec == net::eof)
return handle_ec_eof(client);
else
return handle_ec_default(client, ec);
}
/// The client indicated they will not be sending the data we have been

View file

@ -91,11 +91,14 @@ noexcept
// net/net.h
//
/// Network subsystem log facility with dedicated SNOMASK.
struct ircd::log::log
ircd::net::log
decltype(ircd::net::eof)
ircd::net::eof
{
"net", 'N'
make_error_code(boost::system::error_code
{
boost::asio::error::eof,
boost::asio::error::get_misc_category()
})
};
decltype(ircd::net::enable_ipv6)
@ -106,6 +109,13 @@ ircd::net::enable_ipv6
{ "persist", false },
};
/// Network subsystem log facility
decltype(ircd::net::log)
ircd::net::log
{
"net", 'N'
};
ircd::string_view
ircd::net::peer_cert_der_sha256_b64(const mutable_buffer &buf,
const socket &socket)
@ -3162,10 +3172,7 @@ noexcept
static const ilist<mutable_buffer> bufs{buf};
static const std::error_code eof
{
make_error_code(boost::system::error_code
{
boost::asio::error::eof, boost::asio::error::get_misc_category()
})
buf
};
if(unlikely(!sd.is_open()))
@ -3223,7 +3230,7 @@ try
if(!ret)
throw std::system_error
{
boost::asio::error::eof, boost::asio::error::get_misc_category()
eof
};
++in.calls;
@ -3261,7 +3268,7 @@ try
if(!ret)
throw std::system_error
{
asio::error::eof, asio::error::get_misc_category()
eof
};
++in.calls;
@ -3478,7 +3485,7 @@ noexcept try
ec = make_error_code(errc::bad_file_descriptor);
if(type == ready::READ && !ec && bytes == 0)
ec = error_code{asio::error::eof, asio::error::get_misc_category()};
ec = eof;
#ifdef IRCD_DEBUG_NET_SOCKET_READY
const auto has_pending
@ -3717,9 +3724,8 @@ noexcept try
};
// This ignores EOF and turns it into a success to alleviate user concern.
if(ec.category() == asio::error::get_misc_category())
if(ec.value() == asio::error::eof)
ec = error_code{};
if(ec == eof)
ec = error_code{};
sd.close();
call_user(callback, ec);

View file

@ -944,22 +944,18 @@ ircd::server::peer::handle_error(link &link,
default:
break;
}
else if(ec.category() == get_misc_category()) switch(ec.value())
else if(ec == net::eof)
{
case asio::error::eof:
log::debug
{
log, "%s [%s]: %s",
loghead(link),
string(rembuf, remote),
e.what()
};
log::debug
{
log, "%s [%s]: %s",
loghead(link),
string(rembuf, remote),
e.what()
};
link.close(net::dc::RST);
return;
default:
break;
link.close(net::dc::RST);
return;
}
log::derror
@ -2348,17 +2344,9 @@ ircd::server::link::discard_read()
return;
}
static const std::error_code end_of_file
{
make_error_code(boost::system::error_code
{
boost::asio::error::eof, boost::asio::error::get_misc_category()
})
};
throw std::system_error
{
end_of_file
net::eof
};
}