Jump to content

Error with db [db.core]


Recommended Posts

Hi guys, i have this code in the db.core

Spoiler

				
			root@host:/home/game/Channels/db # gdb
		GNU gdb 6.1.1 [FreeBSD]
		Copyright 2004 Free Software Foundation, Inc.
		GDB is free software, covered by the GNU General Public License, and you are
		welcome to change it and/or distribute copies of it under certain conditions.
		Type "show copying" to see the conditions.
		There is absolutely no warranty for GDB.  Type "show warranty" for details.
		This GDB was configured as "i386-marcel-freebsd".
		(gdb) file db
		Reading symbols from db...done.
		(gdb) core db.core
		Core was generated by `db'.
		Program terminated with signal 11, Segmentation fault.
		Reading symbols from /lib/libz.so.6...done.
		Loaded symbols for /lib/libz.so.6
		Reading symbols from /usr/lib/libstdc++.so.6...done.
		Loaded symbols for /usr/lib/libstdc++.so.6
		Reading symbols from /lib/libm.so.5...done.
		Loaded symbols for /lib/libm.so.5
		Reading symbols from /lib/libgcc_s.so.1...done.
		Loaded symbols for /lib/libgcc_s.so.1
		Reading symbols from /lib/libthr.so.3...done.
		Loaded symbols for /lib/libthr.so.3
		Reading symbols from /lib/libc.so.7...done.
		Loaded symbols for /lib/libc.so.7
		Reading symbols from /usr/lib/libsupc++.so.1...done.
		Loaded symbols for /usr/lib/libsupc++.so.1
		Reading symbols from /libexec/ld-elf.so.1...done.
		Loaded symbols for /libexec/ld-elf.so.1
		#0  0x28331930 in strtoul_l () from /lib/libc.so.7
		[New Thread 28405e00 (LWP 100643/db)]
		[New Thread 28405b00 (LWP 100642/db)]
		[New Thread 28405800 (LWP 100640/db)]
		[New Thread 28405500 (LWP 100639/db)]
		[New Thread 28405200 (LWP 100637/db)]
		[New Thread 28404f00 (LWP 100636/db)]
		[New Thread 28404c00 (LWP 100634/db)]
		[New Thread 28404900 (LWP 100633/db)]
		[New Thread 28404300 (LWP 100446/db)]
		(gdb) bt full
		#0  0x28331930 in strtoul_l () from /lib/libc.so.7
		No symbol table info available.
		#1  0x28331b9d in strtoul () from /lib/libc.so.7
		No symbol table info available.
		#2  0x080d54db in mysql_set_character_set ()
		No symbol table info available.
		#3  0x080ac345 in CAsyncSQL::QueryLocaleSet ()
		No symbol table info available.
		#4  0x08051100 in CDBManager::SetLocale (this=0x28421b00,
		    szLocale=0x2844db8c "latin1") at DBManager.cpp:172
		        n = 0
		        stLocale = {static npos = 4294967295,
		  _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<                                                                                          No data fields>}, <No data fields>}, _M_p = 0x2840d04c "latin1"}}
		#5  0x0805d535 in CClientManager::InitializeLocalization (this=0xbfbfd5ac)
		    at ClientManager.cpp:3646
		        locale = {szValue = "spain\0008 10 12 14 16 18 20 22 24",
		  szKey = "LOCALE\000OWER_BY_LEVEL_TYPE7\000a9(5"}
		        szQuery = "SELECT mValue, mKey FROM locale", '\0' <repeats 11 times>, "\                                                                                          017", '\0' <repeats 19 times>, "/\016▒9\224▒7\000▒Ͽ▒▒ѿ▒\230Ͽ▒\215▒4(▒Ͽ▒▒\0348(▒▒                                                                                          6(▒Ͽ▒I▒4(\224▒7(▒Ͽ▒>\2254(▒▒53▒▒6(▒Ͽ▒/\016▒9▒\223\020(8d\020(▒▒5(\224▒7(▒\0348(\                                                                                          203ѿ▒▒p9(▒Ͽ▒\000\000\000\000\000\000\000\000▒p9(▒Ͽ▒\000\000\000\000\000\000\000\                                                                                          000\034▒\r\b\037\000\000\000\234ѿ▒\000\000\000\000▒▒▒\177"...
		---Type <return> to continue, or q <return> to quit---q
		Quit
		(gdb) quit				
			 				
			

 

I have this in dbmanager.cpp lines 166 to 177


				
			void CDBManager::SetLocale(const char * szLocale)
		{
		    const std::string stLocale(szLocale);
		    sys_log(0, "SetLocale start" );
		    for (int n = 0; n < SQL_MAX_NUM; ++n)
		    {
		        m_mainSQL[n]->SetLocale(stLocale); // line 172 here
		        m_directSQL[n]->SetLocale(stLocale);
		        m_asyncSQL[n]->SetLocale(stLocale);
		    }
		    sys_log(0, "End setlocale %s", szLocale);
		}				
			 				
			

 

Someone know what mean this error?

I can see something like dbmanager.cpp on line 172, locale in db (common)

but i dont know why the .core appear (the server do not crash) and i want fix it.

 

Thanks.

Link to comment
Share on other sites

Sure

In the spoiler the full file, or here to download:

This is the hidden content, please

Spoiler

				
			#ifndef __WIN32__
		#include <sys/time.h>
		#endif				
			#include <cstdlib>
		#include <cstring>				
			#include "AsyncSQL.h"				
			// TODO: Consider providing platform-independent mutex class.
		#ifndef __WIN32__
		#define MUTEX_LOCK(mtx) pthread_mutex_lock(mtx)
		#define MUTEX_UNLOCK(mtx) pthread_mutex_unlock(mtx)
		#else
		#define MUTEX_LOCK(mtx) ::EnterCriticalSection(mtx)
		#define MUTEX_UNLOCK(mtx) ::LeaveCriticalSection(mtx)
		#endif				
			CAsyncSQL::CAsyncSQL()
		    : m_stHost(""), m_stUser(""), m_stPassword(""), m_stDB(""), m_stLocale(""),
		    m_iMsgCount(0), m_bEnd(false),
		#ifndef __WIN32__
		    m_hThread(0),
		#else
		    m_hThread(INVALID_HANDLE_VALUE),
		#endif
		    m_mtxQuery(NULL), m_mtxResult(NULL),
		    m_iQueryFinished(0), m_ulThreadID(0), m_bConnected(false), m_iCopiedQuery(0),
		    m_iPort(0)
		{
		    memset( &m_hDB, 0, sizeof(m_hDB) );				
			    m_aiPipe[0] = 0;
		    m_aiPipe[1] = 0;
		}				
			CAsyncSQL::~CAsyncSQL()
		{
		    Quit();
		    Destroy();
		}				
			void CAsyncSQL::Destroy()
		{
		    if (m_hDB.host)
		    {
		        sys_log(0, "AsyncSQL: closing mysql connection.");
		        mysql_close(&m_hDB);
		        m_hDB.host = NULL;
		    }				
			    if (m_mtxQuery)
		    {
		#ifndef __WIN32__
		        pthread_mutex_destroy(m_mtxQuery);
		#else
		        ::DeleteCriticalSection(m_mtxQuery);
		#endif
		        delete m_mtxQuery;
		        m_mtxQuery = NULL;
		    }				
			    if (m_mtxResult)
		    {
		#ifndef __WIN32__
		        pthread_mutex_destroy(m_mtxResult);
		#else
		        ::DeleteCriticalSection(m_mtxResult);
		#endif
		        delete m_mtxResult;
		        m_mtxQuery = NULL;
		    }
		}				
			#ifndef __WIN32__
		void * AsyncSQLThread(void * arg)
		#else
		unsigned int __stdcall AsyncSQLThread(void* arg)
		#endif
		{
		    CAsyncSQL * pSQL = ((CAsyncSQL *) arg);				
			    if (!pSQL->Connect())
		        return NULL;				
			    pSQL->ChildLoop();
		    return NULL;
		}				
			bool CAsyncSQL::QueryLocaleSet()
		{
		    if (0 == m_stLocale.length())
		    {
		        sys_err("m_stLocale == 0");
		        return true;
		    }				
			    else if (m_stLocale == "ascii")
		    {
		        sys_err("m_stLocale == ascii");
		        return true;
		    }				
			    if (mysql_set_character_set(&m_hDB, m_stLocale.c_str()))
		    {
		        sys_err("cannot set locale %s by 'mysql_set_character_set', errno %u %s", m_stLocale.c_str(), mysql_errno(&m_hDB) , mysql_error(&m_hDB));
		        return false;
		    }				
			    sys_log(0, "\t--mysql_set_character_set(%s)", m_stLocale.c_str());				
			    return true;
		}				
			bool CAsyncSQL::Connect()
		{
		    if (0 == mysql_init(&m_hDB))
		    {
		        fprintf(stderr, "mysql_init failed\n");
		        return false;
		    }				
			    //mysql_options(&m_hDB, MYSQL_SET_CHARSET_NAME, m_stLocale.c_str());
		    if (!m_stLocale.empty())
		    {
		        //mysql_options(&m_hDB, MYSQL_SET_CHARSET_DIR , " /usr/local/share/mysql/charsets/");
		        //mysql_options(&m_hDB, MYSQL_SET_CHARSET_DIR , "/usr/local/share/mysql/charsets");
		        //mysql_options(&m_hDB, MYSQL_SET_CHARSET_DIR , "/usr/local/share/mysql");
		        if (mysql_options(&m_hDB, MYSQL_SET_CHARSET_NAME, m_stLocale.c_str()) != 0)
		        {
		            fprintf(stderr, "mysql_option failed : MYSQL_SET_CHARSET_NAME %s ", mysql_error(&m_hDB));
		        }
		    }				
			    if (!mysql_real_connect(&m_hDB, m_stHost.c_str(), m_stUser.c_str(), m_stPassword.c_str(), m_stDB.c_str(), m_iPort, NULL, CLIENT_MULTI_STATEMENTS))
		    {
		        fprintf(stderr, "mysql_real_connect: %s\n", mysql_error(&m_hDB));
		        return false;
		    }				
			    my_bool reconnect = true;				
			    if (0 != mysql_options(&m_hDB, MYSQL_OPT_RECONNECT, &reconnect))
		        fprintf(stderr, "mysql_option: %s\n", mysql_error(&m_hDB));				
			    fprintf(stdout, "AsyncSQL: connected to %s (reconnect %d)\n", m_stHost.c_str(), m_hDB.reconnect);				
			    // db cache는 common db의 LOCALE 테이블에서 locale을 알아오고, 이후 character set을 수정한다.
		    // 따라서 최초 Connection을 맺을 때에는 locale을 모르기 때문에 character set을 정할 수가 없음에도 불구하고,
		    // 강제로 character set을 euckr로 정하도록 되어있어 이 부분을 주석처리 하였다.
		    // (아래 주석을 풀면 mysql에 euckr이 안 깔려있는 디비에 접근할 수가 없다.)
		    //while (!QueryLocaleSet());
		    m_ulThreadID = mysql_thread_id(&m_hDB);				
			    m_bConnected = true;
		    return true;
		}				
			bool CAsyncSQL::Setup(CAsyncSQL * sql, bool bNoThread)
		{
		    return Setup(sql->m_stHost.c_str(),
		            sql->m_stUser.c_str(),
		            sql->m_stPassword.c_str(),
		            sql->m_stDB.c_str(),
		            sql->m_stLocale.c_str(),
		            bNoThread,
		            sql->m_iPort);
		}				
			bool CAsyncSQL::Setup(const char * c_pszHost, const char * c_pszUser, const char * c_pszPassword, const char * c_pszDB, const char * c_pszLocale, bool bNoThread, int iPort)
		{
		    m_stHost = c_pszHost;
		    m_stUser = c_pszUser;
		    m_stPassword = c_pszPassword;
		    m_stDB = c_pszDB;
		    m_iPort = iPort;				
			    if (c_pszLocale)
		    {
		        m_stLocale = c_pszLocale;
		        sys_log(0, "AsyncSQL: locale %s", m_stLocale.c_str());
		    }				
			    if (!bNoThread)
		    {
		        /*
		        if (!mysql_thread_safe())//
		        {
		            fprintf(stderr, "FATAL ERROR!! mysql client library was not compiled with thread safety\n");
		            return false;
		        }
		        */
		#ifndef __WIN32__
		        m_mtxQuery = new pthread_mutex_t;
		        m_mtxResult = new pthread_mutex_t;				
			        if (0 != pthread_mutex_init(m_mtxQuery, NULL))
		        {
		            perror("pthread_mutex_init");
		            exit(0);
		        }				
			        if (0 != pthread_mutex_init(m_mtxResult, NULL))
		        {
		            perror("pthread_mutex_init");
		            exit(0);
		        }				
			        pthread_create(&m_hThread, NULL, AsyncSQLThread, this);
		#else
		        m_mtxQuery = new CRITICAL_SECTION;
		        m_mtxResult = new CRITICAL_SECTION;				
			        ::InitializeCriticalSection(m_mtxQuery);
		        ::InitializeCriticalSection(m_mtxResult);				
			        m_hThread = (HANDLE)::_beginthreadex(NULL, 0, AsyncSQLThread, this, 0, NULL);
		        if (m_hThread == INVALID_HANDLE_VALUE) {
		            perror("CAsyncSQL::Setup");
		            return false;
		        }
		#endif				
			        return true;
		    }
		    else
		        return Connect();
		}				
			void CAsyncSQL::Quit()
		{
		    m_bEnd = true;
		    m_sem.Release();				
			#ifndef __WIN32__
		    if (m_hThread)
		    {
		        pthread_join(m_hThread, NULL);
		        m_hThread = NULL;
		    }
		#else
		    if (m_hThread != INVALID_HANDLE_VALUE) {
		        ::WaitForSingleObject(m_hThread, INFINITE);
		        m_hThread = INVALID_HANDLE_VALUE;
		    }
		#endif
		}				
			SQLMsg * CAsyncSQL::DirectQuery(const char * c_pszQuery)
		{
		    if (m_ulThreadID != mysql_thread_id(&m_hDB))
		    {
		        sys_err("MySQL connection was reconnected. querying locale set");
		        while (!QueryLocaleSet());
		        m_ulThreadID = mysql_thread_id(&m_hDB);
		    }				
			    SQLMsg * p = new SQLMsg;				
			    p->m_pkSQL = &m_hDB;
		    p->iID = ++m_iMsgCount;
		    p->stQuery = c_pszQuery;				
			    if (mysql_real_query(&m_hDB, p->stQuery.c_str(), p->stQuery.length()))
		    {
		        char buf[1024];				
			        snprintf(buf, sizeof(buf),
		                "AsyncSQL::DirectQuery : mysql_query error: %s\nquery: %s",
		                mysql_error(&m_hDB), p->stQuery.c_str());				
			        sys_err(buf);
		        p->uiSQLErrno = mysql_errno(&m_hDB);
		    }				
			    p->Store();
		    return p;
		}				
			void CAsyncSQL::AsyncQuery(const char * c_pszQuery)
		{
		    SQLMsg * p = new SQLMsg;				
			    p->m_pkSQL = &m_hDB;
		    p->iID = ++m_iMsgCount;
		    p->stQuery = c_pszQuery;				
			    PushQuery(p);
		}				
			void CAsyncSQL::ReturnQuery(const char * c_pszQuery, void * pvUserData)
		{
		    SQLMsg * p = new SQLMsg;				
			    p->m_pkSQL = &m_hDB;
		    p->iID = ++m_iMsgCount;
		    p->stQuery = c_pszQuery;
		    p->bReturn = true;
		    p->pvUserData = pvUserData;				
			    PushQuery(p);
		}				
			void CAsyncSQL::PushResult(SQLMsg * p)
		{
		    MUTEX_LOCK(m_mtxResult);				
			    m_queue_result.push(p);				
			    MUTEX_UNLOCK(m_mtxResult);
		}				
			bool CAsyncSQL::PopResult(SQLMsg ** pp)
		{
		    MUTEX_LOCK(m_mtxResult);				
			    if (m_queue_result.empty())
		    {
		        MUTEX_UNLOCK(m_mtxResult);
		        return false;
		    }				
			    *pp = m_queue_result.front();
		    m_queue_result.pop();
		    MUTEX_UNLOCK(m_mtxResult);
		    return true;
		}				
			void CAsyncSQL::PushQuery(SQLMsg * p)
		{
		    MUTEX_LOCK(m_mtxQuery);				
			    m_queue_query.push(p);
		    //m_map_kSQLMsgUnfinished.insert(std::make_pair(p->iID, p));				
			    m_sem.Release();				
			    MUTEX_UNLOCK(m_mtxQuery);
		}				
			bool CAsyncSQL::PeekQuery(SQLMsg ** pp)
		{
		    MUTEX_LOCK(m_mtxQuery);				
			    if (m_queue_query.empty())
		    {
		        MUTEX_UNLOCK(m_mtxQuery);
		        return false;
		    }				
			    *pp = m_queue_query.front();
		    MUTEX_UNLOCK(m_mtxQuery);
		    return true;
		}				
			bool CAsyncSQL::PopQuery(int iID)
		{
		    MUTEX_LOCK(m_mtxQuery);				
			    if (m_queue_query.empty())
		    {
		        MUTEX_UNLOCK(m_mtxQuery);
		        return false;
		    }				
			    m_queue_query.pop();
		    //m_map_kSQLMsgUnfinished.erase(iID);				
			    MUTEX_UNLOCK(m_mtxQuery);
		    return true;
		}				
			bool CAsyncSQL::PeekQueryFromCopyQueue(SQLMsg ** pp)
		{
		    if (m_queue_query_copy.empty())
		        return false;				
			    *pp = m_queue_query_copy.front();
		    return true;
		}				
			int CAsyncSQL::CopyQuery()
		{
		    MUTEX_LOCK(m_mtxQuery);				
			    if (m_queue_query.empty())
		    {
		        MUTEX_UNLOCK(m_mtxQuery);
		        return -1;
		    }				
			    while (!m_queue_query.empty())
		    {
		        SQLMsg * p = m_queue_query.front();
		        m_queue_query_copy.push(p);
		        m_queue_query.pop();
		    }				
			    //m_map_kSQLMsgUnfinished.erase(iID);				
			    int count = m_queue_query_copy.size();    				
			    MUTEX_UNLOCK(m_mtxQuery);
		    return count;
		}				
			bool CAsyncSQL::PopQueryFromCopyQueue()
		{
		    if (m_queue_query_copy.empty())
		    {
		        return false;
		    }				
			    m_queue_query_copy.pop();
		    //m_map_kSQLMsgUnfinished.erase(iID);				
			    return true;
		}
		int        CAsyncSQL::GetCopiedQueryCount()
		{
		    return m_iCopiedQuery;
		}
		void     CAsyncSQL::ResetCopiedQueryCount()
		{
		    m_iCopiedQuery = 0;
		}				
			void    CAsyncSQL::AddCopiedQueryCount(int iCopiedQuery)
		{
		    m_iCopiedQuery += iCopiedQuery;
		}				
			 				
			DWORD CAsyncSQL::CountQuery()
		{
		    return m_queue_query.size();
		}				
			DWORD CAsyncSQL::CountResult()
		{
		    return m_queue_result.size();
		}				
			void __timediff(struct timeval *a, struct timeval *b, struct timeval *rslt)
		{
		    if (a->tv_sec < b->tv_sec)
		        rslt->tv_sec = rslt->tv_usec = 0;
		    else if (a->tv_sec == b->tv_sec)
		    {
		        if (a->tv_usec < b->tv_usec)
		            rslt->tv_sec = rslt->tv_usec = 0;
		        else
		        {
		            rslt->tv_sec = 0;
		            rslt->tv_usec = a->tv_usec - b->tv_usec;
		        }
		    }
		    else
		    {                      /* a->tv_sec > b->tv_sec */
		        rslt->tv_sec = a->tv_sec - b->tv_sec;				
			        if (a->tv_usec < b->tv_usec)
		        {
		            rslt->tv_usec = a->tv_usec + 1000000 - b->tv_usec;
		            rslt->tv_sec--;
		        } else
		            rslt->tv_usec = a->tv_usec - b->tv_usec;
		    }
		}				
			class cProfiler
		{
		    public:
		        cProfiler()
		        {
		            m_nInterval = 0 ;				
			            memset( &prev, 0, sizeof(prev) );
		            memset( &now, 0, sizeof(now) );
		            memset( &interval, 0, sizeof(interval) );				
			            Start();
		        }				
			        cProfiler(int nInterval = 100000)
		        {
		            m_nInterval = nInterval;				
			            memset( &prev, 0, sizeof(prev) );
		            memset( &now, 0, sizeof(now) );
		            memset( &interval, 0, sizeof(interval) );				
			            Start();
		        }				
			        void Start()
		        {
		            gettimeofday (&prev , (struct timezone *) 0);
		        }				
			        void Stop()
		        {
		            gettimeofday(&now, (struct timezone*) 0);
		            __timediff(&now, &prev, &interval);
		        }				
			        bool IsOk()
		        {
		            if (interval.tv_sec > (m_nInterval / 1000000))
		                return false;				
			            if (interval.tv_usec > m_nInterval)
		                return false;				
			            return true;
		        }				
			        struct timeval * GetResult() { return &interval; }
		        long GetResultSec() { return interval.tv_sec; }
		        long GetResultUSec() { return interval.tv_usec; }				
			    private:
		        int m_nInterval;
		        struct timeval  prev;
		        struct timeval  now;
		        struct timeval    interval;
		};				
			void CAsyncSQL::ChildLoop()
		{
		    cProfiler profiler(500000); // 0.5초				
			    while (!m_bEnd)
		    {
		        m_sem.Wait();				
			        int count = CopyQuery();				
			        if (count <= 0)
		            continue;				
			        AddCopiedQueryCount(count);				
			        SQLMsg * p;				
			        while (count--)
		        {
		            //시간 체크 시작
		            profiler.Start();				
			            if (!PeekQueryFromCopyQueue(&p))
		                continue;				
			            if (m_ulThreadID != mysql_thread_id(&m_hDB))
		            {
		                sys_err("MySQL connection was reconnected. querying locale set");
		                while (!QueryLocaleSet());
		                m_ulThreadID = mysql_thread_id(&m_hDB);
		            }				
			            if (mysql_real_query(&m_hDB, p->stQuery.c_str(), p->stQuery.length()))
		            {
		                p->uiSQLErrno = mysql_errno(&m_hDB);				
			                sys_err("AsyncSQL: query failed: %s (query: %s errno: %d)",
		                        mysql_error(&m_hDB), p->stQuery.c_str(), p->uiSQLErrno);				
			                switch (p->uiSQLErrno)
		                {
		                    case CR_SOCKET_CREATE_ERROR:
		                    case CR_CONNECTION_ERROR:
		                    case CR_IPSOCK_ERROR:
		                    case CR_UNKNOWN_HOST:
		                    case CR_SERVER_GONE_ERROR:
		                    case CR_CONN_HOST_ERROR:
		                    case ER_NOT_KEYFILE:
		                    case ER_CRASHED_ON_USAGE:
		                    case ER_CANT_OPEN_FILE:
		                    case ER_HOST_NOT_PRIVILEGED:
		                    case ER_HOST_IS_BLOCKED:
		                    case ER_PASSWORD_NOT_ALLOWED:
		                    case ER_PASSWORD_NO_MATCH:
		                    case ER_CANT_CREATE_THREAD:
		                    case ER_INVALID_USE_OF_NULL:
		                        m_sem.Release();
		                        sys_err("AsyncSQL: retrying");
		                        continue;
		                }
		            }				
			            profiler.Stop();
		            
		            // 0.5초 이상 걸렸으면 로그에 남기기
		            if (!profiler.IsOk())
		                sys_log(0, "[QUERY : LONG INTERVAL(OverSec %ld.%ld)] : %s",
		                        profiler.GetResultSec(), profiler.GetResultUSec(), p->stQuery.c_str());				
			            PopQueryFromCopyQueue();				
			            if (p->bReturn)
		            {
		                p->Store();
		                PushResult(p);
		            }
		            else
		                delete p;				
			            ++m_iQueryFinished;
		        }
		    }				
			    SQLMsg * p;				
			    while (PeekQuery(&p))
		    {
		        if (m_ulThreadID != mysql_thread_id(&m_hDB))
		        {
		            sys_err("MySQL connection was reconnected. querying locale set");
		            while (!QueryLocaleSet());
		            m_ulThreadID = mysql_thread_id(&m_hDB);
		        }				
			        if (mysql_real_query(&m_hDB, p->stQuery.c_str(), p->stQuery.length()))
		        {
		            p->uiSQLErrno = mysql_errno(&m_hDB);				
			            sys_err("AsyncSQL::ChildLoop : mysql_query error: %s:\nquery: %s",
		                    mysql_error(&m_hDB), p->stQuery.c_str());				
			            switch (p->uiSQLErrno)
		            {
		                case CR_SOCKET_CREATE_ERROR:
		                case CR_CONNECTION_ERROR:
		                case CR_IPSOCK_ERROR:
		                case CR_UNKNOWN_HOST:
		                case CR_SERVER_GONE_ERROR:
		                case CR_CONN_HOST_ERROR:
		                case ER_NOT_KEYFILE:
		                case ER_CRASHED_ON_USAGE:
		                case ER_CANT_OPEN_FILE:
		                case ER_HOST_NOT_PRIVILEGED:
		                case ER_HOST_IS_BLOCKED:
		                case ER_PASSWORD_NOT_ALLOWED:
		                case ER_PASSWORD_NO_MATCH:
		                case ER_CANT_CREATE_THREAD:
		                case ER_INVALID_USE_OF_NULL:
		                    continue;
		            }
		        }				
			        sys_log(0, "QUERY_FLUSH: %s", p->stQuery.c_str());				
			        PopQuery(p->iID);				
			        if (p->bReturn)
		        {
		            p->Store();
		            PushResult(p);
		        }
		        else
		            delete p;				
			        ++m_iQueryFinished;
		    }
		}				
			int CAsyncSQL::CountQueryFinished()
		{
		    return m_iQueryFinished;
		}				
			void CAsyncSQL::ResetQueryFinished()
		{
		    m_iQueryFinished = 0;
		}				
			MYSQL * CAsyncSQL::GetSQLHandle()
		{
		    return &m_hDB;
		}				
			size_t CAsyncSQL::EscapeString(char* dst, size_t dstSize, const char *src, size_t srcSize)
		{
		    if (0 == srcSize)
		    {
		        memset(dst, 0, dstSize);
		        return 0;
		    }				
			    if (0 == dstSize)
		        return 0;				
			    if (dstSize < srcSize * 2 + 1)
		    {
		        // \0이 안붙어있을 때를 대비해서 256 바이트만 복사해서 로그로 출력
		        char tmp[256];
		        size_t tmpLen = sizeof(tmp) > srcSize ? srcSize : sizeof(tmp); // 둘 중에 작은 크기
		        strlcpy(tmp, src, tmpLen);				
			        sys_err("FATAL ERROR!! not enough buffer size (dstSize %u srcSize %u src%s: %s)",
		                dstSize, srcSize, tmpLen != srcSize ? "(trimmed to 255 characters)" : "", tmp);				
			        dst[0] = '\0';
		        return 0;
		    }				
			    return mysql_real_escape_string(GetSQLHandle(), dst, src, srcSize);
		}				
			void CAsyncSQL2::SetLocale(const std::string & stLocale)
		{
		    m_stLocale = stLocale;    
		    QueryLocaleSet();
		}				
			 				
			

 

  • Good 1
  • Love 1
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.