diff options
author | Attila Molnar <attilamolnar@hush.com> | 2014-02-08 22:34:11 +0100 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2014-02-08 22:34:11 +0100 |
commit | aea38a0dd702895b7dfd18efd26a0dcead2279fc (patch) | |
tree | 471443cdc87a922131a7cbf14c313d46b946ee5d /src/socketengines | |
parent | b01820c079a605654d6307f6e57d65b339deef7d (diff) |
Update SocketEngine::CurrentSetSize in AddFdRef()/DelFdRef()
Diffstat (limited to 'src/socketengines')
-rw-r--r-- | src/socketengines/socketengine_epoll.cpp | 3 | ||||
-rw-r--r-- | src/socketengines/socketengine_kqueue.cpp | 3 | ||||
-rw-r--r-- | src/socketengines/socketengine_poll.cpp | 8 | ||||
-rw-r--r-- | src/socketengines/socketengine_ports.cpp | 3 | ||||
-rw-r--r-- | src/socketengines/socketengine_select.cpp | 4 |
5 files changed, 2 insertions, 19 deletions
diff --git a/src/socketengines/socketengine_epoll.cpp b/src/socketengines/socketengine_epoll.cpp index 9e2f6dc2b..7ee01b2cc 100644 --- a/src/socketengines/socketengine_epoll.cpp +++ b/src/socketengines/socketengine_epoll.cpp @@ -53,7 +53,6 @@ public: EPollEngine::EPollEngine() : events(1) { - CurrentSetSize = 0; int max = ulimit(4, 0); if (max > 0) { @@ -136,7 +135,6 @@ bool EPollEngine::AddFd(EventHandler* eh, int event_mask) ServerInstance->Logs->Log("SOCKET", LOG_DEBUG, "New file descriptor: %d", fd); SocketEngine::SetEventMask(eh, event_mask); - CurrentSetSize++; ResizeDouble(events); return true; @@ -180,7 +178,6 @@ void EPollEngine::DelFd(EventHandler* eh) SocketEngine::DelFdRef(eh); ServerInstance->Logs->Log("SOCKET", LOG_DEBUG, "Remove file descriptor: %d", fd); - CurrentSetSize--; } int EPollEngine::DispatchEvents() diff --git a/src/socketengines/socketengine_kqueue.cpp b/src/socketengines/socketengine_kqueue.cpp index 8666a84fe..c51789b29 100644 --- a/src/socketengines/socketengine_kqueue.cpp +++ b/src/socketengines/socketengine_kqueue.cpp @@ -91,7 +91,6 @@ void KQueueEngine::RecoverFromFork() std::cout << "ERROR: this is a fatal error, exiting now." << std::endl; ServerInstance->QuickExit(EXIT_STATUS_SOCKETENGINE); } - CurrentSetSize = 0; } KQueueEngine::~KQueueEngine() @@ -125,7 +124,6 @@ bool KQueueEngine::AddFd(EventHandler* eh, int event_mask) SocketEngine::SetEventMask(eh, event_mask); OnSetEvent(eh, 0, event_mask); - CurrentSetSize++; ResizeDouble(ke_list); return true; @@ -159,7 +157,6 @@ void KQueueEngine::DelFd(EventHandler* eh) } SocketEngine::DelFdRef(eh); - CurrentSetSize--; ServerInstance->Logs->Log("SOCKET", LOG_DEBUG, "Remove file descriptor: %d", fd); } diff --git a/src/socketengines/socketengine_poll.cpp b/src/socketengines/socketengine_poll.cpp index ca9bfd1ea..46a517c51 100644 --- a/src/socketengines/socketengine_poll.cpp +++ b/src/socketengines/socketengine_poll.cpp @@ -64,7 +64,6 @@ public: PollEngine::PollEngine() : events(1), fd_mappings(1) { - CurrentSetSize = 0; struct rlimit limits; if (!getrlimit(RLIMIT_NOFILE, &limits)) { @@ -103,14 +102,14 @@ bool PollEngine::AddFd(EventHandler* eh, int event_mask) return false; } + unsigned int index = CurrentSetSize; + if (!SocketEngine::AddFdRef(eh)) { ServerInstance->Logs->Log("SOCKET", LOG_DEBUG, "Attempt to add duplicate fd: %d", fd); return false; } - unsigned int index = CurrentSetSize; - while (static_cast<unsigned int>(fd) >= fd_mappings.size()) fd_mappings.resize(fd_mappings.size() * 2, -1); fd_mappings[fd] = index; @@ -121,7 +120,6 @@ bool PollEngine::AddFd(EventHandler* eh, int event_mask) ServerInstance->Logs->Log("SOCKET", LOG_DEBUG, "New file descriptor: %d (%d; index %d)", fd, events[index].events, index); SocketEngine::SetEventMask(eh, event_mask); - CurrentSetSize++; return true; } @@ -176,8 +174,6 @@ void PollEngine::DelFd(EventHandler* eh) SocketEngine::DelFdRef(eh); - CurrentSetSize--; - ServerInstance->Logs->Log("SOCKET", LOG_DEBUG, "Remove file descriptor: %d (index: %d) " "(Filled gap with: %d (index: %d))", fd, index, last_fd, last_index); } diff --git a/src/socketengines/socketengine_ports.cpp b/src/socketengines/socketengine_ports.cpp index 2783ce4cc..226f59f04 100644 --- a/src/socketengines/socketengine_ports.cpp +++ b/src/socketengines/socketengine_ports.cpp @@ -79,7 +79,6 @@ PortsEngine::PortsEngine() : events(1) std::cout << "ERROR: This is a fatal error, exiting now." << std::endl; ServerInstance->QuickExit(EXIT_STATUS_SOCKETENGINE); } - CurrentSetSize = 0; } PortsEngine::~PortsEngine() @@ -110,7 +109,6 @@ bool PortsEngine::AddFd(EventHandler* eh, int event_mask) port_associate(EngineHandle, PORT_SOURCE_FD, fd, mask_to_events(event_mask), eh); ServerInstance->Logs->Log("SOCKET", LOG_DEBUG, "New file descriptor: %d", fd); - CurrentSetSize++; ResizeDouble(events); return true; @@ -130,7 +128,6 @@ void PortsEngine::DelFd(EventHandler* eh) port_dissociate(EngineHandle, PORT_SOURCE_FD, fd); - CurrentSetSize--; SocketEngine::DelFdRef(eh); ServerInstance->Logs->Log("SOCKET", LOG_DEBUG, "Remove file descriptor: %d", fd); diff --git a/src/socketengines/socketengine_select.cpp b/src/socketengines/socketengine_select.cpp index d47847154..7aaa7aaf7 100644 --- a/src/socketengines/socketengine_select.cpp +++ b/src/socketengines/socketengine_select.cpp @@ -46,7 +46,6 @@ public: SelectEngine::SelectEngine() { MAX_DESCRIPTORS = FD_SETSIZE; - CurrentSetSize = 0; FD_ZERO(&ReadSet); FD_ZERO(&WriteSet); @@ -69,8 +68,6 @@ bool SelectEngine::AddFd(EventHandler* eh, int event_mask) if (fd > MaxFD) MaxFD = fd; - CurrentSetSize++; - ServerInstance->Logs->Log("SOCKET", LOG_DEBUG, "New file descriptor: %d", fd); return true; } @@ -82,7 +79,6 @@ void SelectEngine::DelFd(EventHandler* eh) if ((fd < 0) || (fd > GetMaxFds() - 1)) return; - CurrentSetSize--; SocketEngine::DelFdRef(eh); FD_CLR(fd, &ReadSet); |