output/httpd: add noexcept
This commit is contained in:
parent
53a4de35c4
commit
ab30695bd1
@ -31,27 +31,27 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
HttpdClient::~HttpdClient()
|
||||
HttpdClient::~HttpdClient() noexcept
|
||||
{
|
||||
if (IsDefined())
|
||||
BufferedSocket::Close();
|
||||
}
|
||||
|
||||
void
|
||||
HttpdClient::Close()
|
||||
HttpdClient::Close() noexcept
|
||||
{
|
||||
httpd.RemoveClient(*this);
|
||||
}
|
||||
|
||||
void
|
||||
HttpdClient::LockClose()
|
||||
HttpdClient::LockClose() noexcept
|
||||
{
|
||||
const std::lock_guard<Mutex> protect(httpd.mutex);
|
||||
Close();
|
||||
}
|
||||
|
||||
void
|
||||
HttpdClient::BeginResponse()
|
||||
HttpdClient::BeginResponse() noexcept
|
||||
{
|
||||
assert(state != State::RESPONSE);
|
||||
|
||||
@ -66,7 +66,7 @@ HttpdClient::BeginResponse()
|
||||
* Handle a line of the HTTP request.
|
||||
*/
|
||||
bool
|
||||
HttpdClient::HandleLine(const char *line)
|
||||
HttpdClient::HandleLine(const char *line) noexcept
|
||||
{
|
||||
assert(state != State::RESPONSE);
|
||||
|
||||
@ -121,7 +121,7 @@ HttpdClient::HandleLine(const char *line)
|
||||
* Sends the status line and response headers to the client.
|
||||
*/
|
||||
bool
|
||||
HttpdClient::SendResponse()
|
||||
HttpdClient::SendResponse() noexcept
|
||||
{
|
||||
char buffer[1024];
|
||||
AllocatedString<> allocated = nullptr;
|
||||
@ -171,7 +171,7 @@ HttpdClient::HttpdClient(HttpdOutput &_httpd, UniqueSocketDescriptor _fd,
|
||||
}
|
||||
|
||||
void
|
||||
HttpdClient::ClearQueue()
|
||||
HttpdClient::ClearQueue() noexcept
|
||||
{
|
||||
assert(state == State::RESPONSE);
|
||||
|
||||
@ -189,7 +189,7 @@ HttpdClient::ClearQueue()
|
||||
}
|
||||
|
||||
void
|
||||
HttpdClient::CancelQueue()
|
||||
HttpdClient::CancelQueue() noexcept
|
||||
{
|
||||
if (state != State::RESPONSE)
|
||||
return;
|
||||
@ -201,7 +201,7 @@ HttpdClient::CancelQueue()
|
||||
}
|
||||
|
||||
ssize_t
|
||||
HttpdClient::TryWritePage(const Page &page, size_t position)
|
||||
HttpdClient::TryWritePage(const Page &page, size_t position) noexcept
|
||||
{
|
||||
assert(position < page.GetSize());
|
||||
|
||||
@ -210,7 +210,8 @@ HttpdClient::TryWritePage(const Page &page, size_t position)
|
||||
}
|
||||
|
||||
ssize_t
|
||||
HttpdClient::TryWritePageN(const Page &page, size_t position, ssize_t n)
|
||||
HttpdClient::TryWritePageN(const Page &page,
|
||||
size_t position, ssize_t n) noexcept
|
||||
{
|
||||
return n >= 0
|
||||
? GetSocket().Write(page.GetData() + position, n)
|
||||
@ -228,7 +229,7 @@ HttpdClient::GetBytesTillMetaData() const noexcept
|
||||
}
|
||||
|
||||
inline bool
|
||||
HttpdClient::TryWrite()
|
||||
HttpdClient::TryWrite() noexcept
|
||||
{
|
||||
const std::lock_guard<Mutex> protect(httpd.mutex);
|
||||
|
||||
@ -342,7 +343,7 @@ HttpdClient::TryWrite()
|
||||
}
|
||||
|
||||
void
|
||||
HttpdClient::PushPage(PagePtr page)
|
||||
HttpdClient::PushPage(PagePtr page) noexcept
|
||||
{
|
||||
if (state != State::RESPONSE)
|
||||
/* the client is still writing the HTTP request */
|
||||
@ -361,7 +362,7 @@ HttpdClient::PushPage(PagePtr page)
|
||||
}
|
||||
|
||||
void
|
||||
HttpdClient::PushMetaData(PagePtr page)
|
||||
HttpdClient::PushMetaData(PagePtr page) noexcept
|
||||
{
|
||||
assert(page != nullptr);
|
||||
|
||||
|
@ -138,55 +138,56 @@ public:
|
||||
* Note: this does not remove the client from the
|
||||
* #HttpdOutput object.
|
||||
*/
|
||||
~HttpdClient();
|
||||
~HttpdClient() noexcept;
|
||||
|
||||
/**
|
||||
* Frees the client and removes it from the server's client list.
|
||||
*/
|
||||
void Close();
|
||||
void Close() noexcept;
|
||||
|
||||
void LockClose();
|
||||
void LockClose() noexcept;
|
||||
|
||||
/**
|
||||
* Clears the page queue.
|
||||
*/
|
||||
void CancelQueue();
|
||||
void CancelQueue() noexcept;
|
||||
|
||||
/**
|
||||
* Handle a line of the HTTP request.
|
||||
*/
|
||||
bool HandleLine(const char *line);
|
||||
bool HandleLine(const char *line) noexcept;
|
||||
|
||||
/**
|
||||
* Switch the client to #State::RESPONSE.
|
||||
*/
|
||||
void BeginResponse();
|
||||
void BeginResponse() noexcept;
|
||||
|
||||
/**
|
||||
* Sends the status line and response headers to the client.
|
||||
*/
|
||||
bool SendResponse();
|
||||
bool SendResponse() noexcept;
|
||||
|
||||
gcc_pure
|
||||
ssize_t GetBytesTillMetaData() const noexcept;
|
||||
|
||||
ssize_t TryWritePage(const Page &page, size_t position);
|
||||
ssize_t TryWritePageN(const Page &page, size_t position, ssize_t n);
|
||||
ssize_t TryWritePage(const Page &page, size_t position) noexcept;
|
||||
ssize_t TryWritePageN(const Page &page,
|
||||
size_t position, ssize_t n) noexcept;
|
||||
|
||||
bool TryWrite();
|
||||
bool TryWrite() noexcept;
|
||||
|
||||
/**
|
||||
* Appends a page to the client's queue.
|
||||
*/
|
||||
void PushPage(PagePtr page);
|
||||
void PushPage(PagePtr page) noexcept;
|
||||
|
||||
/**
|
||||
* Sends the passed metadata.
|
||||
*/
|
||||
void PushMetaData(PagePtr page);
|
||||
void PushMetaData(PagePtr page) noexcept;
|
||||
|
||||
private:
|
||||
void ClearQueue();
|
||||
void ClearQueue() noexcept;
|
||||
|
||||
protected:
|
||||
/* virtual methods from class SocketMonitor */
|
||||
|
@ -162,7 +162,7 @@ public:
|
||||
using ServerSocket::GetEventLoop;
|
||||
|
||||
void Bind();
|
||||
void Unbind();
|
||||
void Unbind() noexcept;
|
||||
|
||||
void Enable() override {
|
||||
Bind();
|
||||
@ -208,18 +208,18 @@ public:
|
||||
return HasClients();
|
||||
}
|
||||
|
||||
void AddClient(UniqueSocketDescriptor fd);
|
||||
void AddClient(UniqueSocketDescriptor fd) noexcept;
|
||||
|
||||
/**
|
||||
* Removes a client from the httpd_output.clients linked list.
|
||||
*/
|
||||
void RemoveClient(HttpdClient &client);
|
||||
void RemoveClient(HttpdClient &client) noexcept;
|
||||
|
||||
/**
|
||||
* Sends the encoder header to the client. This is called
|
||||
* right after the response headers have been sent.
|
||||
*/
|
||||
void SendHeader(HttpdClient &client) const;
|
||||
void SendHeader(HttpdClient &client) const noexcept;
|
||||
|
||||
gcc_pure
|
||||
std::chrono::steady_clock::duration Delay() const noexcept override;
|
||||
@ -235,7 +235,7 @@ public:
|
||||
*
|
||||
* Mutext must not be locked.
|
||||
*/
|
||||
void BroadcastPage(PagePtr page);
|
||||
void BroadcastPage(PagePtr page) noexcept;
|
||||
|
||||
/**
|
||||
* Broadcasts data from the encoder to all clients.
|
||||
@ -251,7 +251,7 @@ public:
|
||||
|
||||
size_t Play(const void *chunk, size_t size) override;
|
||||
|
||||
void CancelAllClients();
|
||||
void CancelAllClients() noexcept;
|
||||
|
||||
void Cancel() noexcept override;
|
||||
bool Pause() override;
|
||||
|
@ -77,7 +77,7 @@ HttpdOutput::Bind()
|
||||
}
|
||||
|
||||
inline void
|
||||
HttpdOutput::Unbind()
|
||||
HttpdOutput::Unbind() noexcept
|
||||
{
|
||||
assert(!open);
|
||||
|
||||
@ -91,7 +91,7 @@ HttpdOutput::Unbind()
|
||||
* HttpdOutput.clients linked list.
|
||||
*/
|
||||
inline void
|
||||
HttpdOutput::AddClient(UniqueSocketDescriptor fd)
|
||||
HttpdOutput::AddClient(UniqueSocketDescriptor fd) noexcept
|
||||
{
|
||||
auto *client = new HttpdClient(*this, std::move(fd), GetEventLoop(),
|
||||
!encoder->ImplementsTag());
|
||||
@ -223,7 +223,7 @@ HttpdOutput::Close() noexcept
|
||||
}
|
||||
|
||||
void
|
||||
HttpdOutput::RemoveClient(HttpdClient &client)
|
||||
HttpdOutput::RemoveClient(HttpdClient &client) noexcept
|
||||
{
|
||||
assert(!clients.empty());
|
||||
|
||||
@ -232,7 +232,7 @@ HttpdOutput::RemoveClient(HttpdClient &client)
|
||||
}
|
||||
|
||||
void
|
||||
HttpdOutput::SendHeader(HttpdClient &client) const
|
||||
HttpdOutput::SendHeader(HttpdClient &client) const noexcept
|
||||
{
|
||||
if (header != nullptr)
|
||||
client.PushPage(header);
|
||||
@ -260,7 +260,7 @@ HttpdOutput::Delay() const noexcept
|
||||
}
|
||||
|
||||
void
|
||||
HttpdOutput::BroadcastPage(PagePtr page)
|
||||
HttpdOutput::BroadcastPage(PagePtr page) noexcept
|
||||
{
|
||||
assert(page != nullptr);
|
||||
|
||||
@ -386,7 +386,7 @@ HttpdOutput::SendTag(const Tag &tag)
|
||||
}
|
||||
|
||||
inline void
|
||||
HttpdOutput::CancelAllClients()
|
||||
HttpdOutput::CancelAllClients() noexcept
|
||||
{
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user