researchman 8 years ago
parent
commit
24d8731be8
3 changed files with 31 additions and 38 deletions
  1. 30 34
      YAServerDlg.cpp.bak
  2. 0 2
      YAServerDlg.h
  3. 1 2
      minidupm.h

+ 30 - 34
YAServerDlg.cpp.bak

@@ -147,7 +147,6 @@ BEGIN_MESSAGE_MAP(CYAServerDlg, CDialogEx)
 	ON_COMMAND(ID_MENU_PARAM, &CYAServerDlg::OnMenuParam)
 	ON_BN_CLICKED(IDC_BTN_HIS, &CYAServerDlg::OnBnCallHisData)
 	ON_MESSAGE(WM_REFRESH_IP_LIST, &CYAServerDlg::OnMsgRefreshIpList)
-	ON_MESSAGE(WM_WRITE_ERROR_LOG, &CYAServerDlg::OnWriteErrorLog)
 	ON_MESSAGE(WM_PARSE_DATA, &CYAServerDlg::OnParseData)
 	ON_MESSAGE(WM_CARD_ADD_DIST, &CYAServerDlg::OnCardAddDist)
 	ON_MESSAGE(WM_REMOVE_SOCKET, &CYAServerDlg::OnRemoveSocket)
@@ -216,15 +215,17 @@ DWORD WINAPI _exec_sql(LPVOID lparam)
 	char *sql = (char*)lparam ;
 <<<<<<< HEAD
 	GetConnPool();
-=======
->>>>>>> 17a9653acaec63be648c72c8df532cbf7ec05e30
 
+=======
+>>>>>>> 576240e851bed0c99876f503bc88c74c777ed79e
 	CMysqlConn* pConn = NULL;
 	CDBConnGuard pDbGuard(pConn);
 	MYSQL_RES* pRes;
 	int err = 0;
 	pRes = pConn->Execute(sql, err);
 	mysql_free_result(pRes);
+	delete sql;
+	sql = NULL;
 	return 0;
 }
 
@@ -232,10 +233,17 @@ DWORD WINAPI _write_error_log(LPVOID lparam)
 {
 	LogInfo* err =  (LogInfo*)lparam;
 	CYAServerDlg* dlg = reinterpret_cast<CYAServerDlg*>(err->handle);
-	//CString strFile, strLog;
-	//strFile.Format(_T("%s"), (char *)err->path);
-	//strLog.Format(_T("%s"), (char *)err->strLog);
 	dlg->writeErrorLogEx(err->path, err->strLog, err->useTime);
+
+	// malloc
+	if(err){
+		free(err->path);
+		free(err->strLog);
+
+		delete err;
+		err = NULL;
+	}
+
 	return 0;
 }
 
@@ -3126,7 +3134,6 @@ void CYAServerDlg::formatByteArray( CString &strBuf, BYTE * buf, int nLen )
 
 void CYAServerDlg::writeErrorLog( const CString strFile, const CString strErr, bool bTime /*= true*/  )
 {
-	//LogInfo err;
 	LogInfo* err = new LogInfo;
 	err->handle = NULL;
 	err->useTime = false;
@@ -3134,30 +3141,12 @@ void CYAServerDlg::writeErrorLog( const CString strFile, const CString strErr, b
 	err->strLog = NULL;
 
 	err->handle = this;
-	//err.path = (LPCTSTR)strFile;
-	//err.strLog = (LPCTSTR)strErr;
 	err->useTime = bTime;
 
-	char *path = CFunctions::CString2char(strFile);
-	char *log  = CFunctions::CString2char(strErr);
-
-	err->path = NULL;
-	err->path = new char[100];
-	err->strLog = NULL;
-	err->strLog = new char[1024];
-
-	memset(err->path,0,100*sizeof(char));
-	memset(err->strLog,0,1024*sizeof(char));
-
-	strcpy(err->path,path);
-	strcpy(err->strLog,log);
+	err->path = CFunctions::CString2char(strFile);
+	err->strLog  = CFunctions::CString2char(strErr);
 
 	QueueUserWorkItem(_write_error_log, (LPVOID)err, WT_EXECUTEDEFAULT);
-
-	delete path;
-	path = NULL;
-	delete log;
-	log = NULL;
 }
 
 BOOL CYAServerDlg::openLogFile(CString strFile)
@@ -3200,7 +3189,9 @@ BOOL CYAServerDlg::openLogFile(const char* strFile)
 	int index = ctemp.ReverseFind('\\');
 	CString strFilePath = ctemp.Left(index+1);
 	CString strFileName;
-	strFileName.Format(_T("%s_%s.log"), strFile, COleDateTime::GetCurrentTime().Format(_T("%Y%m%d")));
+	//CString strTemp;
+	//strTemp.Format(_T("%S"),strFile);
+	strFileName.Format(_T("%S_%s.log"), strFile, COleDateTime::GetCurrentTime().Format(_T("%Y%m%d")));
 	strFilePath += _T("error\\");
 	strFilePath += strFileName;
 	if (cfErrorLog == NULL){
@@ -6255,7 +6246,6 @@ void CYAServerDlg::writeErrorLogEx( const CString strFile, const CString strErr
 	LeaveCriticalSection(&m_csWriteLog);
 }
 
-<<<<<<< HEAD
 void CYAServerDlg::writeErrorLogEx( const char* strFile, const char* strErr ,bool bTime /*= true*/ )
 {
 	EnterCriticalSection(&m_csWriteLog);
@@ -6263,9 +6253,15 @@ void CYAServerDlg::writeErrorLogEx( const char* strFile, const char* strErr ,boo
 		CString strTempInfo;
 		if(bTime){
 			COleDateTime t = COleDateTime::GetCurrentTime(); 
-			strTempInfo.Format(_T("%s\r\n%s\r\n"), t.Format(_T("%H:%M:%S")), strErr);
+			strTempInfo.Format(_T("%s\r\n"), t.Format(_T("%H:%M:%S")));
+			USES_CONVERSION;
+			CString tmp = A2T(strErr);
+			strTempInfo += tmp + _T("\r\n");
 		}else{
-			strTempInfo.Format(_T("%s\r\n"), strErr);
+			//strTempInfo.Format(_T("%S\r\n"), strErr);
+			USES_CONVERSION;
+			strTempInfo = A2T(strErr);
+			strTempInfo += _T("\r\n");
 		}
 		TRY{
 			cfErrorLog.SeekToEnd();
@@ -6284,9 +6280,9 @@ void CYAServerDlg::writeErrorLogEx( const char* strFile, const char* strErr ,boo
 		END_CATCH
 	}
 	LeaveCriticalSection(&m_csWriteLog);
-=======
+}
+
 void CYAServerDlg::init_queuestring()
 {
-	m_qsmSQL = new QueueStrManager(20, 3000, _exec_sql);
->>>>>>> 17a9653acaec63be648c72c8df532cbf7ec05e30
+	m_qsmSQL = new QueueStrManager(50, 7000, _exec_sql);
 }

+ 0 - 2
YAServerDlg.h

@@ -4,8 +4,6 @@
 
 #pragma once
 #include "afxwin.h"
-
-#include <atlutil.h>
 #include "resource.h"
 #include "structdef.h"
 #include "constdef.h"

+ 1 - 2
minidupm.h

@@ -1,6 +1,5 @@
 #pragma once
-//#include <DbgHelp.h>
-#include <ImageHlp.h>
+#include <DbgHelp.h>
 
 int GenerateMiniDump(HANDLE hFile, PEXCEPTION_POINTERS pExceptionPointers, PWCHAR pwAppName);
 LONG WINAPI ExceptionFilter(LPEXCEPTION_POINTERS lpExceptionInfo);