summaryrefslogtreecommitdiffstats
path: root/configd
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2019-08-26 12:19:58 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2019-08-26 12:19:58 +0000
commit58cfb5e88daf7bed3f5b235325eeae5f81983a21 (patch)
treec5983a05e628d0121078bd76006c651e3c901585 /configd
parentdf25abf6f2498d90498ae2f84643aa1dd61fae9b (diff)
Avoid the last usages of time(0/NULL/nullptr) in the codebase.
Diffstat (limited to 'configd')
-rw-r--r--configd/src/apps/sentinel/config-handler.cpp2
-rw-r--r--configd/src/apps/sentinel/metrics.cpp5
-rw-r--r--configd/src/apps/sentinel/service.cpp7
3 files changed, 8 insertions, 6 deletions
diff --git a/configd/src/apps/sentinel/config-handler.cpp b/configd/src/apps/sentinel/config-handler.cpp
index 0f624da2bf0..a73a5f01f33 100644
--- a/configd/src/apps/sentinel/config-handler.cpp
+++ b/configd/src/apps/sentinel/config-handler.cpp
@@ -44,7 +44,7 @@ ConfigHandler::ConfigHandler()
_startMetrics(),
_stateApi()
{
- _startMetrics.startedTime = time(nullptr);
+ _startMetrics.startedTime = fastos::time();
}
ConfigHandler::~ConfigHandler()
diff --git a/configd/src/apps/sentinel/metrics.cpp b/configd/src/apps/sentinel/metrics.cpp
index 812ab56cd15..bb10c94ae12 100644
--- a/configd/src/apps/sentinel/metrics.cpp
+++ b/configd/src/apps/sentinel/metrics.cpp
@@ -2,6 +2,7 @@
#include "metrics.h"
#include <vespa/vespalib/metrics/simple_metrics.h>
+#include <vespa/fastos/timestamp.h>
namespace config::sentinel {
@@ -13,7 +14,7 @@ StartMetrics::StartMetrics()
producer(metrics),
currentlyRunningServices(0),
totalRestartsCounter(0),
- startedTime(time(nullptr)),
+ startedTime(fastos::time()),
sentinel_restarts(metrics->counter("sentinel.restarts",
"how many times sentinel restarted a service")),
sentinel_totalRestarts(metrics->gauge("sentinel.totalRestarts",
@@ -32,7 +33,7 @@ StartMetrics::~StartMetrics() = default;
void
StartMetrics::maybeLog()
{
- uint32_t curTime = time(nullptr);
+ uint32_t curTime = fastos::time();
sentinel_totalRestarts.sample(totalRestartsCounter);
sentinel_running.sample(currentlyRunningServices);
sentinel_uptime.sample(curTime - startedTime);
diff --git a/configd/src/apps/sentinel/service.cpp b/configd/src/apps/sentinel/service.cpp
index 941ea690024..22f9681a2ff 100644
--- a/configd/src/apps/sentinel/service.cpp
+++ b/configd/src/apps/sentinel/service.cpp
@@ -4,6 +4,7 @@
#include "output-connection.h"
#include <vespa/vespalib/util/stringfmt.h>
#include <vespa/vespalib/util/signalhandler.h>
+#include <vespa/fastos/timestamp.h>
#include <csignal>
#include <unistd.h>
@@ -156,7 +157,7 @@ Service::start()
LOG(warning, "tried to start '%s' in REMOVING state", name().c_str());
return;
}
- time_t now = time(0);
+ time_t now = fastos::time();
_last_start = now;
// make a pipe, close the good ends of it, mark it close-on-exec
@@ -322,7 +323,7 @@ Service::youExited(int status)
if (! expectedDeath) {
// make sure the service does not restart in a tight loop:
- time_t now = time(0);
+ time_t now = fastos::time();
unsigned int diff = now - _last_start;
if (diff < MAX_RESTART_PENALTY) {
incrementRestartPenalty();
@@ -420,7 +421,7 @@ bool
Service::wantsRestart() const
{
if (_state == RESTARTING) {
- time_t now = time(0);
+ time_t now = fastos::time();
if (now > _last_start + _restartPenalty) {
return true;
}