From 45e15b6cc625eea522525029d67853e5604a5d08 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 19 Feb 2017 19:49:28 +0100 Subject: [PATCH] output/httpd/Page: make all attributes private --- src/output/plugins/httpd/HttpdClient.cxx | 25 ++++++++++++------------ src/output/plugins/httpd/Page.hxx | 9 ++++++++- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/output/plugins/httpd/HttpdClient.cxx b/src/output/plugins/httpd/HttpdClient.cxx index 386944eb3..3e4fb1242 100644 --- a/src/output/plugins/httpd/HttpdClient.cxx +++ b/src/output/plugins/httpd/HttpdClient.cxx @@ -221,8 +221,8 @@ HttpdClient::ClearQueue() pages.pop(); #ifndef NDEBUG - assert(queue_size >= page->size); - queue_size -= page->size; + assert(queue_size >= page->GetSize()); + queue_size -= page->GetSize(); #endif page->Unref(); @@ -246,16 +246,17 @@ HttpdClient::CancelQueue() ssize_t HttpdClient::TryWritePage(const Page &page, size_t position) { - assert(position < page.size); + assert(position < page.GetSize()); - return Write(page.data + position, page.size - position); + return Write(page.GetData() + position, + page.GetSize() - position); } ssize_t HttpdClient::TryWritePageN(const Page &page, size_t position, ssize_t n) { return n >= 0 - ? Write(page.data + position, n) + ? Write(page.GetData() + position, n) : TryWritePage(page, position); } @@ -263,7 +264,7 @@ ssize_t HttpdClient::GetBytesTillMetaData() const { if (metadata_requested && - current_page->size - current_position > metaint - metadata_fill) + current_page->GetSize() - current_position > metaint - metadata_fill) return metaint - metadata_fill; return -1; @@ -289,8 +290,8 @@ HttpdClient::TryWrite() pages.pop(); current_position = 0; - assert(queue_size >= current_page->size); - queue_size -= current_page->size; + assert(queue_size >= current_page->GetSize()); + queue_size -= current_page->GetSize(); } const ssize_t bytes_to_write = GetBytesTillMetaData(); @@ -316,7 +317,7 @@ HttpdClient::TryWrite() metadata_current_position += nbytes; - if (metadata->size - metadata_current_position == 0) { + if (metadata->GetSize() - metadata_current_position == 0) { metadata_fill = 0; metadata_current_position = 0; metadata_sent = true; @@ -365,12 +366,12 @@ HttpdClient::TryWrite() } current_position += nbytes; - assert(current_position <= current_page->size); + assert(current_position <= current_page->GetSize()); if (metadata_requested) metadata_fill += nbytes; - if (current_position >= current_page->size) { + if (current_position >= current_page->GetSize()) { current_page->Unref(); current_page = nullptr; @@ -399,7 +400,7 @@ HttpdClient::PushPage(Page *page) page->Ref(); pages.push(page); - queue_size += page->size; + queue_size += page->GetSize(); ScheduleWrite(); } diff --git a/src/output/plugins/httpd/Page.hxx b/src/output/plugins/httpd/Page.hxx index edeca2327..8cbcb9971 100644 --- a/src/output/plugins/httpd/Page.hxx +++ b/src/output/plugins/httpd/Page.hxx @@ -44,7 +44,6 @@ class Page { */ RefCount ref; -public: /** * The size of this buffer in bytes. */ @@ -90,6 +89,14 @@ public: * @return true if the #page has been freed */ bool Unref(); + + size_t GetSize() const { + return size; + } + + const uint8_t *GetData() const { + return data; + } }; #endif