Set 'max_fds' parameter for multipath
authorHannes Reinecke <hare@suse.de>
Tue, 9 Dec 2008 11:26:49 +0000 (12:26 +0100)
committerChristophe Varoqui <christophe.varoqui@free.fr>
Tue, 21 Apr 2009 23:00:46 +0000 (01:00 +0200)
max_fds should be enabled for multipath, too.

References: 457443

Signed-off-by: Hannes Reinecke <hare@suse.de>
multipath/main.c

index dacae1f..707e2b9 100644 (file)
@@ -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;
 
@@ -422,6 +425,22 @@ main (int argc, char *argv[])
 
        }
        conf->daemon = 0;
+
+       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) {