Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ylmbtm committed Jul 9, 2021
1 parent d2d00ec commit a788ee9
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 11 deletions.
13 changes: 13 additions & 0 deletions Server/Src/ServerEngine/CrashReport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,19 @@
#pragma comment( lib, "DbgHelp" )


void NewInvalidParamHandler(const wchar_t* expression, const wchar_t* function, const wchar_t* file, unsigned int line, uintptr_t pReserved)
{
throw 1;
}
void NewPureCallHandler(void)
{
throw 1;
}
LPTOP_LEVEL_EXCEPTION_FILTER g_preFilter;

std::string g_AppName;
_invalid_parameter_handler g_preInvalidParamHandler;
_purecall_handler g_prePureHandler;


long __stdcall CrashCallBack(_EXCEPTION_POINTERS* pExInfo)
Expand Down Expand Up @@ -46,6 +56,8 @@ void SetCrashReport(std::string strAppName)
{
g_AppName = strAppName;
g_preFilter = SetUnhandledExceptionFilter(CrashCallBack);
g_preInvalidParamHandler = _set_invalid_parameter_handler(NewInvalidParamHandler);
g_prePureHandler = _set_purecall_handler(NewPureCallHandler);
}

void UnSetCrashReport()
Expand Down Expand Up @@ -78,6 +90,7 @@ void exceptionalStack(int signal)

void SetCrashReport(std::string strAppName)
{
return;
g_AppName = strAppName;
/*捕获异常信息 start*/
signal(SIGABRT, &exceptionalStack); //异常终止(abort)
Expand Down
6 changes: 6 additions & 0 deletions Server/Src/ServerEngine/CrashReport.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#ifndef _CRASH_REPORT_H_
#define _CRASH_REPORT_H_

void NewInvalidParamHandler(const wchar_t* expression,
const wchar_t* function,
const wchar_t* file,
unsigned int line,
uintptr_t pReserved);
void NewPureCallHandler(void);
/*安放crash定位*/
void SetCrashReport(std::string strAppName);

Expand Down
14 changes: 5 additions & 9 deletions Server/Src/ServerEngine/DBInterface/CppMysql.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,11 +290,6 @@ void CppMySQLQuery::nextRow()
_row = mysql_fetch_row(m_MysqlRes);
}

bool CppMySQLQuery::hasResult()
{
return m_MysqlRes != NULL;
}

const unsigned char* CppMySQLQuery::getBlobField(int nField, int& nLen)
{
const unsigned char* pData = (const unsigned char*)getStringField(nField);
Expand Down Expand Up @@ -394,8 +389,6 @@ bool CppMySQL3DB::open(const char* host, const char* user, const char* passwd, c
goto EXT;
}



//unsigned int timeout = 2;
//if (0 != mysql_options(m_pMySqlDB, MYSQL_OPT_CONNECT_TIMEOUT, (const char*)&timeout))
//{
Expand Down Expand Up @@ -475,6 +468,7 @@ MYSQL* CppMySQL3DB::getMysql()
/* 处理返回多行的查询,返回影响的行数 */
CppMySQLQuery& CppMySQL3DB::querySQL(const char* sql)
{
m_nErrNo = 0;
int nRet = mysql_real_query(m_pMySqlDB, sql, (unsigned long)strlen(sql));
if (nRet != 0)
{
Expand All @@ -486,8 +480,7 @@ CppMySQLQuery& CppMySQL3DB::querySQL(const char* sql)
nRet = mysql_real_query(m_pMySqlDB, sql, (unsigned long)strlen(sql));
}
}

if (0 == nRet)
else
{
m_dbQuery.m_MysqlRes = mysql_store_result(m_pMySqlDB);
}
Expand All @@ -497,6 +490,7 @@ CppMySQLQuery& CppMySQL3DB::querySQL(const char* sql)
/* 执行非返回结果查询 */
int CppMySQL3DB::execSQL(const char* sql)
{
m_nErrNo = 0;
int nRet = mysql_real_query(m_pMySqlDB, sql, (unsigned long)strlen(sql));
if (nRet == 0)
{
Expand Down Expand Up @@ -599,6 +593,7 @@ bool CppMySQL3DB::reconnect()
/* 主要功能:开始事务 */
bool CppMySQL3DB::startTransaction()
{
m_nErrNo = 0;
if(!mysql_real_query(m_pMySqlDB, "START TRANSACTION", (unsigned long)strlen("START TRANSACTION") ))
{
return true;
Expand All @@ -613,6 +608,7 @@ bool CppMySQL3DB::startTransaction()
/* 主要功能:提交事务 */
bool CppMySQL3DB::commit()
{
m_nErrNo = 0;
if(!mysql_real_query( m_pMySqlDB, "COMMIT", (unsigned long)strlen("COMMIT") ) )
{
return true;
Expand Down
2 changes: 0 additions & 2 deletions Server/Src/ServerEngine/DBInterface/CppMysql.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ class CppMySQLQuery

void nextRow();

bool hasResult();

private:
void freeRes();

Expand Down
2 changes: 2 additions & 0 deletions Server/Src/ServerEngine/Log.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,6 @@ class CLog
continue; \
}

#define PARSE_FROM_PACKET(TYPE, VALUE) TYPE VALUE; \
ERROR_RETURN_TRUE(VALUE.ParsePartialFromArray(pNetPacket->m_pDataBuffer->GetData(), pNetPacket->m_pDataBuffer->GetBodyLenth()));
#endif

0 comments on commit a788ee9

Please sign in to comment.