EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Development::Server Code Submissions (https://www.eqemulator.org/forums/forumdisplay.php?f=669)
-   -   COMMITTED: UCS crash fix (https://www.eqemulator.org/forums/showthread.php?t=33446)

sorvani 05-05-2011 10:59 PM

Just got in and glanced at my server, no one had logged in all day (12 hours), so I logged in a toon and wham. DB err lost connection, but no crash :) it reconnected just fine.

Thanks for the fix!

Zothen 05-06-2011 01:50 AM

WOOT! Grats! :)

Zothen 05-16-2011 02:59 AM

Okay, I found a cosmetic error, as I interpreted the return value of RunQuery() wrong. RunQuery() returns true when successful, so we need to edit a line:

Code:

bool DBcore::RunQuery(const char* query, int32 querylen, char* errbuf, MYSQL_RES** result, int32* affected_rows, int32* last_insert_id, int32* errnum, bool retry) {
        _CP(DBcore_RunQuery);
        if (errnum)
                *errnum = 0;
        if (errbuf)
                errbuf[0] = 0;
        bool ret = false;
        LockMutex lock(&MDatabase);
        if (pStatus != Connected)
                Open();
#if DEBUG_MYSQL_QUERIES >= 1
        char tmp[120];
        strn0cpy(tmp, query, sizeof(tmp));
        cout << "QUERY: " << tmp << endl;
#endif
        if (mysql_real_query(&mysql, query, querylen)) {
                if (mysql_errno(&mysql) == CR_SERVER_GONE_ERROR)
                        pStatus = Error;
                if (mysql_errno(&mysql) == CR_SERVER_LOST || mysql_errno(&mysql) == CR_SERVER_GONE_ERROR) {
                        if (retry) {
                                cout << "Database Error: Lost connection, attempting to recover...." << endl;
                                ret = RunQuery(query, querylen, errbuf, result, affected_rows, last_insert_id, errnum, false);
                                // if ( !ret )  // <- Wrong return value
                                if ( ret )
                                        cout << "Reconnection to database successful." << endl;
                        }
                        else {

...
...
...


trevius 05-16-2011 04:55 AM

lmao, I forgot about that. I meant to correct that before I committed it. I saw that, but was working on other stuff at the time and didn't get back to it. Thanks for the reminder. I will try to get that in unless someone else does before I find time to.

Zothen 05-16-2011 05:44 AM

I was wondering why I didnt get a reconnection message after my last crash, so I rechecked the code. :)

sorvani 05-16-2011 11:38 AM

UCS has been running great though, thanks Zothen

Zothen 05-16-2011 11:49 AM

Glad to hear :)

joligario 05-16-2011 12:03 PM

Gotcha covered Trev. Committed in r1901.


All times are GMT -4. The time now is 04:19 PM.

Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.