[icinga-checkins] icinga.org: icinga2/master: Implement an environment variable to keep Icinga from closing FDs on startup

git at icinga.org git at icinga.org
Tue Aug 23 13:30:53 CEST 2016


Module: icinga2
Branch: master
Commit: 54a1a7d12c7b4f3d4702700ecdb9e757aa1d87fb
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=54a1a7d12c7b4f3d4702700ecdb9e757aa1d87fb

Author: Gunnar Beutner <gunnar.beutner at netways.de>
Date:   Tue Aug 23 05:11:22 2016 +0200

Implement an environment variable to keep Icinga from closing FDs on startup

fixes #12510

---

 icinga-app/icinga.cpp |   20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/icinga-app/icinga.cpp b/icinga-app/icinga.cpp
index f504505..0fea800 100644
--- a/icinga-app/icinga.cpp
+++ b/icinga-app/icinga.cpp
@@ -706,20 +706,22 @@ VOID WINAPI ServiceMain(DWORD argc, LPSTR *argv)
 int main(int argc, char **argv)
 {
 #ifndef _WIN32
-	rlimit rl;
-	if (getrlimit(RLIMIT_NOFILE, &rl) >= 0) {
-		rlim_t maxfds = rl.rlim_max;
+	if (!getenv("ICINGA2_KEEP_FDS")) {
+		rlimit rl;
+		if (getrlimit(RLIMIT_NOFILE, &rl) >= 0) {
+			rlim_t maxfds = rl.rlim_max;
 
-		if (maxfds == RLIM_INFINITY)
-			maxfds = 65536;
+			if (maxfds == RLIM_INFINITY)
+				maxfds = 65536;
 
-		for (rlim_t i = 3; i < maxfds; i++) {
-			int rc = close(i);
+			for (rlim_t i = 3; i < maxfds; i++) {
+				int rc = close(i);
 
 #ifdef I2_DEBUG
-			if (rc >= 0)
-				std::cerr << "Closed FD " << i << " which we inherited from our parent process." << std::endl;
+				if (rc >= 0)
+					std::cerr << "Closed FD " << i << " which we inherited from our parent process." << std::endl;
 #endif /* I2_DEBUG */
+			}
 		}
 	}
 #endif /* _WIN32 */



More information about the icinga-checkins mailing list