connectivity/com.nokia.tcf/native/TCFNative/TCFServer/ConnectionImpl.cpp
changeset 1473 6c45b7c9cdac
parent 1215 657de0649d83
child 1481 c7f22cc57d44
equal deleted inserted replaced
1472:6eab8978b7d5 1473:6c45b7c9cdac
    25 
    25 
    26 #ifdef _DEBUG
    26 #ifdef _DEBUG
    27 extern BOOL gDoLogging;
    27 extern BOOL gDoLogging;
    28 #endif
    28 #endif
    29 
    29 
    30 //#define LOG_CONNECTION
    30 #define LOG_CONNECTION
    31 #if defined(LOG_CONNECTION) && defined(_DEBUG)
    31 #if defined(LOG_CONNECTION) && defined(_DEBUG)
    32 #define TCDEBUGOPEN() if (gDoLogging) { this->m_DebugLog->WaitForAccess(); }
    32 #define TCDEBUGOPEN() if (gDoLogging) { this->m_DebugLog->WaitForAccess(); }
    33 #define TCDEBUGLOGS(s) if (gDoLogging) { sprintf(this->m_DebugLogMsg,"%s", s); this->m_DebugLog->log(this->m_DebugLogMsg); }
    33 #define TCDEBUGLOGS(s) if (gDoLogging) { sprintf(this->m_DebugLogMsg,"%s", s); this->m_DebugLog->log(this->m_DebugLogMsg); }
    34 #define TCDEBUGLOGA1(s, a1) if (gDoLogging) { sprintf(this->m_DebugLogMsg, s, a1); this->m_DebugLog->log(this->m_DebugLogMsg); }
    34 #define TCDEBUGLOGA1(s, a1) if (gDoLogging) { sprintf(this->m_DebugLogMsg, s, a1); this->m_DebugLog->log(this->m_DebugLogMsg); }
    35 #define TCDEBUGLOGA2(s, a1, a2) if (gDoLogging) { sprintf(this->m_DebugLogMsg, s, a1, a2); this->m_DebugLog->log(this->m_DebugLogMsg); }
    35 #define TCDEBUGLOGA2(s, a1, a2) if (gDoLogging) { sprintf(this->m_DebugLogMsg, s, a1, a2); this->m_DebugLog->log(this->m_DebugLogMsg); }
   408 
   408 
   409 		TCDEBUGLOGS("CConnectionImpl::DoSendMessage done\n");
   409 		TCDEBUGLOGS("CConnectionImpl::DoSendMessage done\n");
   410 		if (err == TCAPI_ERR_COMM_ERROR)
   410 		if (err == TCAPI_ERR_COMM_ERROR)
   411 		{
   411 		{
   412 //			EnterRetryPeriod(err, true, m_BaseComm->m_lastCommError);
   412 //			EnterRetryPeriod(err, true, m_BaseComm->m_lastCommError);
       
   413 			HandleFatalPortError(err, true, m_BaseComm->m_lastCommError);
   413 			m_OsError = m_BaseComm->m_lastCommError;
   414 			m_OsError = m_BaseComm->m_lastCommError;
   414 		}
   415 		}
   415 	}
   416 	}
   416 	else
   417 	else
   417 	{
   418 	{
   660 	TCDEBUGCLOSE();
   661 	TCDEBUGCLOSE();
   661 
   662 
   662 	return m_Registry->AddClient(client, numberIds, ids);
   663 	return m_Registry->AddClient(client, numberIds, ids);
   663 }
   664 }
   664 
   665 
       
   666 long CConnectionImpl::HandleFatalPortError(long err, bool passOsErr, DWORD osErr)
       
   667 {
       
   668 	TCDEBUGOPEN();
       
   669 	TCDEBUGLOGA3("CConnectionImpl::HandleFatalPortError err=%d passOsErr=%d osErr=%d\n", err, passOsErr, osErr);
       
   670 	TCDEBUGCLOSE();
       
   671 
       
   672 	m_BaseComm->ClosePort();
       
   673 	m_Status = eDisconnected;
       
   674 
       
   675 	NotifyClientsCommError(err);
       
   676 
       
   677 	return TCAPI_ERR_NONE;
       
   678 }
   665 void CConnectionImpl::NotifyClientsCommError(long tcfError, bool passOsError, DWORD osError)
   679 void CConnectionImpl::NotifyClientsCommError(long tcfError, bool passOsError, DWORD osError)
   666 {
   680 {
   667 //	TCDEBUGOPEN();
   681 //	TCDEBUGOPEN();
   668 //	TCDEBUGLOGS("CConnectionImpl::NotifyClientsCommError\n");
   682 //	TCDEBUGLOGS("CConnectionImpl::NotifyClientsCommError\n");
   669 //	TCDEBUGCLOSE();
   683 //	TCDEBUGCLOSE();
   767 				MPLOGA2("MessageProcessor PollPort = %d pollsize = %d\n", err, pollSize);
   781 				MPLOGA2("MessageProcessor PollPort = %d pollsize = %d\n", err, pollSize);
   768 				if (err != TCAPI_ERR_NONE)
   782 				if (err != TCAPI_ERR_NONE)
   769 				{
   783 				{
   770 					MPLOGA2("MessageProcessor  err = %d osError = %d\n", err, pThis->m_BaseComm->m_lastCommError);
   784 					MPLOGA2("MessageProcessor  err = %d osError = %d\n", err, pThis->m_BaseComm->m_lastCommError);
   771 //					pThis->EnterRetryPeriod(err, true, pThis->m_BaseComm->m_lastCommError);
   785 //					pThis->EnterRetryPeriod(err, true, pThis->m_BaseComm->m_lastCommError);
       
   786 					pThis->HandleFatalPortError(err, true, pThis->m_BaseComm->m_lastCommError);
   772 				}
   787 				}
   773 				else
   788 				else
   774 				{
   789 				{
   775 					if (pollSize == 0)
   790 					if (pollSize == 0)
   776 					{
   791 					{
   784 
   799 
   785 						MPLOGA2("MessageProcessor ProcessBuffer err = %d number = %d\n", err, numberProcessed);
   800 						MPLOGA2("MessageProcessor ProcessBuffer err = %d number = %d\n", err, numberProcessed);
   786 
   801 
   787 						if (err == TCAPI_ERR_COMM_ERROR)
   802 						if (err == TCAPI_ERR_COMM_ERROR)
   788 						{
   803 						{
       
   804 							MPLOGA2("MessageProcessor  err = %d osError = %d\n", err, pThis->m_BaseComm->m_lastCommError);
   789 							// for this error we have os error, but we probably caught this in PollPort already
   805 							// for this error we have os error, but we probably caught this in PollPort already
   790 //							pThis->EnterRetryPeriod(err, true, pThis->m_BaseComm->m_lastCommError);
   806 //							pThis->EnterRetryPeriod(err, true, pThis->m_BaseComm->m_lastCommError);
       
   807 							pThis->HandleFatalPortError(err, true, pThis->m_BaseComm->m_lastCommError);
   791 						}
   808 						}
   792 						else if (err != TCAPI_ERR_NONE)
   809 						else if (err != TCAPI_ERR_NONE)
   793 						{
   810 						{
   794 							// all clients already notified in ProcessBuffer
   811 							// all clients already notified in ProcessBuffer
   795 							err = TCAPI_ERR_NONE;
   812 							err = TCAPI_ERR_NONE;