mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Fix assertion failure when SQLite connection fails
When connecting to the SQLite database fails, e.g. because the `.sqlite` file is corrupted, the server would crash with the assertion "Tried connecting while the connection is in use" when a player joins and performs any action. This is fixed by resetting the use-flag when connecting to the SQLite database fails, which is the same behavior as for the MySQL database connection.
This commit is contained in:
parent
bb147328c2
commit
040731095e
|
@ -65,6 +65,8 @@ private:
|
|||
bool m_Done; // no more rows available for Step
|
||||
// returns false, if the query succeeded
|
||||
bool Execute(const char *pQuery, char *pError, int ErrorSize);
|
||||
// returns true on failure
|
||||
bool ConnectImpl(char *pError, int ErrorSize);
|
||||
|
||||
// returns true if an error was formatted
|
||||
bool FormatError(int Result, char *pError, int ErrorSize);
|
||||
|
@ -110,9 +112,18 @@ bool CSqliteConnection::Connect(char *pError, int ErrorSize)
|
|||
{
|
||||
if(m_InUse.exchange(true))
|
||||
{
|
||||
dbg_assert(0, "Tried connecting while the connection is in use");
|
||||
dbg_assert(false, "Tried connecting while the connection is in use");
|
||||
}
|
||||
if(ConnectImpl(pError, ErrorSize))
|
||||
{
|
||||
m_InUse.store(false);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CSqliteConnection::ConnectImpl(char *pError, int ErrorSize)
|
||||
{
|
||||
if(m_pDb != nullptr)
|
||||
{
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue