mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-04-25 05:19:55 +00:00
make sure to commit on online notification thread
This commit is contained in:
parent
79f1e81745
commit
faf0c6bbfa
@ -1224,7 +1224,9 @@ void PostgreSQL::onlineNotification_Postgres()
|
|||||||
memberUpdate << "INSERT INTO ztc_member_status (network_id, member_id, address, last_updated) VALUES ";
|
memberUpdate << "INSERT INTO ztc_member_status (network_id, member_id, address, last_updated) VALUES ";
|
||||||
bool firstRun = true;
|
bool firstRun = true;
|
||||||
bool memberAdded = false;
|
bool memberAdded = false;
|
||||||
|
int updateCount = 0;
|
||||||
for (auto i=lastOnline.begin(); i != lastOnline.end(); ++i) {
|
for (auto i=lastOnline.begin(); i != lastOnline.end(); ++i) {
|
||||||
|
updateCount += 1;
|
||||||
uint64_t nwid_i = i->first.first;
|
uint64_t nwid_i = i->first.first;
|
||||||
char nwidTmp[64];
|
char nwidTmp[64];
|
||||||
char memTmp[64];
|
char memTmp[64];
|
||||||
@ -1275,8 +1277,12 @@ void PostgreSQL::onlineNotification_Postgres()
|
|||||||
memberUpdate << " ON CONFLICT (network_id, member_id) DO UPDATE SET address = EXCLUDED.address, last_updated = EXCLUDED.last_updated;";
|
memberUpdate << " ON CONFLICT (network_id, member_id) DO UPDATE SET address = EXCLUDED.address, last_updated = EXCLUDED.last_updated;";
|
||||||
|
|
||||||
if (memberAdded) {
|
if (memberAdded) {
|
||||||
|
fprintf(stderr, "%s\n", memberUpdate.str().c_str());
|
||||||
pqxx::result res = w.exec0(memberUpdate.str());
|
pqxx::result res = w.exec0(memberUpdate.str());
|
||||||
|
w.commit();
|
||||||
}
|
}
|
||||||
|
fprintf(stderr, "Updated online status of %d members\n", updateCount);
|
||||||
|
_pool->unborrow(c);
|
||||||
} catch (std::exception &e) {
|
} catch (std::exception &e) {
|
||||||
fprintf(stderr, "%s: error in onlinenotification thread: %s\n", _myAddressStr.c_str(), e.what());
|
fprintf(stderr, "%s: error in onlinenotification thread: %s\n", _myAddressStr.c_str(), e.what());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user