• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

C++ error C2712: Cannot use __try in functions that require object unwinding

Newbie Spellweaver
Joined
Nov 25, 2011
Messages
79
Reaction score
2
I'm trying to build my Gunz project but can't seem to figure out this error right here. :$:

" error C2712: Cannot use __try in functions that require object unwinding "

Code:
void MSocketThread::Run()
{
	[B]__try[/B]
	{
			//throw(pThread);
		while(true) {	// Waiting for SafeUDP Settting...
			DWORD dwVal = WaitForSingleObject(m_KillEvent.GetEvent(), 100);
			if (dwVal == WAIT_OBJECT_0) {
				return;
			} else if (dwVal == WAIT_TIMEOUT) {
				if (m_pSafeUDP)
					break;
			}
		}

		WSAEVENT EventArray[WSA_MAXIMUM_WAIT_EVENTS];
		WORD wEventIndex = 0;

		bool bSendable = false;
		WSANETWORKEVENTS NetEvent;
		WSAEVENT hFDEvent = WSACreateEvent();
		EventArray[wEventIndex++] = hFDEvent;
		EventArray[wEventIndex++] = m_ACKEvent.GetEvent();
		EventArray[wEventIndex++] = m_SendEvent.GetEvent();
		EventArray[wEventIndex++] = m_KillEvent.GetEvent();

		WSAEventSelect(m_pSafeUDP->GetLocalSocket(), hFDEvent, FD_READ|FD_WRITE);

		while(TRUE) {
			DWORD dwReturn = WSAWaitForMultipleEvents(wEventIndex, EventArray, FALSE, SAFEUDP_SAFE_MANAGE_TIME, FALSE);
			if (dwReturn == WSA_WAIT_TIMEOUT) {					// Time
				m_pSafeUDP->LockNetLink();
				SafeSendManage();
				m_pSafeUDP->UnlockNetLink();
			} else if (dwReturn == WSA_WAIT_EVENT_0) {			// Socket Event
				WSAEnumNetworkEvents(m_pSafeUDP->GetLocalSocket(), hFDEvent, &NetEvent);
				if ((NetEvent.lNetworkEvents & FD_READ) == FD_READ) {
	//				OutputDebugString("SUDP> FD_READ \n");
					m_pSafeUDP->LockNetLink();
					Recv();
					m_pSafeUDP->UnlockNetLink();
				} 
				if ((NetEvent.lNetworkEvents & FD_WRITE) == FD_WRITE) {
					bSendable = true;
	//				OutputDebugString("SUDP> FD_WRITE \n");
				}
			} else if (dwReturn == WSA_WAIT_EVENT_0 + 1) {		// ACK Send Event
	//			OutputDebugString("SUDP> ACK_EVENT \n");
				FlushACK();
			} else if (dwReturn == WSA_WAIT_EVENT_0 + 2) {		// Packet Send Event
	//			OutputDebugString("SUDP> SEND_EVENT \n");
				if (bSendable == true)
					FlushSend();
			} else if (dwReturn == WSA_WAIT_EVENT_0 + 3) {		// Kill the Thread
				break;	// Stop Thread
			}
		}

		WSACloseEvent(hFDEvent);

		// Clear Queues
		LockSend();
		{
			for (SendListItor itor = m_SendList.begin(); itor != m_SendList.end(); ) {
				delete (*itor);
				itor = m_SendList.erase(itor);
			}
		}
		{
			for (SendListItor itor = m_TempSendList.begin(); itor != m_TempSendList.end(); ) {
				delete (*itor);
				itor = m_TempSendList.erase(itor);
			}
		}
		UnlockSend();

		LockACK();
		{
			for (ACKSendListItor itor = m_ACKSendList.begin(); itor != m_ACKSendList.end(); ) {
				delete (*itor);
				itor = m_ACKSendList.erase(itor);
			}
		}
		{
			for (ACKSendListItor itor = m_TempACKSendList.begin(); itor != m_TempACKSendList.end(); ) {
				delete (*itor);
				itor = m_TempACKSendList.erase(itor);
			}
		}
		UnlockACK();
	}
	[B]__except[/B](this->CrashDump(GetExceptionInformation())) 
	{
#ifndef _PUBLISH
		char szFileName[_MAX_DIR];
		GetModuleFileName(NULL, szFileName, _MAX_DIR);
		HANDLE hProcess = MProcessController::OpenProcessHandleByFilePath(szFileName);
		TerminateProcess(hProcess, 0);
#endif
	}

}

Appreciate all the help.
 
Back
Top