diff options
| author | 2024-08-27 14:09:21 +0100 | |
|---|---|---|
| committer | 2024-08-27 14:09:21 +0100 | |
| commit | a5fc0da690ea62c3a76ca2cceaa2ab344a93fce3 (patch) | |
| tree | d0c81a7700ac184b50417f146204dfbcda502811 | |
| parent | Merge branch 'insp4' into master. (diff) | |
Fix the case of some InspIRCd class member variables.
| -rw-r--r-- | include/inspircd.h | 4 | ||||
| -rw-r--r-- | modules/connflood.cpp | 2 | ||||
| -rw-r--r-- | modules/core/core_info/core_info.cpp | 2 | ||||
| -rw-r--r-- | modules/core/core_stats.cpp | 8 | ||||
| -rw-r--r-- | modules/httpd_stats.cpp | 2 | ||||
| -rw-r--r-- | modules/ircv3_msgid.cpp | 2 | ||||
| -rw-r--r-- | modules/ircv3_sts.cpp | 2 | ||||
| -rw-r--r-- | modules/joinflood.cpp | 2 | ||||
| -rw-r--r-- | src/inspircd.cpp | 7 | ||||
| -rw-r--r-- | src/socket.cpp | 12 |
10 files changed, 21 insertions, 22 deletions
diff --git a/include/inspircd.h b/include/inspircd.h index a216d9e08..1a2003695 100644 --- a/include/inspircd.h +++ b/include/inspircd.h @@ -262,10 +262,10 @@ public: std::function<bool(const std::string_view&)> IsUser = &DefaultIsUser; /** List of the open listeners. */ - std::vector<ListenSocket*> ports; + std::vector<ListenSocket*> Ports; /** The time at which the server was started. */ - time_t startup_time; + const time_t StartTime; /** Initialises a new server instance and stores it in ServerInstance * @param argc The argument count from main(). diff --git a/modules/connflood.cpp b/modules/connflood.cpp index 071618399..457a38223 100644 --- a/modules/connflood.cpp +++ b/modules/connflood.cpp @@ -77,7 +77,7 @@ public: return MOD_RES_PASSTHRU; time_t next = ServerInstance->Time(); - if ((time_t)(ServerInstance->startup_time + boot_wait) > next) + if ((time_t)(ServerInstance->StartTime + boot_wait) > next) return MOD_RES_PASSTHRU; /* time difference between first and latest connection */ diff --git a/modules/core/core_info/core_info.cpp b/modules/core/core_info/core_info.cpp index 1f4a7c86a..61ef2f477 100644 --- a/modules/core/core_info/core_info.cpp +++ b/modules/core/core_info/core_info.cpp @@ -173,7 +173,7 @@ public: { user->WriteNumeric(RPL_WELCOME, FMT::format("Welcome to the {} IRC Network {}", ServerInstance->Config->Network, user->GetRealMask())); user->WriteNumeric(RPL_YOURHOST, FMT::format("Your host is {}, running version {}", ServerInstance->Config->GetServerName(), INSPIRCD_BRANCH)); - user->WriteNumeric(RPL_CREATED, Time::ToString(ServerInstance->startup_time, "This server was created %H:%M:%S %b %d %Y")); + user->WriteNumeric(RPL_CREATED, Time::ToString(ServerInstance->StartTime, "This server was created %H:%M:%S %b %d %Y")); user->WriteNumeric(numeric004); isupport.SendTo(user); diff --git a/modules/core/core_stats.cpp b/modules/core/core_stats.cpp index 0f3a40805..1a801ad55 100644 --- a/modules/core/core_stats.cpp +++ b/modules/core/core_stats.cpp @@ -128,7 +128,7 @@ void CommandStats::DoStats(Stats::Context& stats) /* stats p (show listening ports) */ case 'p': { - for (const auto* ls : ServerInstance->ports) + for (const auto* ls : ServerInstance->Ports) { std::stringstream portentry; @@ -284,7 +284,7 @@ void CommandStats::DoStats(Stats::Context& stats) stats.AddRow(249, FMT::format("CPU Use (now): {:03.5}%", per)); - n_elapsed = ServerInstance->Time() - ServerInstance->startup_time; + n_elapsed = ServerInstance->Time() - ServerInstance->StartTime; n_eaten = (float)R.ru_utime.tv_sec + R.ru_utime.tv_usec / 100000.0; per = (n_eaten / n_elapsed) * 100; @@ -315,7 +315,7 @@ void CommandStats::DoStats(Stats::Context& stats) stats.AddRow(249, FMT::format("CPU Use (now): {:03.5}%", per)); - n_elapsed = ServerInstance->Time() - ServerInstance->startup_time; + n_elapsed = ServerInstance->Time() - ServerInstance->StartTime; n_eaten = (double)(( (uint64_t)(KernelTime.dwHighDateTime) << 32 ) + (uint64_t)(KernelTime.dwLowDateTime))/100000; per = (n_eaten / n_elapsed); @@ -346,7 +346,7 @@ void CommandStats::DoStats(Stats::Context& stats) /* stats u (show server uptime) */ case 'u': { - unsigned int up = static_cast<unsigned int>(ServerInstance->Time() - ServerInstance->startup_time); + unsigned int up = static_cast<unsigned int>(ServerInstance->Time() - ServerInstance->StartTime); stats.AddRow(242, FMT::format("Server up {} days, {:02}:{:02}:{:02}", up / 86400, (up / 3600) % 24, (up / 60) % 60, up % 60)); } diff --git a/modules/httpd_stats.cpp b/modules/httpd_stats.cpp index cc86c8830..3a3019fd4 100644 --- a/modules/httpd_stats.cpp +++ b/modules/httpd_stats.cpp @@ -172,7 +172,7 @@ namespace Stats .Attribute("opercount", ServerInstance->Users.all_opers.size()) .Attribute("socketcount", SocketEngine::GetUsedFds()) .Attribute("socketmax", SocketEngine::GetMaxFds()) - .Attribute("boottime", ServerInstance->startup_time) + .Attribute("boottime", ServerInstance->StartTime) .Attribute("currenttime", ServerInstance->Time()); ISupport(serializer); diff --git a/modules/ircv3_msgid.cpp b/modules/ircv3_msgid.cpp index 62cde314e..96a57b1fa 100644 --- a/modules/ircv3_msgid.cpp +++ b/modules/ircv3_msgid.cpp @@ -47,7 +47,7 @@ class MsgIdGenerator final public: MsgIdGenerator() - : strid(FMT::format("{}~{}~", ServerInstance->Config->ServerId, ServerInstance->startup_time)) + : strid(FMT::format("{}~{}~", ServerInstance->Config->ServerId, ServerInstance->StartTime)) , baselen(strid.length()) { } diff --git a/modules/ircv3_sts.cpp b/modules/ircv3_sts.cpp index c6f49480c..97b6c5395 100644 --- a/modules/ircv3_sts.cpp +++ b/modules/ircv3_sts.cpp @@ -141,7 +141,7 @@ private: // The IRCv3 STS specification requires that the server is listening using TLS using a valid certificate. static bool HasValidSSLPort(in_port_t port) { - for (const auto* ls : ServerInstance->ports) + for (const auto* ls : ServerInstance->Ports) { // Is this listener marked as providing SSL over HAProxy? if (!ls->bind_tag->getString("hook").empty() && ls->bind_tag->getBool("sslhook")) diff --git a/modules/joinflood.cpp b/modules/joinflood.cpp index 4390bc8a5..4d7b16bfe 100644 --- a/modules/joinflood.cpp +++ b/modules/joinflood.cpp @@ -159,7 +159,7 @@ public: notifyrank = tag->getNum<ModeHandler::Rank>("notifyrank", 0); if (status.initial) - ignoreuntil = ServerInstance->startup_time + bootwait; + ignoreuntil = ServerInstance->StartTime + bootwait; } void OnServerSplit(const Server* server, bool error) override diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 94d19f80f..882cb2e79 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -377,12 +377,12 @@ namespace void InspIRCd::Cleanup() { // Close all listening sockets - for (auto* port : ports) + for (auto* port : Ports) { port->Cull(); delete port; } - ports.clear(); + Ports.clear(); // Tell modules that we're shutting down. const std::string quitmsg = "Server shutting down"; @@ -434,12 +434,11 @@ void InspIRCd::WritePID() } InspIRCd::InspIRCd(int argc, char** argv) + : StartTime(time(NULL)) { ServerInstance = this; UpdateTime(); - this->startup_time = Time(); - IncreaseCoreDumpSize(); SocketEngine::Init(); diff --git a/src/socket.cpp b/src/socket.cpp index 2ec6d16b3..9f520df16 100644 --- a/src/socket.cpp +++ b/src/socket.cpp @@ -79,14 +79,14 @@ bool InspIRCd::BindPort(const std::shared_ptr<ConfigTag>& tag, const irc::socket } ServerInstance->Logs.Debug("SOCKET", "Added a listener on {} from tag at {}", sa.str(), tag->source.str()); - ports.push_back(ll); + Ports.push_back(ll); return true; } size_t InspIRCd::BindPorts(FailedPortList& failed_ports) { size_t bound = 0; - std::vector<ListenSocket*> old_ports(ports.begin(), ports.end()); + std::vector<ListenSocket*> old_ports(Ports.begin(), Ports.end()); for (const auto& [_, tag] : ServerInstance->Config->ConfTags("bind")) { @@ -209,12 +209,12 @@ size_t InspIRCd::BindPorts(FailedPortList& failed_ports) } } - std::vector<ListenSocket*>::iterator n = ports.begin(); + std::vector<ListenSocket*>::iterator n = Ports.begin(); for (auto* old_port : old_ports) { - while (n != ports.end() && *n != old_port) + while (n != Ports.end() && *n != old_port) n++; - if (n == ports.end()) + if (n == Ports.end()) { this->Logs.Warning("SOCKET", "Port bindings slipped out of vector, aborting close!"); break; @@ -225,7 +225,7 @@ size_t InspIRCd::BindPorts(FailedPortList& failed_ports) delete *n; // this keeps the iterator valid, pointing to the next element - n = ports.erase(n); + n = Ports.erase(n); } return bound; |
