Skip to content

Commit 64c5400

Browse files
committed
Merge branch 'bugfix/fix_tcp_master_close_sockets' into 'master'
fix for closing tcp connections and watchdog timeout Closes IDFGH-11539 and IDFGH-11690 See merge request idf/esp-modbus!53
2 parents f0e78b6 + bf271f4 commit 64c5400

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

freemodbus/tcp_master/port/port_tcp_master.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,6 @@ static BOOL xMBTCPPortMasterCloseConnection(MbSlaveInfo_t *pxInfo)
236236
static void xMBTCPPortMasterShutdown(void)
237237
{
238238
xSemaphoreGive(xShutdownSema);
239-
vTaskDelete(NULL);
240-
xMbPortConfig.xMbTcpTaskHandle = NULL;
241239

242240
for (USHORT ucCnt = 0; ucCnt < MB_TCP_PORT_MAX_CONN; ucCnt++) {
243241
MbSlaveInfo_t* pxInfo = xMbPortConfig.pxMbSlaveInfo[ucCnt];
@@ -251,6 +249,8 @@ static void xMBTCPPortMasterShutdown(void)
251249
}
252250
}
253251
free(xMbPortConfig.pxMbSlaveInfo);
252+
vTaskDelete(NULL);
253+
xMbPortConfig.xMbTcpTaskHandle = NULL;
254254
}
255255

256256
void vMBTCPPortMasterSetNetOpt(void *pvNetIf, eMBPortIpVer xIpVersion, eMBPortProto xProto)
@@ -754,6 +754,8 @@ static void vMBTCPPortMasterTask(void *pvParameters)
754754
break;
755755
}
756756
putchar(ucDot);
757+
// if we don't yield we run the risk of hogging CPU
758+
vTaskDelay(pdMS_TO_TICKS(MB_TCP_CONNECTION_TIMEOUT_MS));
757759
xErr = xMBTCPPortMasterConnect(pxInfo);
758760
switch(xErr)
759761
{

0 commit comments

Comments
 (0)