From 7ad6dcd9777ba2d24f6bfc12ed880dccb0dd77aa Mon Sep 17 00:00:00 2001 From: Bram Matthys Date: Mon, 4 Jan 2010 13:11:03 +0000 Subject: [PATCH] - Fixed a /RESTART issue on Linux: Unreal did not properly close all file- descriptors. Because of this, Unreal did not restart properly as you would get an "Address already in use" error. This only seemed to happen when logging to syslog. - Fixed a similar issue with syslog (and debugmode) and closing fd's as well: the first port we listened on would not open up, ircd did not log any error. --- Changes | 6 ++++++ src/ircd.c | 3 +-- src/s_bsd.c | 6 ++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Changes b/Changes index a62f01ee4..93d5599d4 100644 --- a/Changes +++ b/Changes @@ -1894,3 +1894,9 @@ not exist, it now asks you if you want to automatically download and install curl (which is done by ./curlinstall). This has been tested on Linux, further testing on f.e. FreeBSD is required. +- Fixed a /RESTART issue on Linux: Unreal did not properly close all file- + descriptors. Because of this, Unreal did not restart properly as you would + get an "Address already in use" error. This only seemed to happen when + logging to syslog. +- Fixed a similar issue with syslog (and debugmode) and closing fd's as well: + the first port we listened on would not open up, ircd did not log any error. diff --git a/src/ircd.c b/src/ircd.c index 67facf542..587e5f843 100644 --- a/src/ircd.c +++ b/src/ircd.c @@ -361,8 +361,7 @@ void server_reboot(char *mesg) if (!(bootopt & (BOOT_TTY | BOOT_DEBUG))) (void)close(2); (void)close(1); - if ((bootopt & BOOT_CONSOLE) || isatty(0)) - (void)close(0); + (void)close(0); (void)execv(MYNAME, myargv); #else close_connections(); diff --git a/src/s_bsd.c b/src/s_bsd.c index b0d596a22..e7146f079 100644 --- a/src/s_bsd.c +++ b/src/s_bsd.c @@ -605,6 +605,9 @@ char logbuf[BUFSIZ]; # endif #endif #ifndef _WIN32 +#ifdef HAVE_SYSLOG +closelog(); /* temporary close syslog, as we mass close() fd's below... */ +#endif #ifndef NOCLOSEFD for (fd = 3; fd < MAXCONNECTIONS; fd++) { @@ -655,6 +658,9 @@ init_dgram: close(fileno(stdout)); if (!(bootopt & BOOT_DEBUG)) close(fileno(stderr)); +#endif +#ifdef HAVE_SYSLOG +openlog("ircd", LOG_PID | LOG_NDELAY, LOG_DAEMON); /* reopened now */ #endif memset(local, 0, sizeof(aClient*) * MAXCONNECTIONS); LastSlot = -1;