Skip to content

Commit 42c421e

Browse files
Carsten SchaferCarsten Schafer
authored andcommitted
Handle scenario where 3+ readable events including continuation frames all resulted in a final frame of 0 length
Signed-off-by: Carsten Schafer <Carsten.Schafer@kinarasystems.com>
1 parent 98bfb4b commit 42c421e

5 files changed

Lines changed: 20 additions & 11 deletions

File tree

src/AP_WS_Connection.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -605,10 +605,16 @@ namespace OpenWifi {
605605
void AP_WS_Connection::ProcessWSFinalPayload() {
606606
auto IncomingSize = IncomingFrame_.size();
607607

608+
if (IncomingSize == 0) {
609+
poco_warning(Logger_,
610+
fmt::format("ProcessWSFrame({}): Final Acc. Frame received but empty",
611+
CId_));
612+
return;
613+
}
608614
IncomingFrame_.append(0);
609615

610616
poco_trace(Logger_,
611-
fmt::format("ProcessWSFrame({}): Final Frame received (len={}, Msg={}",
617+
fmt::format("ProcessWSFrame({}): Final Acc. Frame received (len={}, Msg={}",
612618
CId_, IncomingSize, IncomingFrame_.begin()));
613619

614620
Poco::JSON::Parser parser;
@@ -676,7 +682,7 @@ namespace OpenWifi {
676682
State_.MessageCount++;
677683
State_.LastContact = Utils::Now();
678684
poco_trace(Logger_,
679-
fmt::format("FRAME({}): Frame {} rx (len={}, flags={}, acc.len={})",
685+
fmt::format("FRAME({}): Frame rx (op={} len={}, flags={}, acc.len={})",
680686
CId_, Op, IncomingSize, flags, IncomingFrame_.size()));
681687

682688
switch (Op) {
@@ -698,7 +704,8 @@ namespace OpenWifi {
698704
PingDetails.set("locale", State_.locale);
699705
PingObject.set(uCentralProtocol::PING, PingDetails);
700706
poco_trace(Logger_,fmt::format("Sending PING for {}", SerialNumber_));
701-
KafkaManager()->PostMessage(KafkaTopics::CONNECTION, SerialNumber_,PingObject);
707+
KafkaManager()->PostMessage(KafkaTopics::CONNECTION, SerialNumber_,
708+
PingObject);
702709
}
703710
return;
704711
} break;
@@ -721,7 +728,8 @@ namespace OpenWifi {
721728
case Poco::Net::WebSocket::FRAME_OP_TEXT: {
722729
poco_trace(Logger_,
723730
fmt::format("TEXT({}): Frame received (len={}, flags={}). Msg={}",
724-
CId_, IncomingSize, flags, CurrentFrame.begin()));
731+
CId_, IncomingSize, flags,
732+
CurrentFrame.begin() == nullptr ? "" : CurrentFrame.begin()));
725733
} break;
726734

727735
case Poco::Net::WebSocket::FRAME_OP_CLOSE: {
@@ -738,7 +746,7 @@ namespace OpenWifi {
738746
}
739747
}
740748

741-
// Check for final frame and process accumlated payload
749+
// Check for final frame and process accumulated payload
742750
if (!KillConnection && (flags & Poco::Net::WebSocket::FRAME_FLAG_FIN) != 0) {
743751
ProcessWSFinalPayload();
744752
}

src/FileUploader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,4 +315,4 @@ namespace OpenWifi {
315315
poco_notice(Logger(), "Stopped...");
316316
}
317317

318-
} // namespace OpenWifi
318+
} // namespace OpenWifi

src/framework/MicroService.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,6 @@ namespace OpenWifi {
295295

296296
auto Level = Poco::Logger::parseLevel(
297297
MicroService::instance().ConfigGetString("logging.level", "debug"));
298-
//Level = Poco::Logger::parseLevel("trace"); // TODO: remove this
299298
Poco::Logger::root().setLevel(Level);
300299
if (!DisableWebSocketLogging) {
301300
static const UI_WebSocketClientServer::NotificationTypeIdVec Notifications = {

src/framework/utils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,6 @@ namespace OpenWifi::Utils {
943943

944944
return naptrRecords;
945945
}
946-
#endif
947946

948947
std::vector<SrvRecord> getSRVRecords(const std::string& domain) {
949948
std::vector<SrvRecord> srvRecords;
@@ -981,6 +980,7 @@ namespace OpenWifi::Utils {
981980

982981
return srvRecords;
983982
}
983+
#endif
984984

985985

986986
} // namespace OpenWifi::Utils

src/storage/storage_command.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -664,12 +664,14 @@ namespace OpenWifi {
664664
Insert.execute();
665665
Sess.commit();
666666
} else {
667-
poco_warning(Logger(), fmt::format("File {} is too large.", UUID));
667+
poco_warning(Logger(),
668+
fmt::format("File {} is too large ({} >= {} max bytes).",
669+
UUID, Size, FileUploader()->MaxSize()));
668670
}
669671

670672
// update CommandList here to ensure that file us uploaded
671-
Sess.begin();
672-
Poco::Data::Statement Statement(Sess);
673+
Sess.begin();
674+
Poco::Data::Statement Statement(Sess);
673675
std::string StatementStr;
674676
StatementStr =
675677
"UPDATE CommandList SET WaitingForFile=?, AttachDate=?, AttachSize=? WHERE UUID=?";

0 commit comments

Comments
 (0)