Blame SOURCES/xinetd-2.3.14-file-limit.patch

319196
diff -Nurp xinetd-2.3.14-orig/xinetd/attr.h xinetd-2.3.14-files/xinetd/attr.h
319196
--- xinetd-2.3.14-orig/xinetd/attr.h	2005-10-05 19:15:33.000000000 +0200
319196
+++ xinetd-2.3.14-files/xinetd/attr.h	2009-10-20 13:08:45.000000000 +0200
319196
@@ -61,12 +61,13 @@
319196
 #define A_DISABLED         43
319196
 #define A_MDNS             44
319196
 #define A_LIBWRAP          45
319196
+#define A_RLIMIT_FILES     46
319196
 
319196
 /*
319196
  * SERVICE_ATTRIBUTES is the number of service attributes and also
319196
  * the number from which defaults-only attributes start.
319196
  */
319196
-#define SERVICE_ATTRIBUTES      ( A_MDNS + 1 )
319196
+#define SERVICE_ATTRIBUTES      ( A_MDNS + 2 )
319196
 
319196
 /*
319196
  * Mask of attributes that must be specified.
319196
diff -Nurp xinetd-2.3.14-orig/xinetd/child.c xinetd-2.3.14-files/xinetd/child.c
319196
--- xinetd-2.3.14-orig/xinetd/child.c	2009-10-20 13:07:34.000000000 +0200
319196
+++ xinetd-2.3.14-files/xinetd/child.c	2009-10-20 13:10:16.000000000 +0200
319196
@@ -109,6 +109,10 @@ void exec_server( const struct server *s
319196
 
319196
 
319196
 #ifdef RLIMIT_NOFILE
319196
+   if ( SC_RLIM_FILES( scp ))
319196
+   {
319196
+      ps.ros.max_descriptors = SC_RLIM_FILES( scp );
319196
+   }
319196
    rl.rlim_max = rl.rlim_cur = ps.ros.max_descriptors ;
319196
    (void) setrlimit( RLIMIT_NOFILE, &rl ) ;
319196
 #endif
319196
diff -Nurp xinetd-2.3.14-orig/xinetd/parse.c xinetd-2.3.14-files/xinetd/parse.c
319196
--- xinetd-2.3.14-orig/xinetd/parse.c	2005-10-05 19:15:33.000000000 +0200
319196
+++ xinetd-2.3.14-files/xinetd/parse.c	2009-10-20 13:08:45.000000000 +0200
319196
@@ -92,6 +92,9 @@ static const struct attribute service_at
319196
 #ifdef RLIMIT_DATA
319196
    { "rlimit_data",    A_RLIMIT_DATA,    1,  rlim_data_parser       },
319196
 #endif
319196
+#ifdef RLIMIT_NOFILE
319196
+   { "rlimit_files",   A_RLIMIT_FILES,   1,  rlim_files_parser      },
319196
+#endif
319196
 #ifdef RLIMIT_RSS
319196
    { "rlimit_rss",     A_RLIMIT_RSS,     1,  rlim_rss_parser        },
319196
 #endif
319196
diff -Nurp xinetd-2.3.14-orig/xinetd/parsers.c xinetd-2.3.14-files/xinetd/parsers.c
319196
--- xinetd-2.3.14-orig/xinetd/parsers.c	2005-10-05 23:45:41.000000000 +0200
319196
+++ xinetd-2.3.14-files/xinetd/parsers.c	2009-10-20 13:08:45.000000000 +0200
319196
@@ -1415,6 +1415,29 @@ status_e rlim_data_parser( pset_h values
319196
 }
319196
 #endif
319196
 
319196
+#ifdef RLIMIT_NOFILE
319196
+status_e rlim_files_parser( pset_h values, 
319196
+                         struct service_config *scp, 
319196
+                         enum assign_op op )
319196
+{
319196
+   char *mem = (char *) pset_pointer( values, 0 ) ;
319196
+   const char *func = "rlim_files_parser" ;
319196
+
319196
+   if ( EQ( mem, "UNLIMITED" ) )
319196
+      SC_RLIM_FILES(scp) = (rlim_t)RLIM_INFINITY ;
319196
+   else
319196
+   {
319196
+      if ( get_limit ( mem, &SC_RLIM_FILES(scp)) )
319196
+      {
319196
+         parsemsg( LOG_ERR, func,
319196
+            "Max files limit is invalid: %s", mem ) ;
319196
+         return( FAILED ) ;
319196
+      }
319196
+   }
319196
+   return( OK ) ;
319196
+}
319196
+#endif
319196
+
319196
 #ifdef RLIMIT_RSS
319196
 status_e rlim_rss_parser( pset_h values, 
319196
                           struct service_config *scp, 
319196
diff -Nurp xinetd-2.3.14-orig/xinetd/parsers.h xinetd-2.3.14-files/xinetd/parsers.h
319196
--- xinetd-2.3.14-orig/xinetd/parsers.h	2005-10-05 19:15:33.000000000 +0200
319196
+++ xinetd-2.3.14-files/xinetd/parsers.h	2009-10-20 13:08:45.000000000 +0200
319196
@@ -57,6 +57,9 @@ status_e rlim_cpu_parser(pset_h, struct 
319196
 #ifdef RLIMIT_DATA
319196
 status_e rlim_data_parser(pset_h, struct service_config *, enum assign_op) ;
319196
 #endif
319196
+#ifdef RLIMIT_NOFILE
319196
+status_e rlim_files_parser(pset_h, struct service_config *, enum assign_op) ;
319196
+#endif
319196
 #ifdef RLIMIT_RSS
319196
 status_e rlim_rss_parser(pset_h, struct service_config *, enum assign_op) ;
319196
 #endif
319196
diff -Nurp xinetd-2.3.14-orig/xinetd/sconf.h xinetd-2.3.14-files/xinetd/sconf.h
319196
--- xinetd-2.3.14-orig/xinetd/sconf.h	2009-10-20 13:07:34.000000000 +0200
319196
+++ xinetd-2.3.14-files/xinetd/sconf.h	2009-10-20 13:08:45.000000000 +0200
319196
@@ -143,6 +143,7 @@ struct service_config
319196
    rlim_t               sc_rlim_as;
319196
    rlim_t               sc_rlim_cpu;
319196
    rlim_t               sc_rlim_data;
319196
+   rlim_t               sc_rlim_files;
319196
    rlim_t               sc_rlim_rss;
319196
    rlim_t               sc_rlim_stack;
319196
    mode_t               sc_umask;
319196
@@ -191,6 +192,7 @@ struct service_config
319196
 #define SC_RLIM_AS( scp )        (scp)->sc_rlim_as
319196
 #define SC_RLIM_CPU( scp )       (scp)->sc_rlim_cpu
319196
 #define SC_RLIM_DATA( scp )      (scp)->sc_rlim_data
319196
+#define SC_RLIM_FILES( scp )     (scp)->sc_rlim_files
319196
 #define SC_RLIM_RSS( scp )       (scp)->sc_rlim_rss
319196
 #define SC_RLIM_STACK( scp )     (scp)->sc_rlim_stack
319196
 #define SC_TYPE( scp )           (scp)->sc_type
319196
diff -Nurp xinetd-2.3.14-orig/xinetd/xinetd.conf.man xinetd-2.3.14-files/xinetd/xinetd.conf.man
319196
--- xinetd-2.3.14-orig/xinetd/xinetd.conf.man	2009-10-20 13:07:34.000000000 +0200
319196
+++ xinetd-2.3.14-files/xinetd/xinetd.conf.man	2009-10-20 13:08:45.000000000 +0200
319196
@@ -569,6 +569,12 @@ is implemented, it is more useful to set
319196
 rlimit_rss and rlimit_stack. This resource limit is only implemented on
319196
 Linux systems.
319196
 .TP
319196
+.B rlimit_files
319196
+Sets the maximum number of open files that the service may use.
319196
+One parameter is required, which is a positive integer representing
319196
+the number of open file descriptors. Practical limit of this number
319196
+is around 1024000.
319196
+.TP
319196
 .B rlimit_cpu
319196
 Sets the maximum number of CPU seconds that the service may use.
319196
 One parameter is required, which is either a positive integer representing