diff options
author | David Robillard <d@drobilla.net> | 2010-11-26 00:59:54 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2010-11-26 00:59:54 +0000 |
commit | df81cce780f5844a6f904ec76330ec08fe8bc329 (patch) | |
tree | a05d38c532adef93f1e5c7658ff59cad63cad51d /src/engine | |
parent | d60f8a0fba5dfc10cafadf13a6debed8ba832f24 (diff) | |
download | ingen-df81cce780f5844a6f904ec76330ec08fe8bc329.tar.gz ingen-df81cce780f5844a6f904ec76330ec08fe8bc329.tar.bz2 ingen-df81cce780f5844a6f904ec76330ec08fe8bc329.zip |
Fix race crash processing event list (Raul::ListImpl seriously needs an audit and heavy testing...)
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2673 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/engine')
-rw-r--r-- | src/engine/EventSource.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/engine/EventSource.cpp b/src/engine/EventSource.cpp index 27397a8f..ebc12052 100644 --- a/src/engine/EventSource.cpp +++ b/src/engine/EventSource.cpp @@ -76,21 +76,27 @@ EventSource::process(PostProcessor& dest, ProcessContext& context, bool limit) size_t num_events_processed = 0; - QueuedEvent* ev = (QueuedEvent*)_events.front(); - Raul::List<Event*>::Node* new_head = _events.head(); + Raul::List<Event*>::Node* head = _events.head(); + Raul::List<Event*>::Node* tail = head; + + if (!head) + return; + + QueuedEvent* ev = (QueuedEvent*)head->elem(); while (ev && ev->is_prepared() && ev->time() < context.end()) { ev->execute(context); - new_head = new_head->next(); + tail = head; + head = head->next(); ++num_events_processed; if (limit && num_events_processed > MAX_QUEUED_EVENTS) break; - ev = (new_head ? (QueuedEvent*)new_head->elem() : NULL); + ev = (head ? (QueuedEvent*)head->elem() : NULL); } if (num_events_processed > 0) { Raul::List<Event*> front; - _events.chop_front(front, num_events_processed, new_head); + _events.chop_front(front, num_events_processed, tail); dest.append(&front); } } |