SyslogAppender packet splitting for large chunk counts#682
SyslogAppender packet splitting for large chunk counts#682jmestwa-coder wants to merge 1 commit into
Conversation
|
|
||
| void SyslogWriter::write(const LogString& source) | ||
| { | ||
| #if defined(UNIT_TEST) |
There was a problem hiding this comment.
how would this block ever get activated?
There was a problem hiding this comment.
UNIT_TEST is defined in syslogappendertestcase.cpp, so this path is only enabled for those tests.
The goal was to make the packet-size assertions deterministic without depending on UDP/network behavior. If there’s a preferred way to structure this kind of test in log4cxx, I’m happy to adjust it.
There was a problem hiding this comment.
It would never get compiled with UNIT_TEST defined though, you would have to compile the library with that macro defined.
Instead, it would make more sense to make a helper/utility function that can take a string of arbitrary length and split it up into smaller strings of a given max length. This function would then get called by the SyslogAppender to split the log message up. This function can then be properly tested on its own.
There was a problem hiding this comment.
Thanks for the suggestion .
I reworked the patch to move the splitting logic into a dedicated helper that SyslogAppender calls directly, removed the UNIT_TEST interception path, and updated the tests to validate the helper behavior directly instead of capturing network writes.
If there’s still a simpler structure you’d prefer here, I’m happy to adjust it further.
343e205 to
2af1fe0
Compare
Summary
Fix SyslogAppender packet splitting when large chunk counts cause the
(x/y)suffix to exceed the reserved suffix space.What changed
size_tindex arithmetic.MaxMessageLength.(x/y)suffix cannot fit alongside payload data.apr_snprintfsuffix formatting withStringHelper::toString.Behavior
MaxMessageLength, the appender now omits the suffix instead of emitting oversized packets.Tests
Added regression coverage for:
Result
Ensures emitted SyslogAppender payloads remain bounded by
MaxMessageLengthacross large message and packet-count edge cases.