-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modifying a stream while running can deadlock #40
Comments
This partially addresses #40, specifically for set_max_heaps and set_memory_pool. This is achieved by making these operations atomic (in the latter case, using a mutex) rather than serialising via the strand. However, making multiple calls to emplace_reader can still potentially deadlock if the first reader spams the ringbuffer before the last reader is added. Fixing this properly will probably require major architectural changes, because asio has no way to "drop" the strand during blocking operations. It probably requires the strand to be abandoned in favour of fine-grained locking, which may allow for other performance benefits e.g. using multiple threads to benefit from RSS.
Some of these issues have been dealt with by locking, but it can still happen in |
run_in_strand lead to issues like #40. The new queue_mutex can still be a source of similar deadlocks, but heap_ready no longer blocks emplace_reader, because that uses a separate reader_mutex. It is still possible for deadlocks to occur when sharing a thread pool between multiple streams with fewer threads than streams: if it has one thread, it could be blocked waiting for space in ringbuffer A, which can prevent a stop on B from making progress. Fixing that would require addressing #30.
|
The blocking push into the ringbuffer is done with the strand held. If the receiver tries to modify the stream (e.g., to set a memory pool, based on descriptor data) then it can block waiting on the strand, and the ringbuffer will never be emptied. This causes a deadlock.
The text was updated successfully, but these errors were encountered: