summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/socketengine.h3
-rw-r--r--src/coremods/core_dns.cpp2
-rw-r--r--src/listensocket.cpp2
-rw-r--r--src/modules/m_ident.cpp2
-rw-r--r--src/modules/m_spanningtree/main.cpp6
-rw-r--r--src/modules/m_spanningtree/resolvers.cpp6
-rw-r--r--src/socket.cpp2
-rw-r--r--src/socketengine.cpp6
8 files changed, 10 insertions, 19 deletions
diff --git a/include/socketengine.h b/include/socketengine.h
index e54dfca97..2b759dad8 100644
--- a/include/socketengine.h
+++ b/include/socketengine.h
@@ -182,6 +182,9 @@ class CoreExport EventHandler : public classbase
*/
inline int GetFd() const { return fd; }
+ /** Checks if this event handler has a fd associated with it. */
+ inline bool HasFd() const { return fd >= 0; }
+
inline int GetEventMask() const { return event_mask; }
/** Set a new file desciptor
diff --git a/src/coremods/core_dns.cpp b/src/coremods/core_dns.cpp
index 5dcc994ce..326135465 100644
--- a/src/coremods/core_dns.cpp
+++ b/src/coremods/core_dns.cpp
@@ -703,7 +703,7 @@ class MyManager : public Manager, public Timer, public EventHandler
void Rehash(const std::string& dnsserver, std::string sourceaddr, unsigned int sourceport)
{
- if (this->GetFd() > -1)
+ if (this->HasFd())
{
SocketEngine::Shutdown(this, 2);
SocketEngine::Close(this);
diff --git a/src/listensocket.cpp b/src/listensocket.cpp
index 40639ba15..cb1c5c73f 100644
--- a/src/listensocket.cpp
+++ b/src/listensocket.cpp
@@ -130,7 +130,7 @@ ListenSocket::ListenSocket(ConfigTag* tag, const irc::sockets::sockaddrs& bind_t
ListenSocket::~ListenSocket()
{
- if (this->GetFd() > -1)
+ if (this->HasFd())
{
ServerInstance->Logs->Log("SOCKET", LOG_DEBUG, "Shut down listener on fd %d", this->fd);
SocketEngine::Shutdown(this, 2);
diff --git a/src/modules/m_ident.cpp b/src/modules/m_ident.cpp
index 5994caee5..dea411cea 100644
--- a/src/modules/m_ident.cpp
+++ b/src/modules/m_ident.cpp
@@ -187,7 +187,7 @@ class IdentRequestSocket : public EventHandler
/* Remove ident socket from engine, and close it, but dont detatch it
* from its parent user class, or attempt to delete its memory.
*/
- if (GetFd() > -1)
+ if (HasFd())
{
ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Close ident socket %d", GetFd());
SocketEngine::Close(this);
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp
index 1aab60eda..5e6e9b036 100644
--- a/src/modules/m_spanningtree/main.cpp
+++ b/src/modules/m_spanningtree/main.cpp
@@ -221,11 +221,7 @@ void ModuleSpanningTree::ConnectServer(Link* x, Autoconnect* y)
{
// Create a TreeServer object that will start connecting immediately in the background
TreeSocket* newsocket = new TreeSocket(x, y, sa);
- if (newsocket->GetFd() > -1)
- {
- /* Handled automatically on success */
- }
- else
+ if (!newsocket->HasFd())
{
ServerInstance->SNO->WriteToSnoMask('l', "CONNECT: Error connecting \002%s\002: %s.",
x->Name.c_str(), newsocket->getError().c_str());
diff --git a/src/modules/m_spanningtree/resolvers.cpp b/src/modules/m_spanningtree/resolvers.cpp
index f048283cf..14a96933d 100644
--- a/src/modules/m_spanningtree/resolvers.cpp
+++ b/src/modules/m_spanningtree/resolvers.cpp
@@ -71,11 +71,7 @@ void ServernameResolver::OnLookupComplete(const DNS::Query *r)
if (!CheckDupe) /* Check that nobody tried to connect it successfully while we were resolving */
{
TreeSocket* newsocket = new TreeSocket(MyLink, myautoconnect, sa);
- if (newsocket->GetFd() > -1)
- {
- /* We're all OK */
- }
- else
+ if (!newsocket->HasFd())
{
/* Something barfed, show the opers */
ServerInstance->SNO->WriteToSnoMask('l', "CONNECT: Error connecting \002%s\002: %s.",
diff --git a/src/socket.cpp b/src/socket.cpp
index e070b68c3..d2cc2af9a 100644
--- a/src/socket.cpp
+++ b/src/socket.cpp
@@ -47,7 +47,7 @@ bool InspIRCd::BindPort(ConfigTag* tag, const irc::sockets::sockaddrs& sa, std::
}
ListenSocket* ll = new ListenSocket(tag, sa);
- if (ll->GetFd() < 0)
+ if (!ll->HasFd())
{
ServerInstance->Logs->Log("SOCKET", LOG_DEFAULT, "Failed to listen on %s from tag at %s: %s",
sa.str().c_str(), tag->getTagLocation().c_str(), strerror(errno));
diff --git a/src/socketengine.cpp b/src/socketengine.cpp
index 61655732e..e1aef6439 100644
--- a/src/socketengine.cpp
+++ b/src/socketengine.cpp
@@ -180,11 +180,7 @@ EventHandler* SocketEngine::GetRef(int fd)
bool SocketEngine::BoundsCheckFd(EventHandler* eh)
{
- if (!eh)
- return false;
- if (eh->GetFd() < 0)
- return false;
- return true;
+ return eh && eh->HasFd();
}