Lock all Database operations.

All DB functions that are called outside of Database.cpp are now locked
by the same mutex. This might be a bit overkill, but it's not a hot code
path, so it doesn't matter. Better to avoid the potential deadlocks if
we made it too granular.

From now on a clear distinction must be made between external and
internal functions in Database.cpp, or else deadlock will occur.

Note that sqlite database operations are already locked, but if execute
multiple transactions within the same operation, it could have still
caused problems.

I also removed the DbPlayer fetch when writing to DB by making it a part
of the Player struct. This, by itself, should have fixed the crash we found.
This commit is contained in:
2020-09-29 16:47:39 +02:00
parent 3f35d2e960
commit fb281b0237
2 changed files with 35 additions and 1 deletions

View File

@@ -16,6 +16,7 @@ struct Player {
int64_t SerialKey;
int32_t iID;
uint64_t FEKey;
time_t creationTime;
int level;
int HP;