Quellcode durchsuchen

maybe everything is ok

zhangbo vor 3 Jahren
Ursprung
Commit
5db258f6de
4 geänderte Dateien mit 32 neuen und 21 gelöschten Zeilen
  1. 11 19
      app/bmc/Api.c
  2. 10 0
      app/bmc/main.c
  3. 3 0
      app/bmc/uds/UDSIfc.c
  4. 8 2
      app/goahead-3.6.5/src/libipmi/src/libipmi_session.c

+ 11 - 19
app/bmc/Api.c

@@ -716,21 +716,12 @@ int API_BridgeInternal(MsgPkt_T* pReqPkt, MsgPkt_T* pResPkt, uint8_t DestAddr, i
 	uint8_t 		PBTbl;
 	
 	pthread_mutex_lock(&api_bridge_mutex);
-	//create BRIDGE_QUEUE
-    if(-1 != access(BRIDGE_QUEUE, F_OK))
-    {
-        remove(BRIDGE_QUEUE);
-    }
-    if(0 != mkfifo (BRIDGE_QUEUE, 0777))
-    {
-        printf("%s: Create %s fifo failed! \n", __FUNCTION__, BRIDGE_QUEUE);
-        pthread_mutex_unlock(&api_bridge_mutex);
-        return -1;
-    }
+	
     fd_BridgeQue = open (BRIDGE_QUEUE, O_RDWR);
     if(-1 == fd_BridgeQue)
     {
         printf("%s: Open %s fifo failed! \n", __FUNCTION__, BRIDGE_QUEUE);
+        close(fd_BridgeQue);
         pthread_mutex_unlock(&api_bridge_mutex);
         return -1;
     }
@@ -744,7 +735,7 @@ int API_BridgeInternal(MsgPkt_T* pReqPkt, MsgPkt_T* pResPkt, uint8_t DestAddr, i
     else
     {
         printf("Warning: Message Packet to be bridged is NULL\r\n");
-		remove(BRIDGE_QUEUE);
+        close(fd_BridgeQue);
 		pthread_mutex_unlock(&api_bridge_mutex);
         return -1;
     }    
@@ -755,7 +746,7 @@ int API_BridgeInternal(MsgPkt_T* pReqPkt, MsgPkt_T* pResPkt, uint8_t DestAddr, i
     else
     {
         printf("Warning: Message Packet to be bridged is NULL\r\n");
-		remove(BRIDGE_QUEUE);
+        close(fd_BridgeQue);
 		pthread_mutex_unlock(&api_bridge_mutex);
         return -1;
     }   
@@ -775,8 +766,8 @@ int API_BridgeInternal(MsgPkt_T* pReqPkt, MsgPkt_T* pResPkt, uint8_t DestAddr, i
     else
     {
         printf ("Warning: Invalid IPMB Channel: %d\r\n", Channel);
-		remove(BRIDGE_QUEUE);
 		pthread_mutex_unlock(&api_bridge_mutex);
+		close(fd_BridgeQue);
         return -1;
     }
 	
@@ -826,7 +817,7 @@ int API_BridgeInternal(MsgPkt_T* pReqPkt, MsgPkt_T* pResPkt, uint8_t DestAddr, i
 			if(SeqNum == g_BMCInfo.SendMsgSeqNum)
 			{
 				printf ("Warning: Pending Bridge Response Table is full \n");
-				remove(BRIDGE_QUEUE);
+				close(fd_BridgeQue);
 				pthread_mutex_unlock(&api_bridge_mutex);
 				return -1;
 			}
@@ -852,7 +843,7 @@ int API_BridgeInternal(MsgPkt_T* pReqPkt, MsgPkt_T* pResPkt, uint8_t DestAddr, i
 	else
 	{
 		printf("Warning: Invalid Channel %d\n", Channel);
-		remove(BRIDGE_QUEUE);
+		close(fd_BridgeQue);
 		pthread_mutex_unlock(&api_bridge_mutex);
 		return -1;
 	}
@@ -861,14 +852,14 @@ int API_BridgeInternal(MsgPkt_T* pReqPkt, MsgPkt_T* pResPkt, uint8_t DestAddr, i
     if(0 != PostMsg(pReqPkt->SrcQ, pReqPkt) )
     {
         printf ("Warning: oemApi.c : Error posting message to Queue %p \n", pReqPkt->SrcQ);
-		remove(BRIDGE_QUEUE);
+        close(fd_BridgeQue);
 		pthread_mutex_unlock(&api_bridge_mutex);
         return -1;
     }
 	
 	m_PendingBridgedResTbl[PBTbl][SeqNum].ResDataOk = 1;
 	
-    RetVal = GetMsg (fd_BridgeQue, pResPkt, 5000);  //3s
+    RetVal = GetMsg (fd_BridgeQue, pResPkt, 3);  //3s
 
     // int i;
     // printf("Bridge recv: ");
@@ -878,7 +869,8 @@ int API_BridgeInternal(MsgPkt_T* pReqPkt, MsgPkt_T* pResPkt, uint8_t DestAddr, i
     // }
     // printf("\n");
 
-	remove(BRIDGE_QUEUE);
+	//remove(BRIDGE_QUEUE);
+	close(fd_BridgeQue);
 	pthread_mutex_unlock(&api_bridge_mutex);
 	if(RetVal != 0)
 	{

+ 10 - 0
app/bmc/main.c

@@ -174,6 +174,16 @@ void main(void)
     new_value.it_interval.tv_usec = 0;
     setitimer(ITIMER_REAL, &new_value, NULL);
 
+    //create BRIDGE_QUEUE
+    if(-1 != access(BRIDGE_QUEUE, F_OK))
+    {
+        remove(BRIDGE_QUEUE);
+    }
+    if(0 != mkfifo (BRIDGE_QUEUE, 0777))
+    {
+        printf("%s: Create %s fifo failed! \n", __FUNCTION__, BRIDGE_QUEUE);
+    }
+
 
 	/* Create MsgHndlr Task */
 	gThreadIndex++;

+ 3 - 0
app/bmc/uds/UDSIfc.c

@@ -386,6 +386,7 @@ static int ProcessUDSReq(MsgPkt_T *pReq )
 **/
 int SendUDSPkt (MsgPkt_T *pRes)
 {
+    // struct timeval begin;
     // int i;
     // printf("---> server Send size: %d: ", pRes->Size);
     // for(i=0;i<pRes->Size;i++)
@@ -393,6 +394,8 @@ int SendUDSPkt (MsgPkt_T *pRes)
     // printf("\n");
     //printf("Send UDS!\n");
     /* Send the UDS response packet */
+    // gettimeofday(&begin,NULL);
+    // printf("UDS send:%ld:%ld\n", begin.tv_sec, begin.tv_usec);
      if(UDS_FAILURE == send(pRes->Socket,pRes->Data,pRes->Size,MSG_NOSIGNAL))
      {
        if((EBADF == errno) || (EPIPE == errno))

+ 8 - 2
app/goahead-3.6.5/src/libipmi/src/libipmi_session.c

@@ -116,6 +116,7 @@ uint16_t LIBIPMI_Send_RAW_IPMI2_0_Command(IPMI20_UDS_SESSION_T *pUDSSession,
     fd_set  fds;
     struct timeval Timeout;
     int max = 0;
+    //struct timeval begin;
 
     retlen = FillUDSMessagePacket(pUDSSession,pbyIPMIUDSMsgReq,byNetFnLUN,byCommand,pszReqData,dwReqDataLen);
 
@@ -161,8 +162,9 @@ uint16_t LIBIPMI_Send_RAW_IPMI2_0_Command(IPMI20_UDS_SESSION_T *pUDSSession,
         /*Accepting Connection*/
         if(FD_ISSET(pUDSSession->hUDSInfo.hSocket,&fds))
         {
-            byretval = recv(pUDSSession->hUDSInfo.hSocket,pbyIPMIUDSResData,MAX_RESPONSE_SIZE,0);
-            // printf("UDS Recv1 %d: ", byretval);
+            //这里只能接收10个字节,否则会把UDS Recv2的数据也接收了,导致UDS Recv2接收不到数据。
+            byretval = recv(pUDSSession->hUDSInfo.hSocket,pbyIPMIUDSResData,10,0);
+            //printf("UDS Recv1 %d: \n", byretval);
             // for(i=0;i<byretval;i++)
             //     printf("%#02x ", pbyIPMIUDSResData[i]);
             // printf("\n");
@@ -197,6 +199,10 @@ uint16_t LIBIPMI_Send_RAW_IPMI2_0_Command(IPMI20_UDS_SESSION_T *pUDSSession,
     /*Accepting Connection*/
     if(FD_ISSET(pUDSSession->hUDSInfo.hSocket,&fds))
     {
+        
+        // gettimeofday(&begin,NULL);
+        // printf("UDS Recv2:%ld:%ld\n", begin.tv_sec, begin.tv_usec);
+
         byretval = recv(pUDSSession->hUDSInfo.hSocket,pbyIPMIUDSResData,MAX_RESPONSE_SIZE,0);
         // printf("UDS Recv2 %d: ", byretval);
         // for(i=0;i<byretval;i++)