From: <ac...@us...> - 2007-11-11 01:57:31
|
Revision: 247 http://planeshift.svn.sourceforge.net/planeshift/?rev=247&view=rev Author: acraig Date: 2007-11-10 17:57:36 -0800 (Sat, 10 Nov 2007) Log Message: ----------- Added an #ifdef around the delay system since I couldn't quite get it to work for me yet. Turn it on in the dal.h Modified Paths: -------------- trunk/docs/history.txt trunk/src/server/database/mysql/dal.cpp trunk/src/server/database/mysql/dal.h Modified: trunk/docs/history.txt =================================================================== --- trunk/docs/history.txt 2007-11-11 01:22:59 UTC (rev 246) +++ trunk/docs/history.txt 2007-11-11 01:57:36 UTC (rev 247) @@ -1,3 +1,8 @@ +*** 2007-11-10 by Andrew Craig +- Added #ifdef around the delay MYSQL query system. For some + reason it doesn't work well for me so add the define in + dal.h to turn it on/off. + *** 2007-11-10 by Roland Schulz - fix for BT#2755: Guild edit permission. Now actor can only change priviledges that the actor himself has in the guild. Modified: trunk/src/server/database/mysql/dal.cpp =================================================================== --- trunk/src/server/database/mysql/dal.cpp 2007-11-11 01:22:59 UTC (rev 246) +++ trunk/src/server/database/mysql/dal.cpp 2007-11-11 01:57:36 UTC (rev 247) @@ -76,10 +76,12 @@ { // Create a mydb conn=mysql_init(NULL); - + +#ifdef USE_DELAY_QUERY dqm.AttachNew(new DelayedQueryManager(host,port,user,pwd,database)); dqmThread.AttachNew(new Thread(dqm)); dqmThread->Start(); +#endif // Conn is the valid connection to be used for mydb. Have to store the mydb to get @@ -93,9 +95,11 @@ { mysql_close(conn); conn = NULL; - + +#ifdef USE_DELAY_QUERY dqm->Stop(); dqmThread->Stop(); +#endif return true; } @@ -123,6 +127,7 @@ unsigned long psMysqlConnection::CommandPump(const char *sql,...) { +#ifdef USE_DELAY_QUERY psStopWatch timer; csString querystr; va_list args; @@ -133,6 +138,34 @@ dqm->Push(querystr); return 1; +#else + psStopWatch timer; + csString querystr; + va_list args; + + va_start(args, sql); + querystr.FormatV(sql, args); + va_end(args); + + lastquery = querystr; + + timer.Start(); + if (!mysql_real_query(conn, querystr, querystr.Length())) + { + if(timer.Stop() > 1000) + { + csString status; + status.Format("SQL query %s, has taken %u time to process.\n", querystr.GetData(), timer.Stop()); + if(LogCSV::GetSingletonPtr()) + LogCSV::GetSingleton().Write(CSV_STATUS, status); + } + profs.AddSQLTime(querystr, timer.Stop()); + return (unsigned long) mysql_affected_rows(conn); + } + else + return QUERY_FAILED; + +#endif } unsigned long psMysqlConnection::Command(const char *sql,...) @@ -510,6 +543,7 @@ return result; } +#ifdef USE_DELAY_QUERY DelayedQueryManager::DelayedQueryManager(const char *host, unsigned int port, const char *database, const char *user, const char *pwd) @@ -563,4 +597,5 @@ start = tstart; } datacondition.NotifyOne(); -} \ No newline at end of file +} +#endif \ No newline at end of file Modified: trunk/src/server/database/mysql/dal.h =================================================================== --- trunk/src/server/database/mysql/dal.h 2007-11-11 01:22:59 UTC (rev 246) +++ trunk/src/server/database/mysql/dal.h 2007-11-11 01:57:36 UTC (rev 247) @@ -26,6 +26,7 @@ struct iObjectRegistry; +#ifdef USE_DELAY_QUERY class DelayedQueryManager : public CS::Threading::Runnable { public: @@ -45,7 +46,9 @@ bool m_Close; psDBProfiles profs; }; +#endif + class psMysqlConnection : public iComponent, public iDataConnection { protected: @@ -96,8 +99,10 @@ virtual const char* DumpProfile(); virtual void ResetProfile(); +#ifdef USE_DELAY_QUERY csRef<DelayedQueryManager> dqm; csRef<Thread> dqmThread; +#endif }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |