summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/server/EventSource.cpp6
-rw-r--r--src/server/PostProcessor.cpp32
2 files changed, 20 insertions, 18 deletions
diff --git a/src/server/EventSource.cpp b/src/server/EventSource.cpp
index cdecfd4a..ef982664 100644
--- a/src/server/EventSource.cpp
+++ b/src/server/EventSource.cpp
@@ -98,9 +98,11 @@ EventSource::process(PostProcessor& dest, ProcessContext& context, bool limit)
}
if (num_events_processed > 0) {
+ QueuedEvent* next = (QueuedEvent*)last->next();
+ last->next(NULL);
dest.append(_head.get(), last);
- _head = (QueuedEvent*)last->next();
- if (!last->next())
+ _head = next;
+ if (!next)
_tail = NULL;
}
}
diff --git a/src/server/PostProcessor.cpp b/src/server/PostProcessor.cpp
index 7c756812..2dd9666b 100644
--- a/src/server/PostProcessor.cpp
+++ b/src/server/PostProcessor.cpp
@@ -47,14 +47,14 @@ PostProcessor::append(QueuedEvent* first, QueuedEvent* last)
{
assert(first);
assert(last);
- QueuedEvent* const head = _head.get();
- QueuedEvent* const tail = _tail.get();
- if (!head) {
- _head = first;
+ assert(!last->next());
+ if (_head.get()) {
+ _tail.get()->next(first);
+ _tail = last;
} else {
- tail->next(first);
+ _tail = last;
+ _head = first;
}
- _tail = last;
}
void
@@ -88,19 +88,19 @@ PostProcessor::process()
/* Process normal events */
QueuedEvent* ev = _head.get();
- while (ev) {
- if (ev->time() > end_time)
- break;
-
+ if (!ev) {
+ return;
+ }
+
+ QueuedEvent* const tail = _tail.get();
+ _head = (QueuedEvent*)tail->next();
+ while (ev && ev->time() <= end_time) {
QueuedEvent* const next = (QueuedEvent*)ev->next();
ev->post_process();
- if (next) {
- _head = next;
- } else {
- _head = NULL;
- _tail = NULL;
- }
delete ev;
+ if (ev == tail) {
+ break;
+ }
ev = next;
}
}