event/SocketMonitor: rename Get() to GetSocket()

This commit is contained in:
Max Kellermann 2017-11-10 20:34:45 +01:00
parent 59a8836924
commit 7e16ac305d
7 changed files with 12 additions and 12 deletions

View File

@ -38,7 +38,7 @@ InotifySource::OnSocketReady(gcc_unused unsigned flags) noexcept
static_assert(sizeof(buffer) >= sizeof(struct inotify_event) + NAME_MAX + 1, static_assert(sizeof(buffer) >= sizeof(struct inotify_event) + NAME_MAX + 1,
"inotify buffer too small"); "inotify buffer too small");
auto ifd = Get().ToFileDescriptor(); auto ifd = GetSocket().ToFileDescriptor();
ssize_t nbytes = ifd.Read(buffer, sizeof(buffer)); ssize_t nbytes = ifd.Read(buffer, sizeof(buffer));
if (nbytes < 0) if (nbytes < 0)
FatalSystemError("Failed to read from inotify"); FatalSystemError("Failed to read from inotify");
@ -90,7 +90,7 @@ InotifySource::InotifySource(EventLoop &_loop,
int int
InotifySource::Add(const char *path_fs, unsigned mask) InotifySource::Add(const char *path_fs, unsigned mask)
{ {
auto ifd = Get().ToFileDescriptor(); auto ifd = GetSocket().ToFileDescriptor();
int wd = inotify_add_watch(ifd.Get(), path_fs, mask); int wd = inotify_add_watch(ifd.Get(), path_fs, mask);
if (wd < 0) if (wd < 0)
throw MakeErrno("inotify_add_watch() has failed"); throw MakeErrno("inotify_add_watch() has failed");
@ -101,7 +101,7 @@ InotifySource::Add(const char *path_fs, unsigned mask)
void void
InotifySource::Remove(unsigned wd) InotifySource::Remove(unsigned wd)
{ {
auto ifd = Get().ToFileDescriptor(); auto ifd = GetSocket().ToFileDescriptor();
int ret = inotify_rm_watch(ifd.Get(), wd); int ret = inotify_rm_watch(ifd.Get(), wd);
if (ret < 0 && errno != EINVAL) if (ret < 0 && errno != EINVAL)
LogErrno(inotify_domain, "inotify_rm_watch() has failed"); LogErrno(inotify_domain, "inotify_rm_watch() has failed");

View File

@ -58,8 +58,8 @@ class MultiSocketMonitor : IdleMonitor
Schedule(events); Schedule(events);
} }
SocketDescriptor GetFD() const { SocketDescriptor GetSocket() const {
return SocketMonitor::Get(); return SocketMonitor::GetSocket();
} }
unsigned GetEvents() const { unsigned GetEvents() const {
@ -174,7 +174,7 @@ public:
i != end; i = std::next(prev)) { i != end; i = std::next(prev)) {
assert(i->GetEvents() != 0); assert(i->GetEvents() != 0);
unsigned events = e(i->GetFD()); unsigned events = e(i->GetSocket());
if (events != 0) { if (events != 0) {
i->SetEvents(events); i->SetEvents(events);
prev = i; prev = i;

View File

@ -149,7 +149,7 @@ inline void
OneServerSocket::Accept() noexcept OneServerSocket::Accept() noexcept
{ {
StaticSocketAddress peer_address; StaticSocketAddress peer_address;
UniqueSocketDescriptor peer_fd(Get().AcceptNonBlock(peer_address)); UniqueSocketDescriptor peer_fd(GetSocket().AcceptNonBlock(peer_address));
if (!peer_fd.IsDefined()) { if (!peer_fd.IsDefined()) {
const SocketErrorMessage msg; const SocketErrorMessage msg;
FormatError(server_socket_domain, FormatError(server_socket_domain,

View File

@ -106,7 +106,7 @@ SocketMonitor::Read(void *data, size_t length) noexcept
flags |= MSG_DONTWAIT; flags |= MSG_DONTWAIT;
#endif #endif
return recv(Get().Get(), (char *)data, length, flags); return recv(GetSocket().Get(), (char *)data, length, flags);
} }
SocketMonitor::ssize_t SocketMonitor::ssize_t
@ -122,5 +122,5 @@ SocketMonitor::Write(const void *data, size_t length) noexcept
flags |= MSG_DONTWAIT; flags |= MSG_DONTWAIT;
#endif #endif
return send(Get().Get(), (const char *)data, length, flags); return send(GetSocket().Get(), (const char *)data, length, flags);
} }

View File

@ -77,7 +77,7 @@ public:
return fd.IsDefined(); return fd.IsDefined();
} }
SocketDescriptor Get() const noexcept { SocketDescriptor GetSocket() const noexcept {
assert(IsDefined()); assert(IsDefined());
return fd; return fd;

View File

@ -149,7 +149,7 @@ CurlSocket::OnSocketReady(unsigned flags) noexcept
{ {
assert(GetEventLoop().IsInside()); assert(GetEventLoop().IsInside());
global.SocketAction(Get().Get(), FlagsToCurlCSelect(flags)); global.SocketAction(GetSocket().Get(), FlagsToCurlCSelect(flags));
return true; return true;
} }

View File

@ -73,7 +73,7 @@ private:
/* virtual methods from class SocketMonitor */ /* virtual methods from class SocketMonitor */
bool OnSocketReady(unsigned flags) noexcept { bool OnSocketReady(unsigned flags) noexcept {
received = ToAvahiWatchEvent(flags); received = ToAvahiWatchEvent(flags);
callback(this, Get().Get(), received, userdata); callback(this, GetSocket().Get(), received, userdata);
received = AvahiWatchEvent(0); received = AvahiWatchEvent(0);
return true; return true;
} }