Files
leonarski_fandClaude Opus 5 c40e0eb11d broker: fix deadlock when re-initialising after a DECTRIS run that never started
A re-initialisation left the previous run's ZMQImagePuller connected: JFJochServices::On
replaces its own shared_ptr, but JFJochReceiverService keeps a second reference to the puller
of the last run. Two PULL sockets on one PUSH peer share messages round-robin, so the orphaned
puller silently took half of the DECTRIS stream - the start message included - and the receiver
then waited for a start message that had already been discarded.

Once such a run was cancelled, nothing drained the orphaned puller's outside_fifo any more. Its
CBOR thread parked in PutBlocking on the full queue (suspend is only tested before the put), the
puller thread backed up behind it in cbor_fifo, and neither could reach the disconnect flag
again. The next JFJochReceiverService::Start dropped the last reference to that puller, so
~ZMQImagePuller joined two threads that could never exit - while holding state_mutex, inside a
calibration sequence that itself holds the state machine's mutex. The whole control plane froze
with no way to cancel; only a restart got out of it.

* ThreadSafeFIFO gains Stop(), which releases every waiter and makes further blocking operations
  return at once. Clear() now notifies c_full as well: clearing a full queue used to leave the
  blocked producer asleep, since the next Get on an empty queue notifies no one.
* ZMQImagePuller::Disconnect and TCPImagePuller::Disconnect stop their queues before joining, so
  a puller whose consumer is gone can always shut down.
* JFJochServices::On and ::Off disconnect the previous puller explicitly rather than relying on
  the shared_ptr going away, so two readers never share the detector stream.

ZMQImagePuller_DisconnectWithFullQueue covers the shutdown; it hangs on the previous code.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012bew392LTGP2fkhfRJsMcB
2026-09-11 18:53:39 +02:00
..
2026-06-23 20:29:49 +02:00
2025-07-15 09:55:19 +02:00
2026-06-08 08:30:35 +02:00
2026-06-23 20:29:49 +02:00
2025-05-05 19:32:22 +02:00
2026-06-08 08:30:35 +02:00
2026-06-08 08:30:35 +02:00