0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-09-27 11:18:51 +02:00

ircd::net: Convey ALPN selection to socket instance.

This commit is contained in:
Jason Volk 2020-05-30 23:08:09 -07:00
parent 47d1ac40c3
commit a70a6164be
3 changed files with 15 additions and 2 deletions

View file

@ -59,6 +59,7 @@ struct ircd::net::socket
stat in, out;
deadline_timer timer;
uint64_t timer_sem[2] {0}; // handler, sender
char alpn[12] {0};
bool timer_set {false}; // boolean lockout
bool timedout {false};
bool fini {false};

View file

@ -1047,14 +1047,23 @@ const
thread_local char buf[512];
thread_local char rembuf[128];
thread_local char locbuf[128];
const string_view alpn
{
sock?
sock->alpn:
nullptr
};
return fmt::sprintf
{
buf, "socket:%lu local:%s remote:%s client:%lu req:%lu:%lu",
buf, "socket:%lu local:%s remote:%s client:%lu %s %lu:%lu",
sock? net::id(*sock) : -1UL,
string(locbuf, ircd::local(*this)),
string(rembuf, ircd::remote(*this)),
id,
alpn?: "h1"_sv,
ready_count,
request_count
request_count,
};
}

View file

@ -851,7 +851,10 @@ ircd::net::acceptor::handle_alpn(socket &socket,
//NOTE: proto == "h2" condition goes here
for(const auto &proto : in)
if(proto == "http/1.1")
{
strlcpy(socket.alpn, proto);
return proto;
}
return {};
}