summaryrefslogtreecommitdiff
path: root/src/socketengines/socketengine_select.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/socketengines/socketengine_select.cpp')
-rw-r--r--src/socketengines/socketengine_select.cpp15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/socketengines/socketengine_select.cpp b/src/socketengines/socketengine_select.cpp
index 8c41df11b..7f6a4e283 100644
--- a/src/socketengines/socketengine_select.cpp
+++ b/src/socketengines/socketengine_select.cpp
@@ -18,7 +18,7 @@
#include "socketengines/socketengine_select.h"
-SelectEngine::SelectEngine(InspIRCd* Instance) : SocketEngine(Instance)
+SelectEngine::SelectEngine()
{
MAX_DESCRIPTORS = FD_SETSIZE;
EngineHandle = 0;
@@ -34,7 +34,7 @@ SelectEngine::~SelectEngine()
delete[] ref;
}
-bool SelectEngine::AddFd(EventHandler* eh)
+bool SelectEngine::AddFd(EventHandler* eh, bool writeFirst)
{
int fd = eh->GetFd();
if ((fd < 0) || (fd > GetMaxFds() - 1))
@@ -50,6 +50,8 @@ bool SelectEngine::AddFd(EventHandler* eh)
ref[fd] = eh;
CurrentSetSize++;
+ writeable[eh->GetFd()] = writeFirst;
+
ServerInstance->Logs->Log("SOCKET",DEBUG,"New file descriptor: %d", fd);
return true;
}
@@ -101,16 +103,11 @@ int SelectEngine::DispatchEvents()
/* Populate the select FD set (this is why select sucks compared to epoll, kqueue, IOCP) */
for (std::set<int>::iterator a = fds.begin(); a != fds.end(); a++)
{
- if (ref[*a]->Readable())
- /* Read notifications */
- FD_SET (*a, &rfdset);
- else
- /* Write notifications */
- FD_SET (*a, &wfdset);
-
/* Explicitly one-time writeable */
if (writeable[*a])
FD_SET (*a, &wfdset);
+ else
+ FD_SET (*a, &rfdset);
/* All sockets must receive error notifications regardless */
FD_SET (*a, &errfdset);