summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/socketengine.h22
-rw-r--r--src/commands/cmd_dns.cpp14
-rw-r--r--src/configreader.cpp2
-rw-r--r--src/inspsocket.cpp10
-rw-r--r--src/listensocket.cpp26
-rw-r--r--src/modules/m_ident.cpp8
-rw-r--r--src/socket.cpp6
-rw-r--r--src/threadengines/threadengine_pthread.cpp6
-rw-r--r--src/threadengines/threadengine_win32.cpp6
9 files changed, 50 insertions, 50 deletions
diff --git a/include/socketengine.h b/include/socketengine.h
index 072ed9bde..b57113af0 100644
--- a/include/socketengine.h
+++ b/include/socketengine.h
@@ -376,21 +376,21 @@ public:
* @param addrlen The size of the sockaddr parameter.
* @return This method should return exactly the same values as the system call it emulates.
*/
- int Accept(EventHandler* fd, sockaddr *addr, socklen_t *addrlen);
+ static int Accept(EventHandler* fd, sockaddr *addr, socklen_t *addrlen);
/** Abstraction for BSD sockets close(2).
* This function should emulate its namesake system call exactly.
* @param fd This version of the call takes an EventHandler instead of a bare file descriptor.
* @return This method should return exactly the same values as the system call it emulates.
*/
- int Close(EventHandler* fd);
+ static int Close(EventHandler* fd);
/** Abstraction for BSD sockets close(2).
* This function should emulate its namesake system call exactly.
* This function should emulate its namesake system call exactly.
* @return This method should return exactly the same values as the system call it emulates.
*/
- int Close(int fd);
+ static int Close(int fd);
/** Abstraction for BSD sockets send(2).
* This function should emulate its namesake system call exactly.
@@ -443,19 +443,19 @@ public:
* @param addrlen The size of the sockaddr parameter.
* @return This method should return exactly the same values as the system call it emulates.
*/
- int Connect(EventHandler* fd, const sockaddr *serv_addr, socklen_t addrlen);
+ static int Connect(EventHandler* fd, const sockaddr *serv_addr, socklen_t addrlen);
/** Make a file descriptor blocking.
* @param fd a file descriptor to set to blocking mode
* @return 0 on success, -1 on failure, errno is set appropriately.
*/
- int Blocking(int fd);
+ static int Blocking(int fd);
/** Make a file descriptor nonblocking.
* @param fd A file descriptor to set to nonblocking mode
* @return 0 on success, -1 on failure, errno is set appropriately.
*/
- int NonBlocking(int fd);
+ static int NonBlocking(int fd);
/** Abstraction for BSD sockets shutdown(2).
* This function should emulate its namesake system call exactly.
@@ -463,29 +463,29 @@ public:
* @param how What part of the socket to shut down
* @return This method should return exactly the same values as the system call it emulates.
*/
- int Shutdown(EventHandler* fd, int how);
+ static int Shutdown(EventHandler* fd, int how);
/** Abstraction for BSD sockets shutdown(2).
* This function should emulate its namesake system call exactly.
* @return This method should return exactly the same values as the system call it emulates.
*/
- int Shutdown(int fd, int how);
+ static int Shutdown(int fd, int how);
/** Abstraction for BSD sockets bind(2).
* This function should emulate its namesake system call exactly.
* @return This method should return exactly the same values as the system call it emulates.
*/
- int Bind(int fd, const irc::sockets::sockaddrs& addr);
+ static int Bind(int fd, const irc::sockets::sockaddrs& addr);
/** Abstraction for BSD sockets listen(2).
* This function should emulate its namesake system call exactly.
* @return This method should return exactly the same values as the system call it emulates.
*/
- int Listen(int sockfd, int backlog);
+ static int Listen(int sockfd, int backlog);
/** Set SO_REUSEADDR and SO_LINGER on this file descriptor
*/
- void SetReuse(int sockfd);
+ static void SetReuse(int sockfd);
/** This function is called immediately after fork().
* Some socket engines (notably kqueue) cannot have their
diff --git a/src/commands/cmd_dns.cpp b/src/commands/cmd_dns.cpp
index 07ade381a..4af8b2c9e 100644
--- a/src/commands/cmd_dns.cpp
+++ b/src/commands/cmd_dns.cpp
@@ -682,8 +682,8 @@ class MyManager : public Manager, public Timer, public EventHandler
if (this->GetFd() > -1)
{
ServerInstance->SE->DelFd(this);
- ServerInstance->SE->Shutdown(this, 2);
- ServerInstance->SE->Close(this);
+ SocketEngine::Shutdown(this, 2);
+ SocketEngine::Close(this);
this->SetFd(-1);
/* Remove expired entries from the cache */
@@ -699,24 +699,24 @@ class MyManager : public Manager, public Timer, public EventHandler
/* Have we got a socket? */
if (this->GetFd() != -1)
{
- ServerInstance->SE->SetReuse(s);
- ServerInstance->SE->NonBlocking(s);
+ SocketEngine::SetReuse(s);
+ SocketEngine::NonBlocking(s);
irc::sockets::sockaddrs bindto;
memset(&bindto, 0, sizeof(bindto));
bindto.sa.sa_family = myserver.sa.sa_family;
- if (ServerInstance->SE->Bind(this->GetFd(), bindto) < 0)
+ if (SocketEngine::Bind(this->GetFd(), bindto) < 0)
{
/* Failed to bind */
ServerInstance->Logs->Log("RESOLVER", LOG_SPARSE, "Resolver: Error binding dns socket - hostnames will NOT resolve");
- ServerInstance->SE->Close(this);
+ SocketEngine::Close(this);
this->SetFd(-1);
}
else if (!ServerInstance->SE->AddFd(this, FD_WANT_POLL_READ | FD_WANT_NO_WRITE))
{
ServerInstance->Logs->Log("RESOLVER", LOG_SPARSE, "Resolver: Internal error starting DNS - hostnames will NOT resolve.");
- ServerInstance->SE->Close(this);
+ SocketEngine::Close(this);
this->SetFd(-1);
}
}
diff --git a/src/configreader.cpp b/src/configreader.cpp
index 0f6d414dd..59a9f0d97 100644
--- a/src/configreader.cpp
+++ b/src/configreader.cpp
@@ -443,7 +443,7 @@ void ServerConfig::Fill()
if (socktest < 0)
WildcardIPv6 = false;
else
- ServerInstance->SE->Close(socktest);
+ SocketEngine::Close(socktest);
}
ReadXLine(this, "badip", "ipmask", ServerInstance->XLines->GetFactory("Z"));
diff --git a/src/inspsocket.cpp b/src/inspsocket.cpp
index 46f5bd3b2..f27e21ad8 100644
--- a/src/inspsocket.cpp
+++ b/src/inspsocket.cpp
@@ -93,13 +93,13 @@ BufferedSocketError BufferedSocket::BeginConnect(const irc::sockets::sockaddrs&
if (bind.sa.sa_family != 0)
{
- if (ServerInstance->SE->Bind(fd, bind) < 0)
+ if (SocketEngine::Bind(fd, bind) < 0)
return I_ERR_BIND;
}
- ServerInstance->SE->NonBlocking(fd);
+ SocketEngine::NonBlocking(fd);
- if (ServerInstance->SE->Connect(this, &dest.sa, dest.sa_size()) == -1)
+ if (SocketEngine::Connect(this, &dest.sa, dest.sa_size()) == -1)
{
if (errno != EINPROGRESS)
return I_ERR_CONNECT;
@@ -137,9 +137,9 @@ void StreamSocket::Close()
delete iohook;
DelIOHook();
}
- ServerInstance->SE->Shutdown(this, 2);
+ SocketEngine::Shutdown(this, 2);
ServerInstance->SE->DelFd(this);
- ServerInstance->SE->Close(this);
+ SocketEngine::Close(this);
fd = -1;
}
}
diff --git a/src/listensocket.cpp b/src/listensocket.cpp
index 01bc36cc5..565b6b6d8 100644
--- a/src/listensocket.cpp
+++ b/src/listensocket.cpp
@@ -56,10 +56,10 @@ ListenSocket::ListenSocket(ConfigTag* tag, const irc::sockets::sockaddrs& bind_t
}
#endif
- ServerInstance->SE->SetReuse(fd);
- int rv = ServerInstance->SE->Bind(this->fd, bind_to);
+ SocketEngine::SetReuse(fd);
+ int rv = SocketEngine::Bind(this->fd, bind_to);
if (rv >= 0)
- rv = ServerInstance->SE->Listen(this->fd, ServerInstance->Config->MaxConn);
+ rv = SocketEngine::Listen(this->fd, ServerInstance->Config->MaxConn);
int timeout = tag->getInt("defer", 0);
if (timeout && !rv)
@@ -77,14 +77,14 @@ ListenSocket::ListenSocket(ConfigTag* tag, const irc::sockets::sockaddrs& bind_t
if (rv < 0)
{
int errstore = errno;
- ServerInstance->SE->Shutdown(this, 2);
- ServerInstance->SE->Close(this);
+ SocketEngine::Shutdown(this, 2);
+ SocketEngine::Close(this);
this->fd = -1;
errno = errstore;
}
else
{
- ServerInstance->SE->NonBlocking(this->fd);
+ SocketEngine::NonBlocking(this->fd);
ServerInstance->SE->AddFd(this, FD_WANT_POLL_READ | FD_WANT_NO_WRITE);
this->ResetIOHookProvider();
@@ -97,8 +97,8 @@ ListenSocket::~ListenSocket()
{
ServerInstance->SE->DelFd(this);
ServerInstance->Logs->Log("SOCKET", LOG_DEBUG, "Shut down listener on fd %d", this->fd);
- ServerInstance->SE->Shutdown(this, 2);
- if (ServerInstance->SE->Close(this) != 0)
+ SocketEngine::Shutdown(this, 2);
+ if (SocketEngine::Close(this) != 0)
ServerInstance->Logs->Log("SOCKET", LOG_DEBUG, "Failed to cancel listener: %s", strerror(errno));
this->fd = -1;
}
@@ -111,7 +111,7 @@ void ListenSocket::AcceptInternal()
irc::sockets::sockaddrs server;
socklen_t length = sizeof(client);
- int incomingSockfd = ServerInstance->SE->Accept(this, &client.sa, &length);
+ int incomingSockfd = SocketEngine::Accept(this, &client.sa, &length);
ServerInstance->Logs->Log("SOCKET", LOG_DEBUG, "HandleEvent for Listensocket %s nfd=%d", bind_desc.c_str(), incomingSockfd);
if (incomingSockfd < 0)
@@ -140,8 +140,8 @@ void ListenSocket::AcceptInternal()
if (incomingSockfd >= ServerInstance->SE->GetMaxFds())
{
ServerInstance->Logs->Log("SOCKET", LOG_DEBUG, "Server is full");
- ServerInstance->SE->Shutdown(incomingSockfd, 2);
- ServerInstance->SE->Close(incomingSockfd);
+ SocketEngine::Shutdown(incomingSockfd, 2);
+ SocketEngine::Close(incomingSockfd);
ServerInstance->stats->statsRefused++;
return;
}
@@ -176,7 +176,7 @@ void ListenSocket::AcceptInternal()
}
}
- ServerInstance->SE->NonBlocking(incomingSockfd);
+ SocketEngine::NonBlocking(incomingSockfd);
ModResult res;
FIRST_MOD_RESULT(OnAcceptConnection, res, (incomingSockfd, this, &client, &server));
@@ -198,7 +198,7 @@ void ListenSocket::AcceptInternal()
ServerInstance->stats->statsRefused++;
ServerInstance->Logs->Log("SOCKET", LOG_DEFAULT, "Refusing connection on %s - %s",
bind_desc.c_str(), res == MOD_RES_DENY ? "Connection refused by module" : "Module for this port not found");
- ServerInstance->SE->Close(incomingSockfd);
+ SocketEngine::Close(incomingSockfd);
}
}
diff --git a/src/modules/m_ident.cpp b/src/modules/m_ident.cpp
index 1f57fc3e1..1f36c84fb 100644
--- a/src/modules/m_ident.cpp
+++ b/src/modules/m_ident.cpp
@@ -117,16 +117,16 @@ class IdentRequestSocket : public EventHandler
}
/* Attempt to bind (ident requests must come from the ip the query is referring to */
- if (ServerInstance->SE->Bind(GetFd(), bindaddr) < 0)
+ if (SocketEngine::Bind(GetFd(), bindaddr) < 0)
{
this->Close();
throw ModuleException("failed to bind()");
}
- ServerInstance->SE->NonBlocking(GetFd());
+ SocketEngine::NonBlocking(GetFd());
/* Attempt connection (nonblocking) */
- if (ServerInstance->SE->Connect(this, &connaddr.sa, connaddr.sa_size()) == -1 && errno != EINPROGRESS)
+ if (SocketEngine::Connect(this, &connaddr.sa, connaddr.sa_size()) == -1 && errno != EINPROGRESS)
{
this->Close();
throw ModuleException("connect() failed");
@@ -196,7 +196,7 @@ class IdentRequestSocket : public EventHandler
{
ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Close ident socket %d", GetFd());
ServerInstance->SE->DelFd(this);
- ServerInstance->SE->Close(GetFd());
+ SocketEngine::Close(GetFd());
this->SetFd(-1);
}
}
diff --git a/src/socket.cpp b/src/socket.cpp
index cade49353..ba35d2b0a 100644
--- a/src/socket.cpp
+++ b/src/socket.cpp
@@ -46,7 +46,7 @@ bool InspIRCd::BindSocket(int sockfd, int port, const char* addr, bool dolisten)
else if (!irc::sockets::aptosa(addr, port, servaddr))
return false;
- ret = SE->Bind(sockfd, servaddr);
+ ret = SocketEngine::Bind(sockfd, servaddr);
if (ret < 0)
{
@@ -56,7 +56,7 @@ bool InspIRCd::BindSocket(int sockfd, int port, const char* addr, bool dolisten)
{
if (dolisten)
{
- if (SE->Listen(sockfd, Config->MaxConn) == -1)
+ if (SocketEngine::Listen(sockfd, Config->MaxConn) == -1)
{
this->Logs->Log("SOCKET", LOG_DEFAULT, "ERROR in listen(): %s",strerror(errno));
return false;
@@ -64,7 +64,7 @@ bool InspIRCd::BindSocket(int sockfd, int port, const char* addr, bool dolisten)
else
{
this->Logs->Log("SOCKET", LOG_DEBUG, "New socket binding for %d with listen: %s:%d", sockfd, addr, port);
- SE->NonBlocking(sockfd);
+ SocketEngine::NonBlocking(sockfd);
return true;
}
}
diff --git a/src/threadengines/threadengine_pthread.cpp b/src/threadengines/threadengine_pthread.cpp
index e16e401f3..ebd11d487 100644
--- a/src/threadengines/threadengine_pthread.cpp
+++ b/src/threadengines/threadengine_pthread.cpp
@@ -81,7 +81,7 @@ class ThreadSignalSocket : public EventHandler
~ThreadSignalSocket()
{
ServerInstance->SE->DelFd(this);
- ServerInstance->SE->Close(GetFd());
+ SocketEngine::Close(GetFd());
}
void Notify()
@@ -123,7 +123,7 @@ class ThreadSignalSocket : public EventHandler
parent(p), send_fd(sendfd)
{
SetFd(recvfd);
- ServerInstance->SE->NonBlocking(fd);
+ SocketEngine::NonBlocking(fd);
ServerInstance->SE->AddFd(this, FD_WANT_FAST_READ | FD_WANT_NO_WRITE);
}
@@ -131,7 +131,7 @@ class ThreadSignalSocket : public EventHandler
{
close(send_fd);
ServerInstance->SE->DelFd(this);
- ServerInstance->SE->Close(GetFd());
+ SocketEngine::Close(GetFd());
}
void Notify()
diff --git a/src/threadengines/threadengine_win32.cpp b/src/threadengines/threadengine_win32.cpp
index ea37892f8..c3a844a74 100644
--- a/src/threadengines/threadengine_win32.cpp
+++ b/src/threadengines/threadengine_win32.cpp
@@ -94,20 +94,20 @@ SocketThread::SocketThread()
if (!ServerInstance->BindSocket(listenFD, 0, "127.0.0.1", true))
throw CoreException("Could not create ITC pipe");
- ServerInstance->SE->NonBlocking(connFD);
+ SocketEngine::NonBlocking(connFD);
struct sockaddr_in addr;
socklen_t sz = sizeof(addr);
getsockname(listenFD, reinterpret_cast<struct sockaddr*>(&addr), &sz);
connect(connFD, reinterpret_cast<struct sockaddr*>(&addr), sz);
- ServerInstance->SE->Blocking(listenFD);
+ SocketEngine::Blocking(listenFD);
int nfd = accept(listenFD, reinterpret_cast<struct sockaddr*>(&addr), &sz);
if (nfd < 0)
throw CoreException("Could not create ITC pipe");
new ThreadSignalSocket(this, nfd);
closesocket(listenFD);
- ServerInstance->SE->Blocking(connFD);
+ SocketEngine::Blocking(connFD);
this->signal.connFD = connFD;
}