Fixed two races.
The first is that the memory_region destructor would complain there is still an outstanding allocation. This is because circular_buffer from rust_chan wasn't refing its task, so the task was being destructed too soon. The second was where the program could deadlock while joining a task. The target task would die in the time between checking whether the task should block and then actually blocking. The fix is to use the target task's lock.
This commit is contained in:
@@ -20,6 +20,7 @@ circular_buffer::circular_buffer(rust_task *task, size_t unit_sz) :
|
||||
_buffer_sz, _unread, this);
|
||||
|
||||
A(sched, _buffer, "Failed to allocate buffer.");
|
||||
task->ref();
|
||||
}
|
||||
|
||||
circular_buffer::~circular_buffer() {
|
||||
@@ -28,6 +29,7 @@ circular_buffer::~circular_buffer() {
|
||||
W(sched, _unread == 0,
|
||||
"freeing circular_buffer with %d unread bytes", _unread);
|
||||
task->free(_buffer);
|
||||
--task->ref_count;
|
||||
}
|
||||
|
||||
size_t
|
||||
|
||||
Reference in New Issue
Block a user