summaryrefslogtreecommitdiff
path: root/controller/PostgreSQL.cpp
diff options
context:
space:
mode:
authorGrant Limberg <grant.limberg@zerotier.com>2018-12-06 13:08:31 -0800
committerGrant Limberg <grant.limberg@zerotier.com>2018-12-06 13:08:31 -0800
commit1c86f25fab57f4c2bc3f314683a911959f90b9b8 (patch)
tree5f7551df0131c1ff3b28ecf5a0f3118ddb030b1e /controller/PostgreSQL.cpp
parent5535cad773b69cb9359185deead1a3d5ec7bad8a (diff)
downloadinfinitytier-1c86f25fab57f4c2bc3f314683a911959f90b9b8.tar.gz
infinitytier-1c86f25fab57f4c2bc3f314683a911959f90b9b8.zip
update # of threads for Postgres
Diffstat (limited to 'controller/PostgreSQL.cpp')
-rw-r--r--controller/PostgreSQL.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/controller/PostgreSQL.cpp b/controller/PostgreSQL.cpp
index ff1d6c59..e0100613 100644
--- a/controller/PostgreSQL.cpp
+++ b/controller/PostgreSQL.cpp
@@ -77,7 +77,7 @@ PostgreSQL::PostgreSQL(EmbeddedNetworkController *const nc, const Identity &myId
_heartbeatThread = std::thread(&PostgreSQL::heartbeat, this);
_membersDbWatcher = std::thread(&PostgreSQL::membersDbWatcher, this);
_networksDbWatcher = std::thread(&PostgreSQL::networksDbWatcher, this);
- for (int i = 0; i < ZT_CONTROLLER_RETHINKDB_COMMIT_THREADS; ++i) {
+ for (int i = 0; i < ZT_CENTRAL_CONTROLLER_COMMIT_THREADS; ++i) {
_commitThread[i] = std::thread(&PostgreSQL::commitThread, this);
}
_onlineNotificationThread = std::thread(&PostgreSQL::onlineNotificationThread, this);
@@ -91,7 +91,7 @@ PostgreSQL::~PostgreSQL()
_heartbeatThread.join();
_membersDbWatcher.join();
_networksDbWatcher.join();
- for (int i = 0; i < ZT_CONTROLLER_RETHINKDB_COMMIT_THREADS; ++i) {
+ for (int i = 0; i < ZT_CENTRAL_CONTROLLER_COMMIT_THREADS; ++i) {
_commitThread[i].join();
}
_onlineNotificationThread.join();
@@ -518,8 +518,9 @@ void PostgreSQL::heartbeat()
}
while (_run == 1) {
if(PQstatus(conn) != CONNECTION_OK) {
+ fprintf(stderr, "%s heartbeat thread lost connection to Database\n", _myAddressStr.c_str());
PQfinish(conn);
- conn = getPgConn();
+ exit(6);
}
if (conn) {
std::string major = std::to_string(ZEROTIER_ONE_VERSION_MAJOR);
@@ -1161,8 +1162,7 @@ void PostgreSQL::onlineNotificationThread()
if (PQstatus(conn) != CONNECTION_OK) {
fprintf(stderr, "ERROR: Online Notification thread lost connection to Postgres.");
PQfinish(conn);
- conn = getPgConn();
- continue;
+ exit(5);
}
// map used to send notifications to front end
@@ -1326,7 +1326,6 @@ void PostgreSQL::onlineNotificationThread()
}
fprintf(stderr, "%s: Fell out of run loop in onlineNotificationThread", _myAddressStr.c_str());
PQfinish(conn);
- exit(5);
}
PGconn *PostgreSQL::getPgConn(OverrideMode m) {