diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2005-05-10 00:22:39 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2005-05-10 00:22:39 +0000 |
commit | a9af290f1696440623c0585ec0c35991b317e678 (patch) | |
tree | c5529b94f0a96d79b9822a48db5742610fe3c795 /src | |
parent | 1c6241ecd36b1f5492c71569492f54c22a8cb96b (diff) |
Cannot initialize kqueue BEFORE the daemon fork!
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@1350 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r-- | src/inspircd.cpp | 52 | ||||
-rw-r--r-- | src/inspircd_io.cpp | 3 |
2 files changed, 42 insertions, 13 deletions
diff --git a/src/inspircd.cpp b/src/inspircd.cpp index f82be162e..4979f4d48 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -2397,16 +2397,6 @@ int main(int argc, char** argv) lowermap[']'] = '}'; lowermap['\\'] = '|'; -#ifdef USE_KQUEUE - kq = kqueue(); - if (kq == -1) - { - log(DEFAULT,"main: kqueue() failed!"); - printf("ERROR: could not initialise kqueue event system. Shutting down.\n"); - Exit(ERROR); - } -#endif - if (InspIRCd(argv,argc) == ERROR) { log(DEFAULT,"main: daemon function bailed"); @@ -2614,10 +2604,42 @@ void AddClient(int socket, char* host, int port, bool iscached, char* ip) #ifdef USE_KQUEUE struct kevent ke; + memset(&ke,0,sizeof(struct kevent)); + log(DEBUG,"kqueue: Add user to events, kq=%d socket=%d",kq,socket); EV_SET(&ke, socket, EVFILT_READ, EV_ADD, 0, 0, NULL); int i = kevent(kq, &ke, 1, 0, 0, NULL); if (i == -1) { + switch (errno) + { + case EACCES: + log(DEBUG,"kqueue: EACCES"); + break; + case EFAULT: + log(DEBUG,"kqueue: EFAULT"); + break; + case EBADF: + log(DEBUG,"kqueue: EBADF=%d",ke.ident); + break; + case EINTR: + log(DEBUG,"kqueue: EINTR"); + break; + case EINVAL: + log(DEBUG,"kqueue: EINVAL"); + break; + case ENOENT: + log(DEBUG,"kqueue: ENOENT"); + break; + case ENOMEM: + log(DEBUG,"kqueue: ENOMEM"); + break; + case ESRCH: + log(DEBUG,"kqueue: ESRCH"); + break; + default: + log(DEBUG,"kqueue: UNKNOWN!"); + break; + } log(DEBUG,"kqueue: Failed to add user to queue!"); } @@ -4091,6 +4113,16 @@ int InspIRCd(char** argv, int argc) } } + // BUGFIX: We cannot initialize this before forking, as the kqueue data is not inherited by child processes! +#ifdef USE_KQUEUE + kq = kqueue(); + if (kq == -1) + { + log(DEFAULT,"main: kqueue() failed!"); + printf("ERROR: could not initialise kqueue event system. Shutting down.\n"); + Exit(ERROR); + } +#endif WritePID(PID); length = sizeof (client); diff --git a/src/inspircd_io.cpp b/src/inspircd_io.cpp index eb564e555..3ef3c11e3 100644 --- a/src/inspircd_io.cpp +++ b/src/inspircd_io.cpp @@ -99,10 +99,7 @@ int DaemonSeed (void) signal (SIGHUP, Rehash); signal (SIGPIPE, DeadPipe); signal (SIGTERM, Exit); - signal (SIGABRT, Exit); signal (SIGSEGV, Error); - signal (SIGURG, Exit); - signal (SIGKILL, Exit); if ((childpid = fork ()) < 0) return (ERROR); else if (childpid > 0) |