0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-26 07:23:53 +01:00

ircd::server: Add monotonic identity counters for peers and links.

This commit is contained in:
Jason Volk 2019-04-11 22:18:47 -07:00
parent d38c5801c9
commit 4f27526e9b
6 changed files with 33 additions and 9 deletions

View file

@ -17,7 +17,9 @@ struct ircd::server::link
{
static conf::item<size_t> tag_max_default;
static conf::item<size_t> tag_commit_max_default;
static uint64_t ids;
uint64_t id {++ids}; ///< unique identifier of link.
server::peer *peer; ///< backreference to peer
std::shared_ptr<net::socket> socket; ///< link's socket
std::list<tag> queue; ///< link's work queue

View file

@ -27,7 +27,9 @@ struct ircd::server::peer
static conf::item<size_t> link_min_default;
static conf::item<size_t> link_max_default;
static conf::item<seconds> error_clear_default;
static uint64_t ids;
uint64_t id {++ids};
net::ipport remote;
std::string hostcanon;
std::string service;

View file

@ -21,6 +21,9 @@ namespace ircd::server
size_t size(const out &);
size_t size_chunks(const in &);
// gets the unique tag number from request or 0 if no tag associated.
uint64_t id(const request &);
string_view loghead(const mutable_buffer &out, const request &);
string_view loghead(const request &);

View file

@ -28,7 +28,10 @@ struct ircd::server::tag
{
struct state
{
size_t written {0};
static uint64_t ids;
uint64_t id {++ids}; // monotonic tag identifier
size_t written {0}; // bytes transmitted to remote
size_t head_read {0}; // includes head terminator
size_t head_rem {0}; // how much of head buf wasn't used.
size_t content_read {0}; // total content read after head

View file

@ -409,11 +409,12 @@ catch(const std::exception &e)
return "<critical error>";
}
ircd::string_view
ircd::server::loghead(const request &request)
uint64_t
ircd::server::id(const request &request)
{
thread_local char buf[256];
return loghead(buf, request);
return request.tag?
request.tag->state.id:
0UL;
}
//
@ -512,6 +513,9 @@ ircd::server::peer::link_max_default
{ "default", 2L }
};
decltype(ircd::server::peer::ids)
ircd::server::peer::ids;
//
// peer::peer
//
@ -1567,6 +1571,9 @@ ircd::server::link::tag_commit_max_default
{ "default", 3L }
};
decltype(ircd::server::link::ids)
ircd::server::link::ids;
//
// link::link
//
@ -2327,6 +2334,10 @@ const
// tag
//
/// Monotonic counter for tags.
decltype(ircd::server::tag::state::ids)
ircd::server::tag::state::ids;
/// This is tricky. When a user cancels a request which has committed some
/// writes to the remote we have to continue to service it through to
/// completion without disrupting the linearity of the link's pipeline

View file

@ -4307,10 +4307,13 @@ try
"<no socket>"_sv
};
out << std::setw(48) << peer.server_name << " "
<< std::setw(56) << remote << " "
<< std::setw(8) << out_head.method << " "
<< std::setw(0) << out_head.path << " "
out << std::right << std::setw(8) << peer.id << " "
<< std::left << std::setw(40) << peer.hostcanon << " "
<< std::right << std::setw(8) << link.id << " "
<< std::left << std::setw(40) << remote << " "
<< std::right << std::setw(8) << id(request) << " "
<< std::left << std::setw(8) << out_head.method << " "
<< std::left << std::setw(0) << out_head.path << " "
<< std::endl;
return true;