summaryrefslogtreecommitdiffstats
path: root/configd
diff options
context:
space:
mode:
authorJon Marius Venstad <venstad@gmail.com>2019-11-15 12:40:00 +0100
committerJon Marius Venstad <venstad@gmail.com>2019-11-15 13:02:32 +0100
commit7f086605b5d23f42651dfbf430b3c25f14799c9f (patch)
tree89b38198555bb6f2d022c1b4a083c2fc93e3318a /configd
parent0656b8600cb2f1425e98d87f2bbd2fbc6aeeb406 (diff)
Throw, catch and exit on bad port value, rather than straight exit
Diffstat (limited to 'configd')
-rw-r--r--configd/src/apps/sentinel/config-handler.cpp6
-rw-r--r--configd/src/apps/sentinel/sentinel.cpp4
2 files changed, 7 insertions, 3 deletions
diff --git a/configd/src/apps/sentinel/config-handler.cpp b/configd/src/apps/sentinel/config-handler.cpp
index a73a5f01f33..7b68e6c8150 100644
--- a/configd/src/apps/sentinel/config-handler.cpp
+++ b/configd/src/apps/sentinel/config-handler.cpp
@@ -5,6 +5,8 @@
#include <vespa/vespalib/net/simple_metric_snapshot.h>
#include <vespa/vespalib/net/socket_address.h>
+#include <vespa/vespalib/util/exceptions.h>
+#include <string>
#include <fcntl.h>
#include <sys/wait.h>
@@ -24,9 +26,7 @@ ConfigHandler::configure_port(int port)
}
}
if (port <= 0 || port > 65535) {
- LOG(error, "Fatal: bad port %d, expected range [1,65535]", port);
- EV_STOPPING("config-sentinel", "bad port");
- exit(EXIT_FAILURE);
+ throw vespalib::FatalException("Bad port " + std::to_string(port) + ", expected range [1, 65535]", VESPA_STRLOC);
}
if (port != _boundPort) {
LOG(debug, "Config-sentinel accepts connections on port %d", port);
diff --git a/configd/src/apps/sentinel/sentinel.cpp b/configd/src/apps/sentinel/sentinel.cpp
index 741eb5514bb..126c59d42f3 100644
--- a/configd/src/apps/sentinel/sentinel.cpp
+++ b/configd/src/apps/sentinel/sentinel.cpp
@@ -91,6 +91,10 @@ main(int argc, char **argv)
LOG(error, "Fatal: %s", ex.getMessage().c_str());
EV_STOPPING("config-sentinel", ex.what());
exit(EXIT_FAILURE);
+ } catch (vespalib::FatalException& ex) {
+ LOG(error, "Fatal: %s", ex.getMessage().c_str());
+ EV_STOPPING("config-sentinel", ex.what());
+ exit(EXIT_FAILURE);
}
if (vespalib::SignalHandler::CHLD.check()) {
continue;