0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-29 10:12:39 +01:00

ircd: Various error handling fixes/cleanup.

This commit is contained in:
Jason Volk 2018-01-08 03:07:20 -08:00
parent b507262582
commit f8127957c3
3 changed files with 11 additions and 4 deletions

View file

@ -53,6 +53,7 @@ struct ircd::client
std::shared_ptr<socket> sock;
ircd::timer request_timer;
bool handle(parse::buffer &pb);
bool main() noexcept;
public:

View file

@ -377,6 +377,10 @@ catch(const boost::system::system_error &e)
using boost::asio::error::get_ssl_category;
using boost::asio::error::get_misc_category;
log::debug("client(%p): handle error: %s",
(const void *)this,
string(e.code()));
const error_code &ec{e.code()};
const int &value{ec.value()};
if(ec.category() == system_category()) switch(value)
@ -404,6 +408,9 @@ catch(const boost::system::system_error &e)
else if(ec.category() == get_ssl_category()) switch(uint8_t(value))
{
case SSL_R_SHORT_READ:
close(*this, net::dc::RST, net::close_ignore);
return false;
case SSL_R_PROTOCOL_IS_SHUTDOWN:
close(*this, net::dc::RST, net::close_ignore);
return false;

View file

@ -80,7 +80,7 @@ catch(const http::error &e)
return true;
}
}
catch(const std::exception &e)
catch(const ircd::error &e)
{
log::error("client[%s]: in %ld$us: %s",
string(remote(client)),
@ -606,9 +606,8 @@ ircd::resource::response::response(client &client,
const vector_view<const http::header> &headers)
{
char buf[serialized(headers)];
const mutable_buffer mb{buf, sizeof(buf)};
stream_buffer sb{mb};
write(sb, headers);
stream_buffer sb{{buf, sizeof(buf)}};
http::write(sb, headers);
response
{
client, content, content_type, code, sb.completed()