diff options
author | Grant Limberg <grant.limberg@zerotier.com> | 2018-09-25 10:17:15 -0700 |
---|---|---|
committer | Grant Limberg <grant.limberg@zerotier.com> | 2018-09-25 10:17:15 -0700 |
commit | 5b222d0a09dab1a7e009f728f955a0ef70d569a6 (patch) | |
tree | 1f0237cb17e9606b734ef3a48e59c2f3730376f0 | |
parent | 0ec62154931a80459e3888b7b34d622f1e9304cc (diff) | |
download | infinitytier-5b222d0a09dab1a7e009f728f955a0ef70d569a6.tar.gz infinitytier-5b222d0a09dab1a7e009f728f955a0ef70d569a6.zip |
cleanup connections after errors
-rw-r--r-- | controller/PostgreSQL.cpp | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/controller/PostgreSQL.cpp b/controller/PostgreSQL.cpp index e0e25718..4a33e4b6 100644 --- a/controller/PostgreSQL.cpp +++ b/controller/PostgreSQL.cpp @@ -1081,7 +1081,7 @@ void PostgreSQL::onlineNotificationThread() if (PQresultStatus(res) != PGRES_COMMAND_OK) { fprintf(stderr, "ERROR: Error on commit (onlineNotificationThread): %s\n", PQresultErrorMessage(res)); PQclear(res); - PQexec(conn, "ROLLBACK"); + PQclear(PQexec(conn, "ROLLBACK")); exit(1); } PQclear(res); @@ -1100,7 +1100,7 @@ void PostgreSQL::onlineNotificationThread() if (PQresultStatus(res) != PGRES_COMMAND_OK) { fprintf(stderr, "ERROR: Error on commit (onlineNotificationThread): %s\n", PQresultErrorMessage(res)); PQclear(res); - PQexec(conn, "ROLLBACK"); + PQclear(PQexec(conn, "ROLLBACK")); exit(1); } PQclear(res); @@ -1181,7 +1181,7 @@ void PostgreSQL::onlineNotificationThread() if (PQresultStatus(res) != PGRES_COMMAND_OK) { fprintf(stderr, "ERROR: Error on Network Status upsert (onlineNotificationThread): %s\n", PQresultErrorMessage(res)); PQclear(res); - PQexec(conn, "ROLLBACK"); + PQclear(PQexec(conn, "ROLLBACK")); exit(1); } @@ -1190,7 +1190,7 @@ void PostgreSQL::onlineNotificationThread() if (PQresultStatus(res) != PGRES_COMMAND_OK) { fprintf(stderr, "ERROR: Error on COMMIT (onlineNotificationThread): %s\n" , PQresultErrorMessage(res)); PQclear(res); - PQexec(conn, "ROLLBACK"); + PQclear(PQexec(conn, "ROLLBACK")); exit(1); } @@ -1208,7 +1208,7 @@ void PostgreSQL::onlineNotificationThread() if (PQresultStatus(res) != PGRES_COMMAND_OK) { fprintf(stderr, "ERROR: Error on COMMIT (onlineNotificationThread): %s\n", PQresultErrorMessage(res)); PQclear(res); - PQexec(conn, "ROLLBACK"); + PQclear(PQexec(conn, "ROLLBACK")); exit(1); } } @@ -1223,8 +1223,6 @@ void PostgreSQL::onlineNotificationThread() queryBuilder << "NOTIFY controller, '" << networkId << ":" << membersStr << "'"; std::string query = queryBuilder.str(); - fprintf(stderr, "%s\n", query.c_str()); - PGresult *res = PQexec(conn,query.c_str()); if (PQresultStatus(res) != PGRES_COMMAND_OK) { fprintf(stderr, "ERROR: Error sending NOTIFY: %s\n", PQresultErrorMessage(res)); |