diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-10-30 18:45:04 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-10-30 18:45:04 +0000 |
commit | d9147559a3212ff9e61f9fed63ba361505ad519f (patch) | |
tree | 86c6b9b576518b00986ab1b5721718fa9f23c8e1 /src/socketengine_kqueue.cpp | |
parent | b27cdbef041244bb42f82023b401dda127cbe6de (diff) |
Not tested yet: Write and read at the same time in kqueue
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5582 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/socketengine_kqueue.cpp')
-rw-r--r-- | src/socketengine_kqueue.cpp | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/src/socketengine_kqueue.cpp b/src/socketengine_kqueue.cpp index 43d27ba5a..59e4c4812 100644 --- a/src/socketengine_kqueue.cpp +++ b/src/socketengine_kqueue.cpp @@ -107,6 +107,21 @@ bool KQueueEngine::DelFd(EventHandler* eh) return true; } +void KQueueEngine::WantWrite(EventHandler* eh) +{ + struct kevent ke; + EV_SET(&ke, eh->GetFd(), EVFILT_WRITE | EVFILT_READ, EV_ADD | EV_ONESHOT, 0, 0, NULL); + int i = kevent(EngineHandle, &ke, 1, 0, 0, NULL); + if (i == -1) + { + ServerInstance->Log(DEBUG,"kqueue: Unable to set fd %d for wanting write", eh->GetFd()); + } + else + { + ServerInstance->Log(DEBUG,"kqueue: Set fd %d for want write", eh->GetFd()); + } +} + int KQueueEngine::GetMaxFds() { return MAX_DESCRIPTORS; @@ -124,8 +139,19 @@ int KQueueEngine::DispatchEvents() int i = kevent(EngineHandle, NULL, 0, &ke_list[0], MAX_DESCRIPTORS, &ts); for (int j = 0; j < i; j++) { - ServerInstance->Log(DEBUG,"Handle %s event on fd %d",ref[ke_list[j].ident]->Readable() ? "read" : "write", ref[ke_list[j].ident]->GetFd()); - ref[ke_list[j].ident]->HandleEvent(ref[ke_list[j].ident]->Readable() ? EVENT_READ : EVENT_WRITE); + ServerInstance->Log(DEBUG,"Handle %s event on fd %d",ke_list[j].flags & EVFILT_WRITE ? "write" : "read", ke_list[j].ident); + if (ke_list[j].flags & EVFILT_WRITE) + { + ServerInstance->Log(DEBUG,"kqueue: Write socket wants to be set back to read"); + struct kevent ke; + EV_SET(&ke, ke_list[j].ident, EVFILT_READ, EV_ADD, 0, 0, NULL); + int i = kevent(EngineHandle, &ke, 1, 0, 0, NULL); + if (i == -1) + { + ServerInstance->Log(DEBUG,"kqueue: Unable to set fd %d back to just wanting to read!", ke_list[j].ident); + } + } + ref[ke_list[j].ident]->HandleEvent(ke_list[j].flags & EVFILT_WRITE ? EVENT_WRITE : EVENT_READ); } return i; |