I think I found the bug in UCS that is causing this crash.
Debugging showed up a halt in DBCore::Open() after a call of mysql_real_connect() using an uninitialized mysql struct.
The struct gets uninitialized whenever theres a connection error of some sort, because
mysql.close() makes it invalid. Without another call to
mysql.init() all following sql connects/commands will fail, resulting in a crash.
So we just need to enter a single line of code... :
(May need some more testing, but mine is running stable now for 20 hours.)
Code:
bool DBcore::Open(int32* errnum, char* errbuf) {
if (errbuf)
errbuf[0] = 0;
LockMutex lock(&MDatabase);
if (GetStatus() == Connected)
return true;
if (GetStatus() == Error)
{
mysql_close(&mysql); // <- Makes struct 'mysql' invalid!
mysql_init(&mysql); // <- Initialize structure again
}
if (!pHost)
return false;
/*
Quagmire - added CLIENT_FOUND_ROWS flag to the connect
otherwise DB update calls would say 0 rows affected when the value already equalled
what the function was tring to set it to, therefore the function would think it failed
*/
int32 flags = CLIENT_FOUND_ROWS;
if (pCompress)
flags |= CLIENT_COMPRESS;
if (pSSL)
flags |= CLIENT_SSL;
// crashed here, because 'mysql' wasnt valid after an error followed by mysql.close()
if (mysql_real_connect(&mysql, pHost, pUser, pPassword, pDatabase, pPort, 0, flags)) {
pStatus = Connected;
return true;
}
else {
if (errnum)
*errnum = mysql_errno(&mysql);
if (errbuf)
snprintf(errbuf, MYSQL_ERRMSG_SIZE, "#%i: %s", mysql_errno(&mysql), mysql_error(&mysql));
pStatus = Error;
return false;
}
}