You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2013/11/13 00:35:30 UTC

svn commit: r1541317 - in /subversion/trunk/subversion/svnserve: serve.c server.h svnserve.c

Author: stefan2
Date: Tue Nov 12 23:35:30 2013
New Revision: 1541317

URL: http://svn.apache.org/r1541317
Log:
Switch svnserve to use the new object pool structures.

So far, this simply saves some runtime and memory.  Future commits
will enable svnserve to serve large numbers connections with a
limited number of threads in a round-robin scheme.

* subversion/svnserve/server.h
  (repository_t): the parameters are now stored with the repos_pool
  (serve_params_t): for the same reason, we drop caching flags;
                    add global object pools / factories to used

* subversion/svnserve/serve.c
  (load_pwdb_config): read data through a configuration object pool
  (load_authz_config): read data through an authz object pool
  (find_repos): accept and use the object pools
  (serve): update caller

* subversion/svnserve/svnserve.c
  (main): adapt to changed parameter struct;
          instantiate the object pools;
          use them

Modified:
    subversion/trunk/subversion/svnserve/serve.c
    subversion/trunk/subversion/svnserve/server.h
    subversion/trunk/subversion/svnserve/svnserve.c

Modified: subversion/trunk/subversion/svnserve/serve.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnserve/serve.c?rev=1541317&r1=1541316&r2=1541317&view=diff
==============================================================================
--- subversion/trunk/subversion/svnserve/serve.c (original)
+++ subversion/trunk/subversion/svnserve/serve.c Tue Nov 12 23:35:30 2013
@@ -202,12 +202,13 @@ log_authz_denied(const char *path,
   return logger__write(b->logger, line, strlen(line));
 }
 
-/* If CFG specifies a path to the password DB, read that DB and store it
- * in REPOSITORY->PWDB.
+/* If CFG specifies a path to the password DB, read that DB through
+ * CONFIG_POOL and store it in REPOSITORY->PWDB.
  */
 static svn_error_t *
 load_pwdb_config(repository_t *repository,
                  svn_config_t *cfg,
+                 svn_repos__config_pool_t *config_pool,
                  apr_pool_t *pool)
 {
   const char *pwdb_path;
@@ -223,8 +224,9 @@ load_pwdb_config(repository_t *repositor
       pwdb_path = svn_dirent_internal_style(pwdb_path, pool);
       pwdb_path = svn_dirent_join(repository->base, pwdb_path, pool);
 
-      err = svn_config_read3(&repository->pwdb, pwdb_path, TRUE,
-                             FALSE, FALSE, pool);
+      err = svn_repos__config_pool_get(&repository->pwdb, NULL, config_pool,
+                                       pwdb_path, TRUE, FALSE,
+                                       repository->repos, pool);
       if (err)
         {
           /* Because it may be possible to read the pwdb file with some
@@ -281,8 +283,8 @@ canonicalize_access_file(const char **ac
   return SVN_NO_ERROR;
 }
 
-/* Load the authz database for the listening server based on the
-   entries in the SERVER struct.
+/* Load the authz database for the listening server through AUTHZ_POOL
+   based on the entries in the SERVER struct.
 
    SERVER and CONN must not be NULL. The real errors will be logged with
    SERVER and CONN but return generic errors to the client. */
@@ -290,6 +292,7 @@ static svn_error_t *
 load_authz_config(repository_t *repository,
                   const char *repos_root,
                   svn_config_t *cfg,
+                  svn_repos__authz_pool_t *authz_pool,
                   apr_pool_t *pool)
 {
   const char *authzdb_path;
@@ -317,8 +320,9 @@ load_authz_config(repository_t *reposito
                                        repos_root, pool);
 
       if (!err)
-        err = svn_repos_authz_read2(&repository->authzdb, authzdb_path,
-                                    groupsdb_path, TRUE, pool);
+        err = svn_repos__authz_pool_get(&repository->authzdb, authz_pool,
+                                        authzdb_path, groupsdb_path, TRUE,
+                                        repository->repos, pool);
 
       if (err)
         return svn_error_create(SVN_ERR_AUTHZ_INVALID_CONFIG, err, NULL);
@@ -3264,11 +3268,17 @@ repos_path_valid(const char *path)
  * capabilities to CAPABILITIES, which must be at least as long-lived
  * as POOL, and whose elements are SVN_RA_CAPABILITY_*.  VHOST and
  * READ_ONLY flags are the same as in the server baton.
+ *
+ * CONFIG_POOL, AUTHZ_POOL and REPOS_POOL shall be used to load any
+ * object of the respective type.
  */
 static svn_error_t *find_repos(const char *url, const char *root,
                                svn_boolean_t vhost, svn_boolean_t read_only,
                                svn_config_t *cfg, repository_t *repository,
                                const apr_array_header_t *capabilities,
+                               svn_repos__config_pool_t *config_pool,
+                               svn_repos__authz_pool_t *authz_pool,
+                               svn_repos__repos_pool_t *repos_pool,
                                apr_pool_t *pool)
 {
   const char *path, *full_path, *repos_root, *fs_path, *hooks_env, *val;
@@ -3306,8 +3316,8 @@ static svn_error_t *find_repos(const cha
                              "No repository found in '%s'", url);
 
   /* Open the repository and fill in b with the resulting information. */
-  SVN_ERR(svn_repos_open2(&repository->repos, repos_root,
-                          repository->fs_config, pool));
+  SVN_ERR(svn_repos__repos_pool_get(&repository->repos, repos_pool,
+                                    repos_root, "", pool));
   SVN_ERR(svn_repos_remember_client_capabilities(repository->repos,
                                                  capabilities));
   repository->fs = svn_repos_fs(repository->repos);
@@ -3339,8 +3349,8 @@ static svn_error_t *find_repos(const cha
                                pool));
     }
 
-  SVN_ERR(load_pwdb_config(repository, cfg, pool));
-  SVN_ERR(load_authz_config(repository, repos_root, cfg, pool));
+  SVN_ERR(load_pwdb_config(repository, cfg, config_pool, pool));
+  SVN_ERR(load_authz_config(repository, repos_root, cfg, authz_pool, pool));
 
 #ifdef SVN_HAVE_SASL
   /* Should we use Cyrus SASL? */
@@ -3573,15 +3583,6 @@ svn_error_t *serve(svn_ra_svn_conn_t *co
   b.logger = params->logger;
   b.client_info = get_client_info(conn, params, pool);
 
-  /* construct FS configuration parameters */
-  repository.fs_config = apr_hash_make(pool);
-  svn_hash_sets(repository.fs_config, SVN_FS_CONFIG_FSFS_CACHE_DELTAS,
-                params->cache_txdeltas ? "1" :"0");
-  svn_hash_sets(repository.fs_config, SVN_FS_CONFIG_FSFS_CACHE_FULLTEXTS,
-                params->cache_fulltexts ? "1" :"0");
-  svn_hash_sets(repository.fs_config, SVN_FS_CONFIG_FSFS_CACHE_REVPROPS,
-                params->cache_revprops ? "1" :"0");
-
   /* Send greeting.  We don't support version 1 any more, so we can
    * send an empty mechlist. */
   if (params->compression_level > 0)
@@ -3665,7 +3666,10 @@ svn_error_t *serve(svn_ra_svn_conn_t *co
   err = handle_config_error(find_repos(client_url, params->root,
                                        b.vhost, b.read_only,
                                        params->cfg, b.repository,
-                                       cap_words, pool), &b);
+                                       cap_words, params->config_pool,
+                                       params->authz_pool, params->repos_pool,
+                                       pool),
+                            &b);
   if (!err)
     {
       if (repository.anon_access == NO_ACCESS

Modified: subversion/trunk/subversion/svnserve/server.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnserve/server.h?rev=1541317&r1=1541316&r2=1541317&view=diff
==============================================================================
--- subversion/trunk/subversion/svnserve/server.h (original)
+++ subversion/trunk/subversion/svnserve/server.h Tue Nov 12 23:35:30 2013
@@ -37,7 +37,8 @@ extern "C" {
 #include "svn_ra_svn.h"
 
 #include "private/svn_mutex.h"
-
+#include "private/svn_repos_private.h"
+  
 enum username_case_type { CASE_FORCE_UPPER, CASE_FORCE_LOWER, CASE_ASIS };
 
 enum authn_type { UNAUTHENTICATED, AUTHENTICATED };
@@ -54,7 +55,6 @@ typedef struct repository_t {
   const char *realm;       /* Authentication realm */
   const char *repos_url;   /* URL to base of repository */
   svn_stringbuf_t *fs_path;/* Decoded base in-repos path (w/ leading slash) */
-  apr_hash_t *fs_config;   /* Additional FS configuration parameters */
   enum username_case_type username_case; /* Case-normalize the username? */
   svn_boolean_t use_sasl;  /* Use Cyrus SASL for authentication;
                               always false if SVN_HAVE_SASL not defined */
@@ -115,17 +115,17 @@ typedef struct serve_params_t {
   /* logging data structure; possibly NULL. */
   struct logger_t *logger;
 
-  /* Username case normalization style. */
-  enum username_case_type username_case;
+  /* all configurations should be opened through this factory */
+  svn_repos__config_pool_t *config_pool;
 
-  /* Enable text delta caching for all FSFS repositories. */
-  svn_boolean_t cache_txdeltas;
+  /* all authz data should be opened through this factory */
+  svn_repos__authz_pool_t *authz_pool;
 
-  /* Enable full-text caching for all FSFS repositories. */
-  svn_boolean_t cache_fulltexts;
+  /* all repositories should be opened through this factory */
+  svn_repos__repos_pool_t *repos_pool;
 
-  /* Enable revprop caching for all FSFS repositories. */
-  svn_boolean_t cache_revprops;
+  /* Username case normalization style. */
+  enum username_case_type username_case;
 
   /* Size of the in-memory cache (used by FSFS only). */
   apr_uint64_t memory_cache_size;

Modified: subversion/trunk/subversion/svnserve/svnserve.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnserve/svnserve.c?rev=1541317&r1=1541316&r2=1541317&view=diff
==============================================================================
--- subversion/trunk/subversion/svnserve/svnserve.c (original)
+++ subversion/trunk/subversion/svnserve/svnserve.c Tue Nov 12 23:35:30 2013
@@ -48,6 +48,7 @@
 #include "svn_cache_config.h"
 #include "svn_version.h"
 #include "svn_io.h"
+#include "svn_hash.h"
 
 #include "svn_private_config.h"
 
@@ -616,7 +617,12 @@ int main(int argc, const char *argv[])
   apr_thread_t *tid;
 #endif
 #endif
+  svn_boolean_t is_multi_threaded;
   enum connection_handling_mode handling_mode = CONNECTION_DEFAULT;
+  apr_hash_t *fs_config = NULL;
+  svn_boolean_t cache_fulltexts = TRUE;
+  svn_boolean_t cache_txdeltas = TRUE;
+  svn_boolean_t cache_revprops = FALSE;
   apr_uint16_t port = SVN_RA_SVN_PORT;
   const char *host = NULL;
   int family = APR_INET;
@@ -667,12 +673,12 @@ int main(int argc, const char *argv[])
   params.cfg = NULL;
   params.compression_level = SVN_DELTA_COMPRESSION_LEVEL_DEFAULT;
   params.logger = NULL;
+  params.config_pool = NULL;
+  params.authz_pool = NULL;
+  params.repos_pool = NULL;
   params.vhost = FALSE;
   params.username_case = CASE_ASIS;
   params.memory_cache_size = (apr_uint64_t)-1;
-  params.cache_fulltexts = TRUE;
-  params.cache_txdeltas = TRUE;
-  params.cache_revprops = FALSE;
   params.zero_copy_limit = 0;
   params.error_check_interval = 4096;
 
@@ -809,18 +815,15 @@ int main(int argc, const char *argv[])
           break;
 
         case SVNSERVE_OPT_CACHE_TXDELTAS:
-          params.cache_txdeltas
-             = svn_tristate__from_word(arg) == svn_tristate_true;
+          cache_txdeltas = svn_tristate__from_word(arg) == svn_tristate_true;
           break;
 
         case SVNSERVE_OPT_CACHE_FULLTEXTS:
-          params.cache_fulltexts
-             = svn_tristate__from_word(arg) == svn_tristate_true;
+          cache_fulltexts = svn_tristate__from_word(arg) == svn_tristate_true;
           break;
 
         case SVNSERVE_OPT_CACHE_REVPROPS:
-          params.cache_revprops
-             = svn_tristate__from_word(arg) == svn_tristate_true;
+          cache_revprops = svn_tristate__from_word(arg) == svn_tristate_true;
           break;
 
         case SVNSERVE_OPT_CLIENT_SPEED:
@@ -908,17 +911,41 @@ int main(int argc, const char *argv[])
       usage(argv[0], pool);
     }
 
+  /* construct object pools */
+  is_multi_threaded = handling_mode == connection_mode_thread;
+  fs_config = apr_hash_make(pool);
+  svn_hash_sets(fs_config, SVN_FS_CONFIG_FSFS_CACHE_DELTAS,
+                cache_txdeltas ? "1" :"0");
+  svn_hash_sets(fs_config, SVN_FS_CONFIG_FSFS_CACHE_FULLTEXTS,
+                cache_fulltexts ? "1" :"0");
+  svn_hash_sets(fs_config, SVN_FS_CONFIG_FSFS_CACHE_REVPROPS,
+                cache_revprops ? "1" :"0");
+
+  SVN_INT_ERR(svn_repos__config_pool_create(&params.config_pool,
+                                            is_multi_threaded,
+                                            pool));
+  SVN_INT_ERR(svn_repos__authz_pool_create(&params.authz_pool,
+                                           params.config_pool,
+                                           is_multi_threaded,
+                                           pool));
+  SVN_INT_ERR(svn_repos__repos_pool_create(&params.repos_pool,
+                                           fs_config,
+                                           is_multi_threaded,
+                                           pool));
+  
   /* If a configuration file is specified, load it and any referenced
    * password and authorization files. */
   if (config_filename)
     {
       params.base = svn_dirent_dirname(config_filename, pool);
 
-      SVN_INT_ERR(svn_config_read3(&params.cfg, config_filename,
-                                   TRUE, /* must_exist */
-                                   FALSE, /* section_names_case_sensitive */
-                                   FALSE, /* option_names_case_sensitive */
-                                   pool));
+      SVN_INT_ERR(svn_repos__config_pool_get(&params.cfg, NULL,
+                                             params.config_pool,
+                                             config_filename, 
+                                             TRUE, /* must_exist */
+                                             FALSE, /* names_case_sensitive */
+                                             NULL,
+                                             pool));
     }
 
   if (log_filename)