0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-27 07:54:05 +01:00

ircd::server: Minor reorg; section comments.

This commit is contained in:
Jason Volk 2020-02-27 15:28:53 -08:00
parent 9b5e4f8d48
commit 8ce0c46f63
2 changed files with 100 additions and 97 deletions

View file

@ -62,9 +62,9 @@ namespace ircd::server
struct ircd::server::init
{
// manual control panel
void interrupt();
void close();
void wait();
static void interrupt();
static void close();
static void wait();
init() noexcept;
~init() noexcept;

View file

@ -36,6 +36,93 @@ close_all_timeout
{ "default", 2L },
};
//
// init
//
ircd::server::init::init()
noexcept
{
}
ircd::server::init::~init()
noexcept
{
interrupt(), close(), wait();
peers.clear();
log::debug
{
log, "All server peers, connections, and requests are clear."
};
}
void
ircd::server::init::wait()
{
static const auto finished
{
[] { return !peer_unfinished(); }
};
while(!dock.wait_for(seconds(5), finished))
{
for(const auto &[name, peer] : peers)
log::dwarning
{
log, "Waiting for peer %s tags:%zu links:%zu err:%b op[r:%b f:%b]",
name,
peer->tag_count(),
peer->link_count(),
peer->err_has(),
peer->op_resolve,
peer->op_fini,
};
log::warning
{
log, "Waiting for %zu tags on %zu links on %zu of %zu peers to close...",
tag_count(),
link_count(),
peer_unfinished(),
peer_count()
};
}
}
void
ircd::server::init::close()
{
log::debug
{
log, "Closing all %zu peers",
peer_count()
};
net::close_opts opts;
opts.timeout = seconds(close_all_timeout);
for(auto &peer : peers)
peer.second->close(opts);
}
void
ircd::server::init::interrupt()
{
log::debug
{
log, "Cancel %zu tags on %zu links on %zu peers",
tag_count(),
link_count(),
peer_count()
};
for(auto &peer : peers)
peer.second->cancel();
}
//
// ircd::server
//
ircd::server::peer &
ircd::server::get(const net::hostport &hostport)
{
@ -229,92 +316,16 @@ ircd::server::accumulate_peers(F&& closure)
});
}
///////////////////////////////////////////////////////////////////////////////
//
// init
// server/request.h
//
ircd::server::init::init()
noexcept
decltype(ircd::server::request::log)
ircd::server::request::log
{
}
ircd::server::init::~init()
noexcept
{
interrupt(), close(), wait();
peers.clear();
log::debug
{
log, "All server peers, connections, and requests are clear."
};
}
void
ircd::server::init::wait()
{
static const auto finished
{
[] { return !peer_unfinished(); }
};
while(!dock.wait_for(seconds(5), finished))
{
for(const auto &[name, peer] : peers)
log::dwarning
{
log, "Waiting for peer %s tags:%zu links:%zu err:%b op[r:%b f:%b]",
name,
peer->tag_count(),
peer->link_count(),
peer->err_has(),
peer->op_resolve,
peer->op_fini,
};
log::warning
{
log, "Waiting for %zu tags on %zu links on %zu of %zu peers to close...",
tag_count(),
link_count(),
peer_unfinished(),
peer_count()
};
}
}
void
ircd::server::init::close()
{
log::debug
{
log, "Closing all %zu peers",
peer_count()
};
net::close_opts opts;
opts.timeout = seconds(close_all_timeout);
for(auto &peer : peers)
peer.second->close(opts);
}
void
ircd::server::init::interrupt()
{
log::debug
{
log, "Cancel %zu tags on %zu links on %zu peers",
tag_count(),
link_count(),
peer_count()
};
for(auto &peer : peers)
peer.second->cancel();
}
//
// request
//
"server.request"
};
decltype(ircd::server::request::opts_default)
ircd::server::request::opts_default
@ -1662,8 +1673,9 @@ noexcept
{
}
///////////////////////////////////////////////////////////////////////////////
//
// link
// server/link.h
//
decltype(ircd::server::link::tag_max_default)
@ -2558,18 +2570,9 @@ const
});
}
///////////////////////////////////////////////////////////////////////////////
//
// request
//
decltype(ircd::server::request::log)
ircd::server::request::log
{
"server.request"
};
//
// tag
// server/tag.h
//
/// Monotonic counter for tags.