Browse Source

add exec-sql when exit

lihz 8 years ago
parent
commit
7d69a7dd9e
3 changed files with 27 additions and 0 deletions
  1. 21 0
      QueueStrManager.cpp
  2. 1 0
      QueueStrManager.h
  3. 5 0
      YAServerDlg.cpp

+ 21 - 0
QueueStrManager.cpp

@@ -51,3 +51,24 @@ void QueueStrManager::AddString(const char * chr)
 	}
 	LeaveCriticalSection(&m_csQueueList);
 }
+
+void QueueStrManager::Execute()
+{
+	EnterCriticalSection(&m_csQueueList);
+	if(m_length > 0){
+		if(m_pfunc == NULL){
+			LeaveCriticalSection(&m_csQueueList);
+			return;
+		}
+		try
+		{
+			char* pchr = new char[m_length];
+			strcpy(pchr, m_chr);
+			QueueUserWorkItem(m_pfunc, (LPVOID)pchr, WT_EXECUTEDEFAULT);
+		}
+		catch(...){
+
+		}
+	}
+	LeaveCriticalSection(&m_csQueueList);
+}

+ 1 - 0
QueueStrManager.h

@@ -19,5 +19,6 @@ public:
 	};
 	~QueueStrManager(void);
 	void AddString(const char * chr);
+	void Execute();
 };
 

+ 5 - 0
YAServerDlg.cpp

@@ -640,6 +640,7 @@ void CYAServerDlg::stop_and_exit()
 	::SetMainWnd(NULL);
 	::SetInfoList(NULL);
 
+
 	if(is_start_tcp){
 		stop_tcp_server();
 	}
@@ -658,6 +659,10 @@ void CYAServerDlg::stop_and_exit()
 	m_thread_timer = NULL;
 
 	clear_all_list();
+
+	if(m_qsmSQL){
+		m_qsmSQL->Execute();
+	}
 	GetConnPool().CloseAllConn();
 
 	DeleteCriticalSection(&m_csWriteLog);