Re-added code to tell the user how many open files they
authorJeremy Allison <jra@samba.org>
Fri, 16 Oct 1998 06:16:10 +0000 (06:16 +0000)
committerJeremy Allison <jra@samba.org>
Fri, 16 Oct 1998 06:16:10 +0000 (06:16 +0000)
have. Needed for server diagnosis purposes...
Jeremy.

source/include/proto.h
source/lib/util.c
source/smbd/files.c
source/smbwrapper/smbw.c

index 09fe5b0873f16a64f605bd52ace4003b20d8ee1c..d563db3933812c5a8a0cc1055334fd1a22cb58a0 100644 (file)
@@ -351,7 +351,7 @@ char *sid_to_string(pstring sidstr_out, DOM_SID *sid);
 BOOL string_to_sid(DOM_SID *sidout, char *sidstr);
 int str_checksum(const char *s);
 void zero_free(void *p, size_t size);
-int set_maxfiles(void);
+int set_maxfiles(int requested_max);
 
 /*The following definitions come from  libsmb/clientgen.c  */
 
@@ -1189,7 +1189,7 @@ BOOL trust_password_unlock(void);
 BOOL trust_password_delete( char *domain, char *name );
 BOOL get_trust_account_password( unsigned char *ret_pwd, time_t *pass_last_set_time);
 BOOL set_trust_account_password( unsigned char *md4_new_pwd);
-BOOL trust_get_passwd( unsigned char trust_passwd[16], char *myname, char *domain);
+BOOL trust_get_passwd( unsigned char trust_passwd[16], char *domain, char *myname);
 
 /*The following definitions come from  printing/pcap.c  */
 
index c1307336cc18220deecf0b462abf141a8d4d5483..d0cb51f3caa34e331ddbb5286cc3c75e43254430 100644 (file)
@@ -4849,9 +4849,9 @@ void zero_free(void *p, size_t size)
 
 
 /*****************************************************************
-set our open file limit to the max and return the limit
+set our open file limit to a requested max and return the limit
 *****************************************************************/  
-int set_maxfiles(void)
+int set_maxfiles(int requested_max)
 {
 #if (defined(HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE))
        struct rlimit rlp;
@@ -4860,13 +4860,15 @@ int set_maxfiles(void)
         * account for the extra fd we need 
         * as well as the log files and standard
         * handles etc.  */
-       rlp.rlim_cur = rlp.rlim_max;
+       rlp.rlim_cur = MIN(requested_max,rlp.rlim_max);
        setrlimit(RLIMIT_NOFILE, &rlp);
        getrlimit(RLIMIT_NOFILE, &rlp);
        return rlp.rlim_cur;
 #else
-       /* just guess ... */
-       return 1024;
+       /*
+        * No way to know - just guess...
+        */
+       return requested_max;
 #endif
 }
 
index 4030ad4c498ea59b08e17c7a9a00c7c506f4500d..c369a45bab3e3168ab0cb1381cc838bb9732f55d 100644 (file)
@@ -202,13 +202,23 @@ initialise file structures
 
 void file_init(void)
 {
-       int lim;
+        int request_max_open_files = lp_max_open_files();
+       int real_lim;
 
-       lim = set_maxfiles();
-       lim = MIN(lim, lp_max_open_files());
+       /*
+        * Set the max_open files to be the requested
+        * max plus a fudgefactor to allow for the extra
+        * fd's we need such as log files etc...
+        */
+       real_lim = set_maxfiles(request_max_open_files + MAX_OPEN_FUDGEFACTOR);
+
+       real_max_open_files = real_lim - MAX_OPEN_FUDGEFACTOR;
+
+        if(real_max_open_files != request_max_open_files) {
+               DEBUG(1,("file_init: Information only: requested %d \
+open files, %d are available.\n", request_max_open_files, real_max_open_files));
+       }
 
-       real_max_open_files = lim - MAX_OPEN_FUDGEFACTOR;
-       
        file_bmap = bitmap_allocate(real_max_open_files);
        
        if (!file_bmap) {
index d9ff6daa05cf491218f18569a4d1c452ca5c5be8..9c690ac5fb27b7be2fd2052c518fda00abe919a1 100644 (file)
@@ -100,7 +100,7 @@ void smbw_init(void)
        }
        smbw_busy--;
 
-       set_maxfiles();
+       set_maxfiles(lp_max_open_files()+10);
 
        errno = eno;
 }