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 2014/03/26 17:18:35 UTC

svn commit: r1581906 - /subversion/trunk/subversion/svnserve/svnserve.c

Author: stefan2
Date: Wed Mar 26 16:18:34 2014
New Revision: 1581906

URL: http://svn.apache.org/r1581906
Log:
Simply APR memory pool handling in svnserve.  Allocate all connection_t
objects from the application's main pool instead of given them independent
root pools.  Since we (potentially) release connections in background
threads, the applications's root pool must be thread-safe.

* subversion/svnserve/svnserve.c
  (accept_connection): Allocate the new connection in a sub-pool of the
                       pool passed in - just following our standard pool
                       usage pattern.
  (close_connection): Pool destruction now uses standard code as well.
  (sub_main): We don't need the socket_pools anymore.  Update call to
              above sub-function.
  (main): Make sure the application's root pool is thread-safe.

Modified:
    subversion/trunk/subversion/svnserve/svnserve.c

Modified: subversion/trunk/subversion/svnserve/svnserve.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnserve/svnserve.c?rev=1581906&r1=1581905&r2=1581906&view=diff
==============================================================================
--- subversion/trunk/subversion/svnserve/svnserve.c (original)
+++ subversion/trunk/subversion/svnserve/svnserve.c Wed Mar 26 16:18:34 2014
@@ -441,9 +441,9 @@ static apr_status_t redirect_stdout(void
 static svn_error_t *
 accept_connection(connection_t **connection,
                   apr_socket_t *sock,
-                  svn_root_pools__t *connection_pools,
                   serve_params_t *params,
-                  enum connection_handling_mode handling_mode)
+                  enum connection_handling_mode handling_mode,
+                  apr_pool_t *pool)
 {
   apr_status_t status;
   
@@ -451,11 +451,10 @@ accept_connection(connection_t **connect
    *         the connection threads so it cannot clean up after each one.  So
    *         separate pools that can be cleared at thread exit are used. */
   
-  apr_pool_t *pool = svn_root_pools__acquire_pool(connection_pools);
-  *connection = apr_pcalloc(pool, sizeof(**connection));
-  (*connection)->pool = pool;
+  apr_pool_t *connection_pool = svn_pool_create(pool);
+  *connection = apr_pcalloc(connection_pool, sizeof(**connection));
+  (*connection)->pool = connection_pool;
   (*connection)->params = params;
-  (*connection)->root_pools = connection_pools;
   (*connection)->ref_count = 1;
   
   do
@@ -465,14 +464,15 @@ accept_connection(connection_t **connect
         exit(0);
       #endif
       
-      status = apr_socket_accept(&(*connection)->usock, sock, pool);
+      status = apr_socket_accept(&(*connection)->usock, sock,
+                                 connection_pool);
       if (handling_mode == connection_mode_fork)
         {
           apr_proc_t proc;
           
           /* Collect any zombie child processes. */
           while (apr_proc_wait_all_procs(&proc, NULL, NULL, APR_NOWAIT,
-            pool) == APR_CHILD_DONE)
+            connection_pool) == APR_CHILD_DONE)
             ;
         }
     }
@@ -502,7 +502,7 @@ close_connection(connection_t *connectio
 {
   /* this will automatically close USOCK */
   if (svn_atomic_dec(&connection->ref_count) == 0)
-    svn_root_pools__release_pool(connection->pool, connection->root_pools);
+    svn_pool_destroy(connection->pool);
 }
 
 /* Wrapper around serve() that takes a socket instead of a connection.
@@ -657,7 +657,6 @@ sub_main(int *exit_code, int argc, const
   const char *pid_filename = NULL;
   const char *log_filename = NULL;
   svn_node_kind_t kind;
-  svn_root_pools__t *socket_pools;
 
 #ifdef SVN_HAVE_SASL
   SVN_ERR(cyrus_init(pool));
@@ -1182,10 +1181,6 @@ sub_main(int *exit_code, int argc, const
     svn_cache_config_set(&settings);
   }
 
-  /* we use (and recycle) separate pools for sockets (many small ones)
-     and connections (fewer but larger ones) */
-  SVN_ERR(svn_root_pools__create(&socket_pools));
-
 #if APR_HAS_THREADS
   SVN_ERR(svn_root_pools__create(&connection_pools));
 
@@ -1217,8 +1212,8 @@ sub_main(int *exit_code, int argc, const
   while (1)
     {
       connection_t *connection = NULL;
-      SVN_ERR(accept_connection(&connection, sock, socket_pools, &params,
-                                handling_mode));
+      SVN_ERR(accept_connection(&connection, sock, &params, handling_mode,
+                                pool));
       if (run_mode == run_mode_listen_once)
         {
           err = serve_socket(connection, connection->pool);
@@ -1290,7 +1285,7 @@ main(int argc, const char *argv[])
     return EXIT_FAILURE;
 
   /* Create our top-level pool. */
-  pool = svn_pool_create(NULL);
+  pool = apr_allocator_owner_get(svn_pool_create_allocator(TRUE));
 
   err = sub_main(&exit_code, argc, argv, pool);