mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-06 20:43:44 +02:00
fix compile & sql errors
This commit is contained in:
parent
55a9e6e05e
commit
6014df2847
1 changed files with 18 additions and 10 deletions
|
@ -1315,12 +1315,14 @@ void PostgreSQL::onlineNotificationThread()
|
||||||
continue; // skip members trying to join non-existant networks
|
continue; // skip members trying to join non-existant networks
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string networkId(nwidTmp);
|
||||||
|
std::string memberId(memTmp);
|
||||||
|
|
||||||
std::vector<std::string> &members = updateMap[networkId];
|
std::vector<std::string> &members = updateMap[networkId];
|
||||||
members.push_back(memberId);
|
members.push_back(memberId);
|
||||||
|
|
||||||
lastOnlineCumulative[i->first] = i->second.first;
|
lastOnlineCumulative[i->first] = i->second.first;
|
||||||
std::string networkId(nwidTmp);
|
|
||||||
std::string memberId(memTmp);
|
|
||||||
|
|
||||||
const char *qvals[2] = {
|
const char *qvals[2] = {
|
||||||
networkId.c_str(),
|
networkId.c_str(),
|
||||||
|
@ -1356,7 +1358,13 @@ void PostgreSQL::onlineNotificationThread()
|
||||||
memberUpdate << ", ";
|
memberUpdate << ", ";
|
||||||
}
|
}
|
||||||
|
|
||||||
memberUpdate << "('" << networkId << "', '" << memberId << '", ' << ipAddr << "', TO_TIMESTAMP(" << timestamp << "::double precision/1000))";
|
memberUpdate << "('" << networkId << "', '" << memberId << "', ";
|
||||||
|
if (ipAddr.empty()) {
|
||||||
|
memberUpdate << "NULL, ";
|
||||||
|
} else {
|
||||||
|
memberUpdate << "'" << ipAddr << "', ";
|
||||||
|
}
|
||||||
|
memberUpdate << "TO_TIMESTAMP(" << timestamp << "::double precision/1000))";
|
||||||
memberAdded = true;
|
memberAdded = true;
|
||||||
} else if (nrows > 1) {
|
} else if (nrows > 1) {
|
||||||
fprintf(stderr, "nrows > 1?!?");
|
fprintf(stderr, "nrows > 1?!?");
|
||||||
|
@ -1369,7 +1377,7 @@ void PostgreSQL::onlineNotificationThread()
|
||||||
|
|
||||||
if (memberAdded) {
|
if (memberAdded) {
|
||||||
res = PQexec(conn, memberUpdate.str().c_str());
|
res = PQexec(conn, memberUpdate.str().c_str());
|
||||||
if (res != PGRES_COMMAND_OK) {
|
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
|
||||||
fprintf(stderr, "Multiple insert failed: %s", PQerrorMessage(conn));
|
fprintf(stderr, "Multiple insert failed: %s", PQerrorMessage(conn));
|
||||||
}
|
}
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
|
@ -1422,11 +1430,11 @@ void PostgreSQL::onlineNotificationThread()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char *nvals[1] = {
|
const char *nvals[1] = {
|
||||||
networkId.c_str();
|
networkId.c_str()
|
||||||
};
|
};
|
||||||
|
|
||||||
res = PQExecParams(conn,
|
res = PQexecParams(conn,
|
||||||
"SELECT id FROM ztc_network WHERE id = $1",
|
"SELECT id FROM ztc_network WHERE id = $1",
|
||||||
1,
|
1,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -1473,8 +1481,8 @@ void PostgreSQL::onlineNotificationThread()
|
||||||
<< "authorized_member_count = EXCLUDED.authorized_member_count, online_member_count = EXCLUDED.online_member_count, "
|
<< "authorized_member_count = EXCLUDED.authorized_member_count, online_member_count = EXCLUDED.online_member_count, "
|
||||||
<< "total_member_count = EXCLUDED.total_member_count, last_modified = EXCLUDED.last_modified";
|
<< "total_member_count = EXCLUDED.total_member_count, last_modified = EXCLUDED.last_modified";
|
||||||
if (networkAdded) {
|
if (networkAdded) {
|
||||||
res = PQExec(conn, networkUpdate.str().c_str());
|
res = PQexec(conn, networkUpdate.str().c_str());
|
||||||
if (res != PGRES_COMMAND_OK) {
|
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
|
||||||
fprintf(stderr, "Error during multiple network upsert: %s", PQresultErrorMessage(res));
|
fprintf(stderr, "Error during multiple network upsert: %s", PQresultErrorMessage(res));
|
||||||
}
|
}
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
|
|
Loading…
Add table
Reference in a new issue