Skip to content

Commit

Permalink
Check for shutdown in RxHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
christoph2 committed Jan 24, 2022
1 parent 9fefd88 commit 1683e12
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/tl/eth/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,15 @@ static int XcpTl_ReadHeader(uint16_t * len, uint16_t * counter)
XCP_FOREVER {
if (XcpTl_Connection.socketType == SOCK_DGRAM) {
nbytes = recvfrom(XcpTl_Connection.boundSocket, (char*)header_buffer + offset, bytes_remaining, 0,
(struct sockaddr *)&XcpTl_Connection.currentAddress, NULL);

(struct sockaddr *)&XcpTl_Connection.currentAddress, NULL);
if (XcpThrd_IsShuttingDown()) {
return 0;
}
} else if (XcpTl_Connection.socketType == SOCK_STREAM) {
nbytes = recv(XcpTl_Connection.connectedSocket, (char*)header_buffer + offset, bytes_remaining, 0);
nbytes = recv(XcpTl_Connection.connectedSocket, (char*)header_buffer + offset, bytes_remaining, 0);
if (XcpThrd_IsShuttingDown()) {
return 0;
}
}
if (nbytes < 1) {
return nbytes;
Expand Down Expand Up @@ -151,8 +156,8 @@ void XcpTl_RxHandler(void)
XcpHw_ErrorMsg("XcpTl_RxHandler:XcpTl_ReadHeader()", errno);
#endif
exit(2);
} else if (res == 0) {
exit(0);
} else if (res == 0) {
XcpTl_ReleaseConnection();
return;
}
if (!XcpThrd_IsShuttingDown()) {
Expand All @@ -165,8 +170,8 @@ void XcpTl_RxHandler(void)
XcpHw_ErrorMsg("XcpTl_RxHandler:XcpTl_ReadData()", errno);
#endif
exit(2);
} else if (res == 0) {
exit(0);
} else if (res == 0) {
printf("Empty data\n");
return;
}
#if 0
Expand All @@ -176,6 +181,8 @@ void XcpTl_RxHandler(void)
XCP_ASSERT_LE(dlc, XCP_TRANSPORT_LAYER_CTO_BUFFER_SIZE);
XcpUtl_MemCopy(Xcp_CtoIn.data, XcpTl_RxBuffer, dlc);
Xcp_DispatchCommand(&Xcp_CtoIn);
} else {
printf("shutting down\n");
}
}
}
Expand All @@ -202,7 +209,6 @@ static void XcpTl_Accept(void)
#elif defined(__unix__)
XcpHw_ErrorMsg("XcpTl_Accept::accept()", errno);
#endif
exit(1);
}
} else {
}
Expand Down

0 comments on commit 1683e12

Please sign in to comment.