aboutsummaryrefslogtreecommitdiffstats
path: root/src/output/plugins/httpd/HttpdOutputPlugin.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2015-10-19 15:18:47 +0200
committerMax Kellermann <max@duempel.org>2015-10-19 16:00:26 +0200
commit6bea346c4110f14288726766449bd5c843f8bae5 (patch)
tree187ecc417812916a99bdea732f530ca8bd710e36 /src/output/plugins/httpd/HttpdOutputPlugin.cxx
parent8d2370635408b9acd392843de96179383a95a4bf (diff)
downloadmpd-6bea346c4110f14288726766449bd5c843f8bae5.tar.gz
mpd-6bea346c4110f14288726766449bd5c843f8bae5.tar.xz
mpd-6bea346c4110f14288726766449bd5c843f8bae5.zip
output/httpd: use boost::intrusive::list instead of std::forward_list
Diffstat (limited to 'src/output/plugins/httpd/HttpdOutputPlugin.cxx')
-rw-r--r--src/output/plugins/httpd/HttpdOutputPlugin.cxx25
1 files changed, 9 insertions, 16 deletions
diff --git a/src/output/plugins/httpd/HttpdOutputPlugin.cxx b/src/output/plugins/httpd/HttpdOutputPlugin.cxx
index d13f646f3..765a72d92 100644
--- a/src/output/plugins/httpd/HttpdOutputPlugin.cxx
+++ b/src/output/plugins/httpd/HttpdOutputPlugin.cxx
@@ -34,6 +34,7 @@
#include "event/Call.hxx"
#include "util/Error.hxx"
#include "util/Domain.hxx"
+#include "util/DeleteDisposer.hxx"
#include "Log.hxx"
#include <assert.h>
@@ -169,9 +170,9 @@ httpd_output_finish(AudioOutput *ao)
inline void
HttpdOutput::AddClient(int fd)
{
- clients.emplace_front(*this, fd, GetEventLoop(),
- encoder->plugin.tag == nullptr);
- ++clients_cnt;
+ auto *client = new HttpdClient(*this, fd, GetEventLoop(),
+ encoder->plugin.tag == nullptr);
+ clients.push_front(*client);
/* pass metadata to client */
if (metadata != nullptr)
@@ -235,7 +236,7 @@ HttpdOutput::OnAccept(int fd, SocketAddress address, gcc_unused int uid)
if (fd >= 0) {
/* can we allow additional client */
- if (open && (clients_max == 0 || clients_cnt < clients_max))
+ if (open && (clients_max == 0 || clients.size() < clients_max))
AddClient(fd);
else
close_socket(fd);
@@ -319,7 +320,6 @@ HttpdOutput::Open(AudioFormat &audio_format, Error &error)
/* initialize other attributes */
- clients_cnt = 0;
timer = new Timer(audio_format);
open = true;
@@ -347,7 +347,7 @@ HttpdOutput::Close()
delete timer;
BlockingCall(GetEventLoop(), [this](){
- clients.clear();
+ clients.clear_and_dispose(DeleteDisposer());
});
if (header != nullptr)
@@ -368,17 +368,10 @@ httpd_output_close(AudioOutput *ao)
void
HttpdOutput::RemoveClient(HttpdClient &client)
{
- assert(clients_cnt > 0);
+ assert(!clients.empty());
- for (auto prev = clients.before_begin(), i = std::next(prev);;
- prev = i, i = std::next(prev)) {
- assert(i != clients.end());
- if (&*i == &client) {
- clients.erase_after(prev);
- clients_cnt--;
- break;
- }
- }
+ clients.erase_and_dispose(clients.iterator_to(client),
+ DeleteDisposer());
}
void