diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2005-05-10 14:45:59 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2005-05-10 14:45:59 +0000 |
commit | 26f8439040f8a49d4883dcd59709172360a1fbc8 (patch) | |
tree | 12c371e8007861543b6c1d514610152a419f8591 /src/inspircd.cpp | |
parent | f90325d048a0a6d0beebf2b5cf4c30657e3630ad (diff) |
Added server-listen-sockets to kqueue support (all sockets are now kqueue)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@1355 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/inspircd.cpp')
-rw-r--r-- | src/inspircd.cpp | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 2a2696413..1f7487242 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -112,7 +112,7 @@ bool unlimitcore = false; time_t TIME = time(NULL); #ifdef USE_KQUEUE -int kq, lkq; +int kq, lkq, skq; #endif namespace nspace @@ -4121,7 +4121,8 @@ int InspIRCd(char** argv, int argc) #ifdef USE_KQUEUE kq = kqueue(); lkq = kqueue(); - if ((kq == -1) || (lkq == -1)) + skq = kqueue(); + if ((kq == -1) || (lkq == -1) || (skq == -1)) { log(DEFAULT,"main: kqueue() failed!"); printf("ERROR: could not initialise kqueue event system. Shutting down.\n"); @@ -4144,6 +4145,23 @@ int InspIRCd(char** argv, int argc) printf("ERROR: could not initialise listening sockets in kqueue. Shutting down.\n"); } } + for (int t = 0; t != SERVERportCount; t++) + { + struct kevent ke; + if (me[t]) + { + log(DEBUG,"kqueue: Add listening SERVER socket to events, kq=%d socket=%d",skq,me[t]->fd); + EV_SET(&ke, me[t]->fd, EVFILT_READ, EV_ADD, 0, 5, NULL); + int i = kevent(skq, &ke, 1, 0, 0, NULL); + if (i == -1) + { + log(DEFAULT,"main: add server listen ports to kqueue failed!"); + printf("ERROR: could not initialise listening server sockets in kqueue. Shutting down.\n"); + } + } + } + + #else log(DEFAULT,"Using standard select socket engine."); #endif @@ -4200,16 +4218,25 @@ int InspIRCd(char** argv, int argc) // fix by brain - this must be below any manipulation of the hashmap by modules user_hash::iterator count2 = clientlist.begin(); +#ifdef USE_KQUEUE + ts.tv_sec = 0; + ts.tv_nsec = 30000L; + i = kevent(skq, NULL, 0, &ke, 1, &ts); + if (i > 0) + { + log(DEBUG,"kqueue: Listening server socket event, i=%d, ke.ident=%d",i,ke.ident); + for (int x = 0; x != SERVERportCount; x++) + { + if ((me[x]) && (ke.ident == me[x]->fd)) + { + +#else FD_ZERO(&serverfds); - for (int x = 0; x != SERVERportCount; x++) { if (me[x]) FD_SET(me[x]->fd, &serverfds); } - - // serverFds timevals went here - tvs.tv_usec = 30000L; tvs.tv_sec = 0; int servresult = select(32767, &serverfds, NULL, NULL, &tvs); @@ -4219,6 +4246,7 @@ int InspIRCd(char** argv, int argc) { if ((me[x]) && (FD_ISSET (me[x]->fd, &serverfds))) { +#endif char remotehost[MAXBUF],resolved[MAXBUF]; length = sizeof (client); incomingSockfd = accept (me[x]->fd, (sockaddr *) &client, &length); |