diff --git a/include/ircd/server/link.h b/include/ircd/server/link.h index adeea96dd..cd1577235 100644 --- a/include/ircd/server/link.h +++ b/include/ircd/server/link.h @@ -17,7 +17,9 @@ struct ircd::server::link { static conf::item tag_max_default; static conf::item 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 socket; ///< link's socket std::list queue; ///< link's work queue diff --git a/include/ircd/server/peer.h b/include/ircd/server/peer.h index 1d5c9cb68..09e2badf6 100644 --- a/include/ircd/server/peer.h +++ b/include/ircd/server/peer.h @@ -27,7 +27,9 @@ struct ircd::server::peer static conf::item link_min_default; static conf::item link_max_default; static conf::item error_clear_default; + static uint64_t ids; + uint64_t id {++ids}; net::ipport remote; std::string hostcanon; std::string service; diff --git a/include/ircd/server/request.h b/include/ircd/server/request.h index 9e4f9a88c..09847077a 100644 --- a/include/ircd/server/request.h +++ b/include/ircd/server/request.h @@ -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 &); diff --git a/include/ircd/server/tag.h b/include/ircd/server/tag.h index 99231360f..5e658bb84 100644 --- a/include/ircd/server/tag.h +++ b/include/ircd/server/tag.h @@ -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 diff --git a/ircd/server.cc b/ircd/server.cc index 1cfcf34e2..eea495e13 100644 --- a/ircd/server.cc +++ b/ircd/server.cc @@ -409,11 +409,12 @@ catch(const std::exception &e) return ""; } -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 diff --git a/modules/console.cc b/modules/console.cc index 576d3ed75..23af05c87 100644 --- a/modules/console.cc +++ b/modules/console.cc @@ -4307,10 +4307,13 @@ try ""_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;