mirror of
https://github.com/matrix-construct/construct
synced 2024-12-26 15:33:54 +01:00
ircd::server: Add monotonic identity counters for peers and links.
This commit is contained in:
parent
d38c5801c9
commit
4f27526e9b
6 changed files with 33 additions and 9 deletions
|
@ -17,7 +17,9 @@ struct ircd::server::link
|
||||||
{
|
{
|
||||||
static conf::item<size_t> tag_max_default;
|
static conf::item<size_t> tag_max_default;
|
||||||
static conf::item<size_t> tag_commit_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
|
server::peer *peer; ///< backreference to peer
|
||||||
std::shared_ptr<net::socket> socket; ///< link's socket
|
std::shared_ptr<net::socket> socket; ///< link's socket
|
||||||
std::list<tag> queue; ///< link's work queue
|
std::list<tag> queue; ///< link's work queue
|
||||||
|
|
|
@ -27,7 +27,9 @@ struct ircd::server::peer
|
||||||
static conf::item<size_t> link_min_default;
|
static conf::item<size_t> link_min_default;
|
||||||
static conf::item<size_t> link_max_default;
|
static conf::item<size_t> link_max_default;
|
||||||
static conf::item<seconds> error_clear_default;
|
static conf::item<seconds> error_clear_default;
|
||||||
|
static uint64_t ids;
|
||||||
|
|
||||||
|
uint64_t id {++ids};
|
||||||
net::ipport remote;
|
net::ipport remote;
|
||||||
std::string hostcanon;
|
std::string hostcanon;
|
||||||
std::string service;
|
std::string service;
|
||||||
|
|
|
@ -21,6 +21,9 @@ namespace ircd::server
|
||||||
size_t size(const out &);
|
size_t size(const out &);
|
||||||
size_t size_chunks(const in &);
|
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 mutable_buffer &out, const request &);
|
||||||
string_view loghead(const request &);
|
string_view loghead(const request &);
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,10 @@ struct ircd::server::tag
|
||||||
{
|
{
|
||||||
struct state
|
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_read {0}; // includes head terminator
|
||||||
size_t head_rem {0}; // how much of head buf wasn't used.
|
size_t head_rem {0}; // how much of head buf wasn't used.
|
||||||
size_t content_read {0}; // total content read after head
|
size_t content_read {0}; // total content read after head
|
||||||
|
|
|
@ -409,11 +409,12 @@ catch(const std::exception &e)
|
||||||
return "<critical error>";
|
return "<critical error>";
|
||||||
}
|
}
|
||||||
|
|
||||||
ircd::string_view
|
uint64_t
|
||||||
ircd::server::loghead(const request &request)
|
ircd::server::id(const request &request)
|
||||||
{
|
{
|
||||||
thread_local char buf[256];
|
return request.tag?
|
||||||
return loghead(buf, request);
|
request.tag->state.id:
|
||||||
|
0UL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -512,6 +513,9 @@ ircd::server::peer::link_max_default
|
||||||
{ "default", 2L }
|
{ "default", 2L }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
decltype(ircd::server::peer::ids)
|
||||||
|
ircd::server::peer::ids;
|
||||||
|
|
||||||
//
|
//
|
||||||
// peer::peer
|
// peer::peer
|
||||||
//
|
//
|
||||||
|
@ -1567,6 +1571,9 @@ ircd::server::link::tag_commit_max_default
|
||||||
{ "default", 3L }
|
{ "default", 3L }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
decltype(ircd::server::link::ids)
|
||||||
|
ircd::server::link::ids;
|
||||||
|
|
||||||
//
|
//
|
||||||
// link::link
|
// link::link
|
||||||
//
|
//
|
||||||
|
@ -2327,6 +2334,10 @@ const
|
||||||
// tag
|
// 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
|
/// 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
|
/// writes to the remote we have to continue to service it through to
|
||||||
/// completion without disrupting the linearity of the link's pipeline
|
/// completion without disrupting the linearity of the link's pipeline
|
||||||
|
|
|
@ -4307,10 +4307,13 @@ try
|
||||||
"<no socket>"_sv
|
"<no socket>"_sv
|
||||||
};
|
};
|
||||||
|
|
||||||
out << std::setw(48) << peer.server_name << " "
|
out << std::right << std::setw(8) << peer.id << " "
|
||||||
<< std::setw(56) << remote << " "
|
<< std::left << std::setw(40) << peer.hostcanon << " "
|
||||||
<< std::setw(8) << out_head.method << " "
|
<< std::right << std::setw(8) << link.id << " "
|
||||||
<< std::setw(0) << out_head.path << " "
|
<< 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;
|
<< std::endl;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in a new issue