Sfoglia il codice sorgente

#IQRV #comment [Module] CardIssuerAdapter::SafeDelete

gifur 4 anni fa
parent
commit
596a9572a0

+ 6 - 6
Module/mod_CardReadAdapter/CardReadAdapterFSM.cpp

@@ -1347,7 +1347,7 @@ void CCardReadAdapterFSM::CheckAndReconnectSession()
 		{
 			if (m_pCardIssuer != NULL)
 			{
-				//m_pCardIssuer->SafeDelete();
+				m_pCardIssuer->GetFunction()->CloseSession();
 				m_pCardIssuer = NULL;
 			}
 			m_pCardIssuer = new CardIssuerService_ClientBase(GetEntityBase());
@@ -1359,7 +1359,7 @@ void CCardReadAdapterFSM::CheckAndReconnectSession()
 					if (cardIssuerCount%120 == 0)//about 10 minutes can't connect to entity
 						Dbg("connect to entity CardIssuer failed.%d", eErr);
 					cardIssuerCount++;
-					//m_pCardIssuer->SafeDelete();
+					m_pCardIssuer->SafeDelete();
 					m_pCardIssuer = NULL;
 				}
 				else
@@ -1375,7 +1375,7 @@ void CCardReadAdapterFSM::CheckAndReconnectSession()
 		{
 			if (m_pContactless != NULL)
 			{
-				//m_pContactless->SafeDelete();
+				m_pContactless->GetFunction()->CloseSession();
 				m_pContactless = NULL;
 			}
 			m_pContactless = new ContactlessCardService_ClientBase(GetEntityBase());
@@ -1387,7 +1387,7 @@ void CCardReadAdapterFSM::CheckAndReconnectSession()
 					if (contactlessCardCount % 120 == 0)//about 10 minutes can't connect to entity
 						Dbg("connect to entity ContactlessCard failed.%d", eErr);
 					contactlessCardCount++;
-					//m_pContactless->SafeDelete();
+					m_pContactless->SafeDelete();
 					m_pContactless = NULL;
 				}
 				else
@@ -1402,7 +1402,7 @@ void CCardReadAdapterFSM::CheckAndReconnectSession()
 		{
 			if (m_pCardSwiper != NULL)
 			{
-				//m_pCardSwiper->SafeDelete();
+				m_pCardSwiper->GetFunction()->CloseSession();
 				m_pCardSwiper = NULL;
 			}
 			m_pCardSwiper = new CardSwiperService_ClientBase(GetEntityBase());
@@ -1414,7 +1414,7 @@ void CCardReadAdapterFSM::CheckAndReconnectSession()
 					if (cardSwiperCount%120 == 0)//about 10 minutes can't connect to entity
 						Dbg("connect to entity CardSwiper failed.%d", eErr);
 					cardSwiperCount++;
-					//m_pCardSwiper->SafeDelete();
+					m_pCardSwiper->SafeDelete();
 					m_pCardSwiper = NULL;
 				}
 				else

+ 7 - 6
Module/mod_cardissuer/CardIssuerFSM.cpp

@@ -4584,13 +4584,14 @@ int CCardIssuerFSM::SyncDataToDB(bool bMaintain[3], bool bSetCaptured)
 	{
 		Dbg("to connect to guiconsole");
 		eConn = pGuiConsoleClient->Connect();
+		if(eConn != Error_Succeed)
+			pGuiConsoleClient->SafeDelete();
 	}
 	else
 		Dbg("new pGuiConsoleClient failed.");
 	if (eConn != Error_Succeed)
 	{
 		Dbg("SyncDataToDB can't connect to GUIConsole.");
-		//pGuiConsoleClient->SafeDelete();
 		pGuiConsoleClient = NULL;
 		return -1;
 	}
@@ -4666,7 +4667,6 @@ int CCardIssuerFSM::SyncDataToDB(bool bMaintain[3], bool bSetCaptured)
 		eConn = pGuiConsoleClient->SyncMaterialCount(info);
 		Dbg("%d", eConn);
 		pGuiConsoleClient->GetFunction()->CloseSession();
-		//pGuiConsoleClient->SafeDelete();
 		pGuiConsoleClient = NULL;
 		if (eConn != Error_Succeed)
 			return -2;
@@ -4877,7 +4877,6 @@ bool CCardIssuerFSM::RegistCardWhileCaptureCard()
 				if (pGuiConsoleClient != NULL)
 				{
 					pGuiConsoleClient->GetFunction()->CloseSession();
-					//pGuiConsoleClient->SafeDelete();
 					pGuiConsoleClient = NULL;
 				}
 			}
@@ -6070,8 +6069,11 @@ int CCardIssuerFSM::PreOnlineOnStore(SpReqAnsContext<CardIssuerService_PreOnline
 	HeartBeatService_ClientBase *pHeartBeatClient = NULL;
 	ErrorCodeEnum eErr = Error_Unexpect;
 	pHeartBeatClient = new HeartBeatService_ClientBase(GetEntityBase());
-	if (pHeartBeatClient != NULL)
+	if (pHeartBeatClient != NULL) {
 		eErr = pHeartBeatClient->Connect();
+		if(eErr != Error_Succeed)
+			pHeartBeatClient->SafeDelete();
+	}
 	else
 	{
 		Dbg("pGuiConsoleClient is null?");
@@ -6093,8 +6095,7 @@ int CCardIssuerFSM::PreOnlineOnStore(SpReqAnsContext<CardIssuerService_PreOnline
 			req.slot = ctx->Req.slot;
 			eErr = pHeartBeatClient->CardActive(req, ans, 60000);
 			Dbg("card active result:%x", eErr);
-			//clear
-			//pHeartBeatClient->SafeDelete();
+			pHeartBeatClient->GetFunction()->CloseSession();
 			pHeartBeatClient = NULL;
 		}
 	}

+ 2 - 34
Module/mod_cardswiper/CardSwiperFSM.cpp

@@ -3271,38 +3271,6 @@ ErrorCodeEnum CCardSwiperFSM::CommitSuicide()
 	ErrorCodeEnum erroCode = Error_Succeed;
 
 	erroCode = ReStartRelateEntity("CardSwiper");
-
-	//if(m_pSelfcheckClient == NULL)
-	//{
-	//	m_pSelfcheckClient = new SelfChekerClient(this->GetEntityBase());
-	//	if(m_pSelfcheckClient == NULL)
-	//		return Error_Unexpect;
-	//	erroCode = m_pSelfcheckClient->Connect();
-	//	if(erroCode != Error_Succeed)
-	//	{
-	//		m_pSelfcheckClient->SafeDelete();
-	//		m_pSelfcheckClient = NULL;
-	//		Dbg("Connect to SelfCheck entity failed, 0x%x.", erroCode);
-	//		return erroCode;
-	//	}
-	//	Dbg("Connect to SelfCheck entity suc.");
-	//}
-
-
-	//SelfCheckerService_RealCheck_Req req;
-	//req.name = this->GetEntityBase()->GetEntityName();
-	//SelfCheckerService_RealCheck_Ans ans;
-	//erroCode = m_pSelfcheckClient->RealCheck(req, ans, 5000);
-	//if(erroCode != Error_Succeed)
-	//{
-	//	Dbg("RealCheck for %s failed 0x%x.", (LPCTSTR)req.name, erroCode);
-	//	m_pSelfcheckClient->SafeDelete();
-	//	m_pSelfcheckClient = NULL;
-	//}
-	//else
-	//{
-	//	Dbg("RealCheck for %s suc.", (LPCTSTR)req.name);
-	//}
 	return erroCode;
 }
 
@@ -3317,6 +3285,7 @@ ErrorCodeEnum CCardSwiperFSM::CheckPinPadStatus()
 	if (erroCode != Error_Succeed)
 	{
 		Dbg("connect PinPad fail 0x%x(%d).", erroCode, erroCode);
+		pPinPadClient->SafeDelete();
 	}
 	else
 	{
@@ -3349,7 +3318,7 @@ ErrorCodeEnum CCardSwiperFSM::CheckPinPadStatus()
 		}
 		pPinPadClient->GetFunction()->CloseSession();
 	}
-	pPinPadClient->SafeDelete();
+	
 	pPinPadClient = NULL;
 	return erroCode;
 }
@@ -3521,7 +3490,6 @@ int CCardSwiperFSM::GetAccessAuthState()
 			Dbg("GetNetworkState from HealthManager failed 0x%x.", ec);
 		}
 		pClient->GetFunction()->CloseSession();
-		pClient->SafeDelete();
 		pClient = NULL;
 	}
 	return nRes;