From 2cf4b614e6c23bfc6d47da2ec4b1932ee2f62cf0 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Sat, 8 Feb 2014 13:10:09 +0100 Subject: Change SocketEngine functions that do not require an instance to be static --- src/commands/cmd_dns.cpp | 14 +++++++------- src/configreader.cpp | 2 +- src/inspsocket.cpp | 10 +++++----- src/listensocket.cpp | 26 +++++++++++++------------- src/modules/m_ident.cpp | 8 ++++---- src/socket.cpp | 6 +++--- src/threadengines/threadengine_pthread.cpp | 6 +++--- src/threadengines/threadengine_win32.cpp | 6 +++--- 8 files changed, 39 insertions(+), 39 deletions(-) (limited to 'src') 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(&addr), &sz); connect(connFD, reinterpret_cast(&addr), sz); - ServerInstance->SE->Blocking(listenFD); + SocketEngine::Blocking(listenFD); int nfd = accept(listenFD, reinterpret_cast(&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; } -- cgit v1.2.3