aboutsummaryrefslogtreecommitdiffstats
path: root/src/output/HttpdClient.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-01-04 17:04:21 +0100
committerMax Kellermann <max@duempel.org>2014-01-04 17:06:05 +0100
commit968c5eb7675a5cf4f3a07820356ac5a0ae55d12f (patch)
tree457a024a04c74695113be7e8f03dcdf9ddcb67b7 /src/output/HttpdClient.cxx
parent19424e95dba6ae2b25733a48994f3781624c9c2e (diff)
downloadmpd-968c5eb7675a5cf4f3a07820356ac5a0ae55d12f.tar.gz
mpd-968c5eb7675a5cf4f3a07820356ac5a0ae55d12f.tar.xz
mpd-968c5eb7675a5cf4f3a07820356ac5a0ae55d12f.zip
output/httpd: keep track of queue size
Don't iterate the std::list each time.
Diffstat (limited to 'src/output/HttpdClient.cxx')
-rw-r--r--src/output/HttpdClient.cxx18
1 files changed, 6 insertions, 12 deletions
diff --git a/src/output/HttpdClient.cxx b/src/output/HttpdClient.cxx
index f7ddb74e1..8fae27855 100644
--- a/src/output/HttpdClient.cxx
+++ b/src/output/HttpdClient.cxx
@@ -197,6 +197,7 @@ HttpdClient::HttpdClient(HttpdOutput &_httpd, int _fd, EventLoop &_loop,
:BufferedSocket(_fd, _loop),
httpd(_httpd),
state(REQUEST),
+ queue_size(0),
head_method(false),
dlna_streaming_requested(false),
metadata_supported(_metadata_supported),
@@ -207,18 +208,6 @@ HttpdClient::HttpdClient(HttpdOutput &_httpd, int _fd, EventLoop &_loop,
{
}
-size_t
-HttpdClient::GetQueueSize() const
-{
- if (state != RESPONSE)
- return 0;
-
- size_t size = 0;
- for (auto page : pages)
- size += page->size;
- return size;
-}
-
void
HttpdClient::CancelQueue()
{
@@ -228,6 +217,7 @@ HttpdClient::CancelQueue()
for (auto page : pages)
page->Unref();
pages.clear();
+ queue_size = 0;
if (current_page == nullptr)
CancelWrite();
@@ -278,6 +268,9 @@ HttpdClient::TryWrite()
current_page = pages.front();
pages.pop_front();
current_position = 0;
+
+ assert(queue_size >= current_page->size);
+ queue_size -= current_page->size;
}
const ssize_t bytes_to_write = GetBytesTillMetaData();
@@ -380,6 +373,7 @@ HttpdClient::PushPage(Page *page)
page->Ref();
pages.push_back(page);
+ queue_size += page->size;
ScheduleWrite();
}