aboutsummaryrefslogtreecommitdiffstats
path: root/src/output
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/output/HttpdClient.cxx19
-rw-r--r--src/output/HttpdClient.hxx3
2 files changed, 16 insertions, 6 deletions
diff --git a/src/output/HttpdClient.cxx b/src/output/HttpdClient.cxx
index 121f36e41..d16f78942 100644
--- a/src/output/HttpdClient.cxx
+++ b/src/output/HttpdClient.cxx
@@ -212,10 +212,19 @@ HttpdClient::ClearQueue()
{
assert(state == RESPONSE);
- for (auto page : pages)
+ while (!pages.empty()) {
+ Page *page = pages.front();
+ pages.pop();
+
+#ifndef NDEBUG
+ assert(queue_size >= page->size);
+ queue_size -= page->size;
+#endif
+
page->Unref();
- pages.clear();
- queue_size = 0;
+ }
+
+ assert(queue_size == 0);
}
void
@@ -273,7 +282,7 @@ HttpdClient::TryWrite()
}
current_page = pages.front();
- pages.pop_front();
+ pages.pop();
current_position = 0;
assert(queue_size >= current_page->size);
@@ -379,7 +388,7 @@ HttpdClient::PushPage(Page *page)
return;
page->Ref();
- pages.push_back(page);
+ pages.push(page);
queue_size += page->size;
ScheduleWrite();
diff --git a/src/output/HttpdClient.hxx b/src/output/HttpdClient.hxx
index 7b83bca33..72a5224ca 100644
--- a/src/output/HttpdClient.hxx
+++ b/src/output/HttpdClient.hxx
@@ -23,6 +23,7 @@
#include "event/BufferedSocket.hxx"
#include "Compiler.h"
+#include <queue>
#include <list>
#include <stddef.h>
@@ -53,7 +54,7 @@ class HttpdClient final : BufferedSocket {
/**
* A queue of #Page objects to be sent to the client.
*/
- std::list<Page *> pages;
+ std::queue<Page *, std::list<Page *>> pages;
/**
* The sum of all page sizes in #pages.