event/SocketMonitor: eliminate Read(), Write()
Migrate callers to GetSocket().Read(), GetSocket.Write(), which is the same.
This commit is contained in:
parent
7e16ac305d
commit
5fd2b7cc79
|
@ -27,7 +27,7 @@
|
|||
BufferedSocket::ssize_t
|
||||
BufferedSocket::DirectRead(void *data, size_t length)
|
||||
{
|
||||
const auto nbytes = SocketMonitor::Read((char *)data, length);
|
||||
const auto nbytes = GetSocket().Read((char *)data, length);
|
||||
if (gcc_likely(nbytes > 0))
|
||||
return nbytes;
|
||||
|
||||
|
|
|
@ -45,7 +45,6 @@ public:
|
|||
|
||||
using SocketMonitor::IsDefined;
|
||||
using SocketMonitor::Close;
|
||||
using SocketMonitor::Write;
|
||||
|
||||
private:
|
||||
ssize_t DirectRead(void *data, size_t length);
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
FullyBufferedSocket::ssize_t
|
||||
FullyBufferedSocket::DirectWrite(const void *data, size_t length)
|
||||
{
|
||||
const auto nbytes = SocketMonitor::Write((const char *)data, length);
|
||||
const auto nbytes = GetSocket().Write((const char *)data, length);
|
||||
if (gcc_unlikely(nbytes < 0)) {
|
||||
const auto code = GetSocketError();
|
||||
if (IsSocketErrorAgain(code))
|
||||
|
|
|
@ -95,32 +95,3 @@ SocketMonitor::Schedule(unsigned flags) noexcept
|
|||
|
||||
scheduled_flags = flags;
|
||||
}
|
||||
|
||||
SocketMonitor::ssize_t
|
||||
SocketMonitor::Read(void *data, size_t length) noexcept
|
||||
{
|
||||
assert(IsDefined());
|
||||
|
||||
int flags = 0;
|
||||
#ifdef MSG_DONTWAIT
|
||||
flags |= MSG_DONTWAIT;
|
||||
#endif
|
||||
|
||||
return recv(GetSocket().Get(), (char *)data, length, flags);
|
||||
}
|
||||
|
||||
SocketMonitor::ssize_t
|
||||
SocketMonitor::Write(const void *data, size_t length) noexcept
|
||||
{
|
||||
assert(IsDefined());
|
||||
|
||||
int flags = 0;
|
||||
#ifdef MSG_NOSIGNAL
|
||||
flags |= MSG_NOSIGNAL;
|
||||
#endif
|
||||
#ifdef MSG_DONTWAIT
|
||||
flags |= MSG_DONTWAIT;
|
||||
#endif
|
||||
|
||||
return send(GetSocket().Get(), (const char *)data, length, flags);
|
||||
}
|
||||
|
|
|
@ -126,9 +126,6 @@ public:
|
|||
Schedule(GetScheduledFlags() & ~WRITE);
|
||||
}
|
||||
|
||||
ssize_t Read(void *data, size_t length) noexcept;
|
||||
ssize_t Write(const void *data, size_t length) noexcept;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @return false if the socket has been closed
|
||||
|
|
|
@ -173,7 +173,7 @@ HttpdClient::SendResponse()
|
|||
response = buffer;
|
||||
}
|
||||
|
||||
ssize_t nbytes = SocketMonitor::Write(response, strlen(response));
|
||||
ssize_t nbytes = GetSocket().Write(response, strlen(response));
|
||||
if (gcc_unlikely(nbytes < 0)) {
|
||||
const SocketErrorMessage msg;
|
||||
FormatWarning(httpd_output_domain,
|
||||
|
@ -238,15 +238,15 @@ HttpdClient::TryWritePage(const Page &page, size_t position)
|
|||
{
|
||||
assert(position < page.GetSize());
|
||||
|
||||
return Write(page.GetData() + position,
|
||||
page.GetSize() - position);
|
||||
return GetSocket().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.GetData() + position, n)
|
||||
? GetSocket().Write(page.GetData() + position, n)
|
||||
: TryWritePage(page, position);
|
||||
}
|
||||
|
||||
|
@ -315,7 +315,7 @@ HttpdClient::TryWrite()
|
|||
} else {
|
||||
char empty_data = 0;
|
||||
|
||||
ssize_t nbytes = Write(&empty_data, 1);
|
||||
ssize_t nbytes = GetSocket().Write(&empty_data, 1);
|
||||
if (nbytes < 0) {
|
||||
auto e = GetSocketError();
|
||||
if (IsSocketErrorAgain(e))
|
||||
|
|
Loading…
Reference in New Issue