aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-01-04 17:42:03 +0100
committerMax Kellermann <max@duempel.org>2014-01-04 17:42:03 +0100
commit68fcc195657fa31b47bc9504286a9b31feda92dc (patch)
tree223c2ef36aebe471b5600b52ed56ea567d007934 /src
parent8e4efd071e8eef033d0a68f6cf60f3910599a1a9 (diff)
downloadmpd-68fcc195657fa31b47bc9504286a9b31feda92dc.tar.gz
mpd-68fcc195657fa31b47bc9504286a9b31feda92dc.tar.xz
mpd-68fcc195657fa31b47bc9504286a9b31feda92dc.zip
output/httpd: move queue size check to HttpdClient::PushPage()
Don't let the server care for client problems.
Diffstat (limited to 'src')
-rw-r--r--src/output/HttpdClient.cxx6
-rw-r--r--src/output/HttpdClient.hxx8
-rw-r--r--src/output/HttpdOutputPlugin.cxx10
3 files changed, 6 insertions, 18 deletions
diff --git a/src/output/HttpdClient.cxx b/src/output/HttpdClient.cxx
index d16f78942..c0b2429d2 100644
--- a/src/output/HttpdClient.cxx
+++ b/src/output/HttpdClient.cxx
@@ -387,6 +387,12 @@ HttpdClient::PushPage(Page *page)
/* the client is still writing the HTTP request */
return;
+ if (queue_size > 256 * 1024) {
+ FormatDebug(httpd_output_domain,
+ "client is too slow, flushing its queue");
+ ClearQueue();
+ }
+
page->Ref();
pages.push(page);
queue_size += page->size;
diff --git a/src/output/HttpdClient.hxx b/src/output/HttpdClient.hxx
index 72a5224ca..94fe2ae62 100644
--- a/src/output/HttpdClient.hxx
+++ b/src/output/HttpdClient.hxx
@@ -143,14 +143,6 @@ public:
void LockClose();
/**
- * Returns the total size of this client's page queue.
- */
- gcc_pure
- size_t GetQueueSize() const {
- return queue_size;
- }
-
- /**
* Clears the page queue.
*/
void CancelQueue();
diff --git a/src/output/HttpdOutputPlugin.cxx b/src/output/HttpdOutputPlugin.cxx
index 63131533a..ea75cb87d 100644
--- a/src/output/HttpdOutputPlugin.cxx
+++ b/src/output/HttpdOutputPlugin.cxx
@@ -401,16 +401,6 @@ HttpdOutput::BroadcastPage(Page *page)
void
HttpdOutput::BroadcastFromEncoder()
{
- mutex.lock();
- for (auto &client : clients) {
- if (client.GetQueueSize() > 256 * 1024) {
- FormatDebug(httpd_output_domain,
- "client is too slow, flushing its queue");
- client.CancelQueue();
- }
- }
- mutex.unlock();
-
Page *page;
while ((page = ReadPage()) != nullptr) {
BroadcastPage(page);