summaryrefslogtreecommitdiff
path: root/src/socketengine_select.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-10-30 19:49:13 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-10-30 19:49:13 +0000
commit2a31fe603884449ff08f300fa43dc7c0770b71e2 (patch)
tree52d0b92c963b57ed437000530bd0f48ef8bafcd6 /src/socketengine_select.cpp
parentb8f4ba8214a9ae954c506dec354020b43849c346 (diff)
Select is now done, and some debug removed. Not that anyone really should be using select()...
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5587 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/socketengine_select.cpp')
-rw-r--r--src/socketengine_select.cpp30
1 files changed, 23 insertions, 7 deletions
diff --git a/src/socketengine_select.cpp b/src/socketengine_select.cpp
index 8d0ed446c..7a21fab84 100644
--- a/src/socketengine_select.cpp
+++ b/src/socketengine_select.cpp
@@ -24,6 +24,7 @@ SelectEngine::SelectEngine(InspIRCd* Instance) : SocketEngine(Instance)
ServerInstance->Log(DEBUG,"SelectEngine::SelectEngine()");
EngineHandle = 0;
CurrentSetSize = 0;
+ memset(writeable, 0, sizeof(writeable));
}
SelectEngine::~SelectEngine()
@@ -57,6 +58,15 @@ bool SelectEngine::AddFd(EventHandler* eh)
return true;
}
+void SelectEngine::WantWrite(EventHandler* eh)
+{
+ int fd = eh->GetFd();
+
+ writeable[fd] = true;
+
+ ServerInstance->Log(DEBUG,"Set %d to writeable", fd);
+}
+
bool SelectEngine::DelFd(EventHandler* eh)
{
int fd = eh->GetFd();
@@ -101,14 +111,11 @@ int SelectEngine::DispatchEvents()
for (std::map<int,int>::iterator a = fds.begin(); a != fds.end(); a++)
{
if (ref[a->second]->Readable())
- {
FD_SET (a->second, &rfdset);
- }
else
- {
FD_SET (a->second, &wfdset);
- }
-
+ if (writeable[a->second])
+ FD_SET (a->second, &wfdset);
}
tval.tv_sec = 0;
tval.tv_usec = 50L;
@@ -131,8 +138,17 @@ int SelectEngine::DispatchEvents()
*/
for (int i = 0; i < result; i++)
{
- ServerInstance->Log(DEBUG,"Handle %s event on fd %d",ev[i]->Readable() ? "read" : "write", ev[i]->GetFd());
- ev[i]->HandleEvent(ev[i]->Readable() ? EVENT_READ : EVENT_WRITE);
+ ServerInstance->Log(DEBUG,"Handle %s event on fd %d",writeable[ev[i]->GetFd()] || !ev[i]->Readable() ? "write" : "read", ev[i]->GetFd());
+ if (writeable[ev[i]->GetFd()])
+ {
+ ev[i]->HandleEvent(EVENT_WRITE);
+ writeable[ev[i]->GetFd()] = false;
+
+ }
+ else
+ {
+ ev[i]->HandleEvent(ev[i]->Readable() ? EVENT_READ : EVENT_WRITE);
+ }
}
return result;