0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-30 17:34:04 +01:00

ircd: Take some buffers off the stack.

This commit is contained in:
Jason Volk 2018-01-11 18:41:27 -08:00
parent a135227370
commit f99461481c
3 changed files with 32 additions and 11 deletions

View file

@ -1784,7 +1784,8 @@ noexcept try
if(!valid)
{
char buf[256];
thread_local char buf[256];
const critical_assertion ca;
log.warning("verify: %s /CN=%s :%s",
common_name(opts),
openssl::subject_common_name(buf, cert),
@ -1832,7 +1833,8 @@ noexcept try
if(!verifier(true, vc))
{
char buf[256];
thread_local char buf[256];
const critical_assertion ca;
throw inauthentic
{
"/CN=%s does not match target host %s :%s",
@ -1843,6 +1845,14 @@ noexcept try
}
}
{
thread_local char buf[512];
const critical_assertion ca;
log.debug("verify[%s]: %s",
common_name(opts),
openssl::print(buf, cert));
}
return true;
}
catch(const inauthentic &e)
@ -2241,7 +2251,8 @@ ircd::net::_resolve(const ipport &ipport,
std::ostream &
ircd::net::operator<<(std::ostream &s, const remote &t)
{
char buf[256];
thread_local char buf[256];
const critical_assertion ca;
s << string(buf, t);
return s;
}
@ -2280,7 +2291,8 @@ ircd::net::string(const mutable_buffer &buf,
std::ostream &
ircd::net::operator<<(std::ostream &s, const ipport &t)
{
char buf[256];
thread_local char buf[256];
const critical_assertion ca;
s << string(buf, t);
return s;
}
@ -2410,7 +2422,8 @@ ircd::net::ipport::ipport(const boost::asio::ip::address &address,
std::ostream &
ircd::net::operator<<(std::ostream &s, const hostport &t)
{
char buf[256];
thread_local char buf[256];
const critical_assertion ca;
s << string(buf, t);
return s;
}

View file

@ -894,8 +894,8 @@ ircd::openssl::bignum::bignum(const const_raw_buffer &bin)
:a{[&bin]
{
// Our binary buffer is little endian. We use
const ctx::critical_assertion ca;
static thread_local uint8_t tmp[64_KiB];
thread_local uint8_t tmp[64_KiB];
const critical_assertion ca;
const mutable_raw_buffer buf{tmp, size(bin)};
if(unlikely(size(buf) > sizeof(tmp)))
throw buffer_error

View file

@ -606,9 +606,15 @@ ircd::resource::response::response(client &client,
const http::code &code,
const vector_view<const http::header> &headers)
{
char buf[serialized(headers)];
stream_buffer sb{{buf, sizeof(buf)}};
http::write(sb, headers);
// contents of this buffer get copied again when further passed to
// response{}; we can get this off the stack if that remains true.
thread_local char buffer[2_KiB];
stream_buffer sb{buffer};
{
const critical_assertion ca;
http::write(sb, headers);
}
response
{
client, content, content_type, code, sb.completed()
@ -639,7 +645,9 @@ ircd::resource::response::response(client &client,
""
};
char head_buf[2048];
// This buffer will be passed to the socket and sent out;
// cannot be static/tls.
char head_buf[2_KiB];
stream_buffer head{head_buf};
http::response
{