Repository navigation
syslog: fix message-loss bug and blocking-DNS retry storm, cache hostname - #31
Merged
Merged
Conversation
…name - write()'s "#15" artifact filter used a prefix match (size>=4, first 4 bytes) while flushBuffer()'s equivalent check is an exact match (size==4). Any real log line longer than 4 bytes that happened to start with "#15" passed flushBuffer() untouched but was then silently dropped entirely by write() - losing real diagnostic content instead of just the intended artifact line. Made both checks consistent (exact match only). - resolveHostname() re-ran a blocking hostByName() DNS lookup on every single syslog flush whenever resolution hadn't yet succeeded, with no backoff. Since this runs on the hot path for the entire firmware's debug output (DEBUGOUT=Syslog), a misconfigured/unreachable syslog host meant every buffered log line paid the full blocking DNS timeout, risking main-loop stalls/watchdog resets under frequent logging. Added a 10s backoff between retry attempts (an immediate first attempt is still guaranteed via a separate "has attempted" flag, so this doesn't delay normal startup resolution). - write() re-allocated and cleaned a new String from serverDescription on every single packet send. Cached it (mirroring the existing syslogHostIP caching pattern) and only recompute when serverDescription changes. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01J6bJtispewBKR2dXBcNWpw
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up review of the
syslogfeature (wled00/syslog.cpp/syslog.h, after #3/#18/#22), looking for anything left. Found and fixed two real bugs plus one efficiency issue:flushBuffer()'s "skip pure#015artifact" filter is an exact match (_bufferIndex == 4), butwrite()'s equivalent check was a prefix match (size >= 4, only checking the first 4 bytes). Any genuine debug line longer than 4 bytes that happened to start with those same 4 characters passedflushBuffer()untouched (since it isn't exactly 4 bytes) but was then fully discarded bywrite(). Made both checks consistent (exact match only).resolveHostname()re-runs a blockinghostByName()call whenever resolution hasn't succeeded yet, and this sits on the hot path for the entire firmware's debug output (DEBUGOUT=Syslog). With a misconfigured or temporarily unreachable syslog host, every buffered log line paid the full blocking DNS timeout (up to 750ms on ESP8266, uncapped on ESP32/Ethernet) — risking main-loop stalls or watchdog resets under frequent debug logging. Added a 10-second backoff between retry attempts, with a separate "has attempted" flag so the very first resolution attempt at boot still happens immediately.write()allocated and cleaned a freshStringfromserverDescriptionon every single UDP packet, even though it only changes when the user edits it in settings. Cached it, mirroring the existingsyslogHostIPcaching pattern already used for the host.Test plan
WLED_DEBUGon and confirm no main-loop stalls; send a debug line starting with#015but longer than 4 bytes and confirm it now reaches the syslog server.🤖 Generated with Claude Code
https://claude.ai/code/session_01J6bJtispewBKR2dXBcNWpw
Generated by Claude Code