File multipath-tools-set-max_fds-parameter-for-multipath of Package multipath-tools

From cce0922defb5c89c63ed42d2ea4a398d6a8c5a29 Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <hare@suse.de>
Date: Tue, 9 Dec 2008 12:26:49 +0100
Subject: [PATCH] Set 'max_fds' parameter for multipath

max_fds should be enabled for multipath, too.

References: 457443

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 multipath/main.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/multipath/main.c b/multipath/main.c
index ffa6eb5..49b5619 100644
--- a/multipath/main.c
+++ b/multipath/main.c
@@ -48,6 +48,9 @@
 #include <configure.h>
 #include <pgpolicies.h>
 #include <version.h>
+#include <errno.h>
+#include <sys/time.h>
+#include <sys/resource.h>
 
 int logsink;
 
@@ -477,6 +480,21 @@ main (int argc, char *argv[])
 			conf->dev_type = DEV_DEVMAP;
 
 	}
+	if (conf->max_fds) {
+		struct rlimit fd_limit;
+		if (conf->max_fds > 0) {
+			fd_limit.rlim_cur = conf->max_fds;
+			fd_limit.rlim_max = conf->max_fds;
+		}
+		else {
+			fd_limit.rlim_cur = RLIM_INFINITY;
+			fd_limit.rlim_max = RLIM_INFINITY;
+		}
+		if (setrlimit(RLIMIT_NOFILE, &fd_limit) < 0)
+			condlog(0, "can't set open fds limit to %d : %s\n",
+				conf->max_fds, strerror(errno));
+	}
+
 	dm_init();
 
 	if (conf->remove == FLUSH_ONE) {
-- 
1.6.0.2

openSUSE Build Service is sponsored by