Skip to content

Commit 14ce2eb

Browse files
committed
Delete useless MYSQL code
improved:sql packet module
1 parent 2954c66 commit 14ce2eb

File tree

3 files changed

+29
-29
lines changed

3 files changed

+29
-29
lines changed

XEngine_Source/VSCopy.bat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ copy /y "%XEngine_Library%\x86\XEngine_HelpComponents\libmariadb.dll" "./"
2121
copy /y "%XEngine_Library%\x86\XEngine_HelpComponents\libpq.dll" "./"
2222
copy /y "%XEngine_Library%\x86\XEngine_HelpComponents\sqlite3.dll" "./"
2323
copy /y "%XEngine_Library%\x86\XEngine_HelpComponents\zlib1.dll" "./"
24+
copy /y "%XEngine_Library%\x86\XEngine_HelpComponents\plugin\caching_sha2_password.dll" "./"
2425
copy /y "%XEngine_Library%\x86\XEngine_LibEx\libcrypto-1_1.dll" "./"
2526
copy /y "%XEngine_Library%\x86\XEngine_LibEx\libssl-1_1.dll" "./"
2627
copy /y "%XEngine_Library%\x86\XEngine_LibEx\libcurl.dll" "./"

XEngine_Source/XEngine_StorageComponents/XStorage_SQLPacket/XStorage_MySql/XStorage_MySql.cpp

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ BOOL CXStorage_MySql::XStorage_MySql_Init(DATABASE_MYSQL_CONNECTINFO *pSt_DBConn
6767
return FALSE;
6868
}
6969
bIsRun = TRUE;
70+
7071
pSTDThread = make_shared<std::thread>(XStorage_MySql_Thread, this);
7172
if (!pSTDThread->joinable())
7273
{
@@ -93,10 +94,15 @@ BOOL CXStorage_MySql::XStorage_MySql_Destory()
9394
return TRUE;
9495
}
9596
bIsRun = FALSE;
96-
pSTDThread->join();
9797

98+
if (NULL != pSTDThread)
99+
{
100+
if (pSTDThread->joinable())
101+
{
102+
pSTDThread->join();
103+
}
104+
}
98105
DataBase_MySQL_Close(xhDBSQL);
99-
100106
return TRUE;
101107
}
102108
/********************************************************************
@@ -821,15 +827,6 @@ BOOL CXStorage_MySql::XStorage_MySql_TimeDel()
821827

822828
for (int i = 0; i < nListCount; i++)
823829
{
824-
//更新文件个数和大小
825-
memset(tszSQLQuery, '\0', sizeof(tszSQLQuery));
826-
_stprintf_s(tszSQLQuery, _T("UPDATE `XStorage_Count` SET FileCount = FileCount - 1,FileSize = FileSize - %lld"), ppSt_ListFile[i]->st_ProtocolFile.nFileSize);
827-
if (!DataBase_MySQL_Execute(xhDBSQL, tszSQLQuery))
828-
{
829-
XStorage_IsErrorOccur = TRUE;
830-
XStorage_dwErrorCode = DataBase_GetLastError();
831-
return FALSE;
832-
}
833830
//删除文件
834831
TCHAR tszFilePath[2048];
835832
memset(tszFilePath, '\0', sizeof(tszFilePath));
@@ -857,20 +854,17 @@ XHTHREAD CXStorage_MySql::XStorage_MySql_Thread(LPVOID lParam)
857854
CXStorage_MySql *pClass_This = (CXStorage_MySql *)lParam;
858855
time_t nTimeStart = time(NULL);
859856
time_t nTimeEnd = 0;
860-
BOOL bFirst = TRUE;
861857
int nTime = 60 * 60 * 12;
862858

863-
while (pClass_This->bIsRun)
864-
{
865-
if (((nTimeEnd - nTimeStart) > nTime) || bFirst)
859+
while (pClass_This->bIsRun)
860+
{
861+
if ((nTimeEnd - nTimeStart) > nTime)
866862
{
867863
pClass_This->XStorage_MySql_TimeDel();
868864
pClass_This->XStorage_MySql_CreateTable();
869-
bFirst = FALSE;
870865
}
871-
nTimeEnd = time(NULL);
872-
std::this_thread::sleep_for(std::chrono::seconds(1));
873-
}
866+
nTimeEnd = time(NULL);
867+
std::this_thread::sleep_for(std::chrono::milliseconds(10));
868+
}
874869
return 0;
875-
}
876-
870+
}

XEngine_Source/XEngine_StorageComponents/XStorage_SQLPacket/XStorage_SQLite/XStorage_SQLite.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,16 @@ BOOL CXStorage_SQLite::XStorage_SQLite_Destory()
9292
return TRUE;
9393
}
9494
bIsRun = FALSE;
95-
pSTDThread->join();
96-
delete pSTDThread;
95+
96+
if (NULL != pSTDThread)
97+
{
98+
if (pSTDThread->joinable())
99+
{
100+
pSTDThread->join();
101+
delete pSTDThread;
102+
pSTDThread = NULL;
103+
}
104+
}
97105
DataBase_SQLite_Close(xhSQL);
98106
return TRUE;
99107
}
@@ -639,20 +647,17 @@ XHTHREAD CXStorage_SQLite::XStorage_SQLite_Thread(LPVOID lParam)
639647
CXStorage_SQLite* pClass_This = (CXStorage_SQLite*)lParam;
640648
time_t nTimeStart = time(NULL);
641649
time_t nTimeEnd = 0;
642-
BOOL bFirst = TRUE;
643650
int nTime = 60 * 60 * 12;
644651

645652
while (pClass_This->bIsRun)
646653
{
647-
if (((nTimeEnd - nTimeStart) > nTime) || bFirst)
654+
if ((nTimeEnd - nTimeStart) > nTime)
648655
{
649656
pClass_This->XStorage_SQLite_TimeDel();
650657
pClass_This->XStorage_SQLite_CreateTable();
651-
bFirst = FALSE;
652658
}
653659
nTimeEnd = time(NULL);
654-
std::this_thread::sleep_for(std::chrono::seconds(1));
660+
std::this_thread::sleep_for(std::chrono::milliseconds(10));
655661
}
656662
return 0;
657-
}
658-
663+
}

0 commit comments

Comments
 (0)