Skip to content

Commit ec17988

Browse files
committed
Fixed crash-bug in ProtocolExchange session handling
1 parent ae5b360 commit ec17988

3 files changed

Lines changed: 23 additions & 9 deletions

File tree

components/ProtocolExchange/FileStreamSession.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,9 @@ UtilsRetCode::RetCode FileStreamSession::handleCmdFrame(FileStreamBase::FileStre
222222
// Session may now be finished
223223
if (!_pFileStreamProtocolHandler->isActive())
224224
_isActive = false;
225+
226+
// Keep session alive while we're receiving
227+
_sessionLastActiveMs = millis();
225228
return rslt;
226229
}
227230

components/ProtocolExchange/ProtocolExchange.cpp

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@
2121
static const char* MODULE_PREFIX = "ProtExchg";
2222

2323
// Warn
24-
// #define WARN_ON_SLOW_PROC_ENDPOINT_MESSAGE
24+
#define WARN_ON_SLOW_PROC_ENDPOINT_MESSAGE
2525
#define WARN_ON_FILE_UPLOAD_FAILED
26+
#define WARN_ON_FILE_STREAM_SESSION_NOT_FOUND
2627
// #define WARN_ON_FILE_STREAM_BLOCK_LENGTH_ZERO
2728

2829
// Debug
@@ -83,8 +84,9 @@ void ProtocolExchange::service()
8384
if (!pSession->isActive())
8485
{
8586
#ifdef DEBUG_FILE_STREAM_SESSIONS
86-
LOG_I(MODULE_PREFIX, "service session inactive name %s channel %d streamID %d",
87-
pSession->getFileStreamName().c_str(), pSession->getChannelID(), pSession->getStreamID());
87+
LOG_I(MODULE_PREFIX, "service session inactive name %s channel %d streamID %d pSession %p",
88+
pSession->getFileStreamName().c_str(), pSession->getChannelID(),
89+
pSession->getStreamID(), pSession);
8890
#endif
8991
// Tidy up inactive session
9092
_sessions.remove(pSession);
@@ -452,10 +454,19 @@ UtilsRetCode::RetCode ProtocolExchange::processRICRESTCmdFrame(RICRESTMsg& ricRE
452454
}
453455

454456
// Check session is found
455-
if (!pSession && respondToMismatchedSession)
457+
if (!pSession)
456458
{
457-
// Failure
458-
Raft::setJsonBoolResult(ricRESTReqMsg.getReq().c_str(), respMsg, true);
459+
if (respondToMismatchedSession)
460+
{
461+
// Failure
462+
Raft::setJsonBoolResult(ricRESTReqMsg.getReq().c_str(), respMsg, true);
463+
}
464+
465+
// Debug
466+
#ifdef WARN_ON_FILE_STREAM_SESSION_NOT_FOUND
467+
LOG_W(MODULE_PREFIX, "processRICRESTCmdFrame session not found msgType %s streamName %s streamID %d",
468+
FileStreamBase::getFileStreamMsgTypeStr(fileStreamMsgType), fileStreamName.c_str(), streamID);
469+
#endif
459470
return UtilsRetCode::SESSION_NOT_FOUND;
460471
}
461472

@@ -638,8 +649,8 @@ FileStreamSession* ProtocolExchange::getFileStreamExistingSession(const char* fi
638649
return nullptr;
639650
}
640651
#ifdef DEBUG_FILE_STREAM_SESSIONS
641-
LOG_I(MODULE_PREFIX, "getFileStreamExistingSession OK name %s channelID %d streamID %d",
642-
fileStreamName, channelID, streamID);
652+
LOG_I(MODULE_PREFIX, "getFileStreamExistingSession OK name %s channelID %d streamID %d pSession %p",
653+
fileStreamName, channelID, streamID, pSession);
643654
#endif
644655
return pSession;
645656
}

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "RaftSysMods",
3-
"version": "0.1.6",
3+
"version": "0.1.7",
44
"description": "System modules for the Raft ESP32 framework",
55
"keywords": "esp32, esp32s3, framework",
66
"repository":

0 commit comments

Comments
 (0)