mirror of
https://github.com/matrix-construct/construct
synced 2024-12-26 15:33:54 +01:00
ircd: Fixes to client related to net.
This commit is contained in:
parent
f10662fe7d
commit
8b573378e8
1 changed files with 20 additions and 14 deletions
|
@ -196,7 +196,7 @@ ircd::client::client(const hostport &host_port,
|
||||||
const seconds &timeout)
|
const seconds &timeout)
|
||||||
:client
|
:client
|
||||||
{
|
{
|
||||||
std::make_shared<socket>(host_port.first, host_port.second, timeout)
|
std::make_shared<socket>(host_port, timeout)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -209,8 +209,15 @@ ircd::client::client(std::shared_ptr<socket> sock)
|
||||||
}
|
}
|
||||||
|
|
||||||
ircd::client::~client()
|
ircd::client::~client()
|
||||||
noexcept
|
noexcept try
|
||||||
{
|
{
|
||||||
|
if(sock)
|
||||||
|
sock->disconnect(socket::dc::SSL_NOTIFY);
|
||||||
|
}
|
||||||
|
catch(const std::exception &e)
|
||||||
|
{
|
||||||
|
log::error("~client(%p): %s", this, e.what());
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace ircd
|
namespace ircd
|
||||||
|
@ -268,7 +275,7 @@ catch(const boost::system::system_error &e)
|
||||||
|
|
||||||
log::critical("(unexpected) system_error: %s", e.what());
|
log::critical("(unexpected) system_error: %s", e.what());
|
||||||
if(ircd::debugmode)
|
if(ircd::debugmode)
|
||||||
std::terminate();
|
throw;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -279,7 +286,7 @@ catch(const std::exception &e)
|
||||||
e.what());
|
e.what());
|
||||||
|
|
||||||
if(ircd::debugmode)
|
if(ircd::debugmode)
|
||||||
std::terminate();
|
throw;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -297,17 +304,19 @@ try
|
||||||
client.sock->cancel();
|
client.sock->cancel();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
bool ret{true};
|
||||||
http::request
|
http::request
|
||||||
{
|
{
|
||||||
pc, nullptr, write_closure(client), [&client, &pc]
|
pc, nullptr, write_closure(client), [&client, &pc, &ret]
|
||||||
(const auto &head)
|
(const auto &head)
|
||||||
{
|
{
|
||||||
client.sock->timer.cancel();
|
client.sock->timer.cancel();
|
||||||
handle_request(client, pc, head);
|
handle_request(client, pc, head);
|
||||||
|
ret = !iequals(head.connection, "close"s);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return true;
|
return ret;
|
||||||
}
|
}
|
||||||
catch(const http::error &e)
|
catch(const http::error &e)
|
||||||
{
|
{
|
||||||
|
@ -460,6 +469,7 @@ ircd::handle_ec(client &client,
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
log::debug("client(%p): %s", &client, ec.message());
|
log::debug("client(%p): %s", &client, ec.message());
|
||||||
|
disconnect(client, socket::dc::RST);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -475,13 +485,10 @@ bool
|
||||||
ircd::handle_ec_eof(client &client)
|
ircd::handle_ec_eof(client &client)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
assert(bool(client.sock));
|
log::debug("client[%s]: EOF",
|
||||||
auto &sock(*client.sock);
|
string(remote(client)));
|
||||||
log::debug("client[%s]: EOF (avail: %zu)",
|
|
||||||
string(remote(client)),
|
|
||||||
available(sock));
|
|
||||||
|
|
||||||
sock.disconnect(socket::RST);
|
disconnect(client, socket::dc::RST);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
catch(const std::exception &e)
|
catch(const std::exception &e)
|
||||||
|
@ -498,11 +505,10 @@ ircd::handle_ec_timeout(client &client)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
assert(bool(client.sock));
|
assert(bool(client.sock));
|
||||||
auto &sock(*client.sock);
|
|
||||||
log::debug("client[%s]: disconnecting after inactivity timeout",
|
log::debug("client[%s]: disconnecting after inactivity timeout",
|
||||||
string(remote(client)));
|
string(remote(client)));
|
||||||
|
|
||||||
sock.disconnect();
|
disconnect(client, socket::dc::SSL_NOTIFY);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
catch(const std::exception &e)
|
catch(const std::exception &e)
|
||||||
|
|
Loading…
Reference in a new issue