Repository navigation
Let a Logger report on a full queue, and close the client - #26
Merged
Merged
Conversation
Shared::log held logMutex while the logger ran, so a logger whose report() found the queue full locked that mutex a second time on the same thread and hung, on the reporting thread or the sending one. A logger calling close() hung in forgetLogger the same way, or aborted the program: the destructor could find close() returning at once while thread_ was still joinable. Shared now records which thread is running the logger. A message raised on that thread is dropped, and close() called from it waits for nothing: it detaches the thread under sharedMutex_ and abandons what is queued, leaving log() to clear the logger once it has returned. Closes #24 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On the reporting thread the sending thread is not always stuck, only possibly so; "cannot finish" overstated it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
Author
|
Self-review rubric (performed inline in a headless dispatch; not an independent review):
Findings:
Do-not-auto-merge paths: none touched (no workflow, Makefile, CMakeLists, curl argv, quoting, spawn code, This comment was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener). drafted by Claude on behalf of Daniel Stephenson |
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
A
Loggerthat calls back into the client no longer hangs or aborts the program.Shared::logholdslogMutexwhile the logger runs, so a call that reachedlogorforgetLoggeragain on the same thread locked astd::mutexthat thread already owned.report()from a Logger on a full queue: the message that report would raise is dropped without a mention, on either thread the Logger runs on.Sharednow records which thread is running the logger, under the existingmutex. A re-entrancy check is used instead of a recursive mutex, as the issue requires, and nostd::atomicis added, so the header cannot pick up a libatomic link requirement.close()from a Logger: it now waits for nothing, whatever bound it is given, because the sending thread may be running the logger or waiting its turn to, so the wait might never end. The thread is detached undersharedMutex_and what is queued is abandoned.log()clears the logger after it returns, since a runningstd::functioncannot be destroyed. Beyond the hang the issue predicted, the old path also aborted: the stashed run below ended interminate called without an active exception, consistent with the destructor findingthread_still joinable whileclose()was blocked inforgetLogger.Loggertypedef andclose()'s comment state both behaviors.The change is confined to
SharedandTraceClient::close, so all transports and platforms share it. The curl argv, config quoting, process-spawn code, wire format and version are unchanged.Closes #24
Deferred issues
TRACE_CLIENT_CURLignored on Windows whenSystem32\curl.exeexists): awaits the owner's decision, and touches thecurl.exelookup on the do-not-auto-merge list.Test plan
make clean && make test(g++, C++11):65 tests, 0 failed checks, up from 61make test STD=c++2a(g++):65 tests, 0 failed checksaLoggerMayReportWhileTheQueueIsFullandaLoggerMayFillTheQueueFromTheSendingThreadfailed after their 30 s bound, andaLoggerMayCloseFromTheSendingThreadfailed onreturnedand then aborted the run, soaLoggerMayCloseFromTheReportingThreadwas not reachedlog()'sif (forgotten) logger = Logger();disabled,aLoggerMayCloseFromTheReportingThreadfailed withexpected [1] got [2]Buildgreen on the PR head, including bothlinux-sanitizerslegs,macosandwindows: all 11 jobs printed65 tests, 0 failed checks, and no sanitizer report appears in the logsThe TSan runtime is not installed locally, and clang++ and
make test-libcurlwere not run locally; all three were covered by CI.This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).
🤖 Generated with Claude Code
drafted by Claude on behalf of Daniel Stephenson