Repository navigation
Conversation
Flushing a bounded queue interrupts its overflow strategy, causing blocked producers to return without enqueuing their records. Separate dequeue wakeup from producer cancellation for built-in bounded queues. Use a distinct optional flush hook with a no-argument fallback so existing custom interruption overloads retain their semantics. Preserve cancellation for stop, and cover delivery and compatibility with separate regression executables guarded by process deadlines.
838c40b to
673f5fe
Compare
|
I think, I'd prefer a different approach:
Re. tests, it would be better if this could be tested without mocking the queueing strategies. I think, you can just write a test sink backend that will block on a condition variable or something on receiving a log record, until you signal it after invoking In general, I prefer when tests use the exact components that are provided by the library through their public interfaces rather their mocked variants because it is easier to understand what is being tested and avoid testing or depending on implementation details. This also pertains to your other PRs. |
| namespace logging = boost::log; | ||
| namespace sinks = boost::log::sinks; |
There was a problem hiding this comment.
Namespace aliases should be avoided in headers, these tend to create issues like this. Just use full namespace qualification in headers.
|
Thank you for the PR, I've merged my version of the fix. |
Flushing an asynchronous sink can silently discard records from producers waiting for queue space. This affects both
bounded_fifo_queueandbounded_ordering_queuewhen used withblock_on_overflow.flush()uses the same queue wake-up operation asstop(). For bounded queues, that operation also cancels producers blocked by the overflow policy. Theirconsume()calls then return without enqueueing their records.Separate waking the consumer from cancelling blocked producers. Flushing the built-in bounded queues now wakes only the consumer, allowing blocked producers to enqueue their records as space becomes available.
stop()retains its existing cancellation behavior.The bounded policies expose a separate
interrupt_dequeue_for_flush()hook. Other custom queue strategies continue through their existing no-argument interruption call unless they provide the new hook. Using a distinct name preserves existing overloads such asinterrupt_dequeue(bool wake = true)without assigning a new meaning to their arguments.Separate FIFO and ordering regression executables each pause the backend on a first record, fill a one-slot queue with a second record, and block a third producer for queue space. They then start a flush and release the backend. Before the fix, all three producer calls return but only two records reach the backend. With the fix, all three records are delivered.
A third executable checks that a legacy custom queue with a defaulted boolean interruption argument keeps its original wake behavior. All three tests have ten-second process watchdogs and pass on macOS with C++11.