s3/smbd: open the share_info.tdb on startup instead of tconx
authorSteven Danneman <steven.danneman@isilon.com>
Wed, 26 Aug 2009 23:17:38 +0000 (16:17 -0700)
committerSteven Danneman <steven.danneman@isilon.com>
Wed, 26 Aug 2009 23:34:10 +0000 (16:34 -0700)
This is a small performance optimization.  Instead of opening the tdb
on every smb connection in the forked child process, we now open it in
the parent and share the fd.

This also reduces the total fd usage in the system.

source3/include/proto.h
source3/lib/sharesec.c
source3/smbd/server.c

index 50ac834307a5a26b9e33461163324c600e8f548b..0da8c25a3956ccfe796cf064a62c7e9bdeb36f64 100644 (file)
@@ -721,6 +721,7 @@ struct named_mutex *grab_named_mutex(TALLOC_CTX *mem_ctx, const char *name,
 
 /* The following definitions come from lib/sharesec.c  */
 
+bool share_info_db_init(void);
 SEC_DESC *get_share_security_default( TALLOC_CTX *ctx, size_t *psize, uint32 def_access);
 SEC_DESC *get_share_security( TALLOC_CTX *ctx, const char *servicename,
                              size_t *psize);
index a1d30f1d2b47431eac6ffaf161f84aa956150a1c..799d983c8210ff1315e2b29aac2243a6ddef4f74 100644 (file)
@@ -37,7 +37,7 @@ static int delete_fn(struct db_record *rec, void *priv)
        return 0;
 }
 
-static bool share_info_db_init(void)
+bool share_info_db_init(void)
 {
        const char *vstring = "INFO/version";
        int32 vers_id;
index ace3124842d38862350673c3e039c26abe2fbc37..09ad8d8ea55af057d8fea68b266929d1c5b634d2 100644 (file)
@@ -1218,6 +1218,15 @@ extern void build_options(bool screen);
                return -1;
        }
 
+       /* Open the share_info.tdb here, so we don't have to open
+          after the fork on every single connection.  This is a small
+          performance improvment and reduces the total number of system
+          fds used. */
+       if (!share_info_db_init()) {
+               DEBUG(0,("ERROR: failed to load share info db.\n"));
+               exit(1);
+       }
+
        /* only start the background queue daemon if we are 
           running as a daemon -- bad things will happen if
           smbd is launched via inetd and we fork a copy of