Repository navigation
PumpUntilBoth reports which side timed out; fix 85 mislabelled message ids (#65) - #67
Conversation
…e names Two related changes: PumpUntilBoth now reports which side timed out, and the name table it leans on is corrected. PumpUntilBoth returned a bare bool and nulled both out-params, so a timeout at any of its 9 call sites said only "something did not arrive". #62 was diagnosable precisely because the code it replaced named the side. It now returns a ::testing::AssertionResult; every call site already wraps it in ASSERT_TRUE, which prints the message, so no call site changed. Naming the ids in that message exposed a library bug. PacketLogger's name table was missing ID_RAKVOICE_RELAY_DATA (id 48), and since the table is positional, every id from 48 to 132 reported the NEXT id's name: ID_SESSION_CONFIG_REQUEST printed as "ID_SESSION_CONFIG", ID_SESSION_CONFIG_ABANDONED as "ID_RESERVED_8", ID_RESERVED_9 as "ID_USER_PACKET_ENUM". 85 ids mislabelled, the whole session-config range among them. A stray trailing ID_USER_PACKET_ENUM sentinel kept the array the expected length, so nothing caught it. This is diagnostic-only, but it misleads exactly when someone is reading a handshake log to debug a handshake -- which is how the #62 investigation was conducted. Tests/Unit/PacketLoggerIdNamesTests.cpp pins the ends of the table and both sides of the break. Pinning the LAST entry is the load-bearing case: a name dropped anywhere earlier pushes it off its own slot. Verified by reverting the one-line fix: 3 of the 7 cases fail, naming the shifted values. The blanket sweep alone does not catch it, since shifted names are still well-formed -- hence the pinned assertions. The test and the integration helper are guarded on _RAKNET_SUPPORT_PacketLogger so MAFIANET_MINIMAL together with MAFIANET_BUILD_TESTS still builds. Verified on macOS arm64: full ctest 283/283. Fixes #65
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (3)
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review. WalkthroughThe packet name table now includes ChangesPacket ID names and timeout diagnostics
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Low Merge Risk: ⚪ Minimal · up to The packet-name correction and timeout diagnostics appear ready to merge after normal checks. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. A rabbit checks the packet names, Comment |
Fixes #65, and fixes a library bug that writing #65 exposed.
1. The requested fix
PumpUntilBothreturned a barebooland nulled both out-params, so a timeout at any of its 9 call sites said only "something didn't arrive". #62 was diagnosable precisely because the sequential code it replaced named the side.It now returns a
::testing::AssertionResult. Every call site already wraps it inASSERT_TRUE, which prints the message — so no call site changed:2. The library bug it exposed
Naming the ids required
PacketLogger::BaseIDTOString, and that message came back with the wrong name —ID_RESERVED_8forID_SESSION_CONFIG_ABANDONED.The table was missing
ID_RAKVOICE_RELAY_DATA(id 48). It is positional, so every id from 48 to 132 reported the next id's name:ID_SESSION_CONFIGID_SESSION_CONFIG_REQUESTID_RESERVED_8ID_SESSION_CONFIG_ABANDONEDID_USER_PACKET_ENUMID_RESERVED_985 ids mislabelled, the entire session-config range among them. A stray trailing
ID_USER_PACKET_ENUMsentinel kept the array at the expected length, so no length check could catch it. Fix is one line.Diagnostic-only severity — but it misleads exactly when someone is reading a handshake log to debug a handshake, which is how the #62 investigation was run. I fixed it here rather than filing it, because shipping #65's diagnostics on top of a table that prints wrong names would make the feature actively misleading.
3. Test
Tests/Unit/PacketLoggerIdNamesTests.cpp(7 cases, Unit per CLAUDE.md — pure logic, no networking). Pins the table's ends and both sides of the break. Pinning the last entry is the load-bearing case: a name dropped anywhere earlier pushes it off its own slot.Verified by reverting the one-line fix — 3 of 7 cases fail, naming the shifted values. Worth noting the blanket sweep alone does not catch it, since shifted names are still well-formed
ID_*strings; that's why the pinned assertions exist.Test and integration helper are guarded on
_RAKNET_SUPPORT_PacketLogger, soMAFIANET_MINIMAL+MAFIANET_BUILD_TESTSstill builds (thelinux-minimaljob doesn't build tests, so CI wouldn't have caught a regression there).Verification (macOS arm64)
Full
ctest: 283/283 (276 + 7 new).Unrelated flake, for the record
PingTests.PingStatisticsAndOccasionalPingfailed once during this work. It is not from this branch — it asserts hard wall-clock thresholds on loopback ping (average ping 12 exceeded threshold 10) and binds fixed port 60000, both of which CLAUDE.md warns against. Measured: 40/40 pass idle on this branch, 7/12 under artificial CPU load; master behaves the same. Not touched here — happy to file it separately.Summary by CodeRabbit