Author: svn-role
Date: Tue May 14 04:02:25 2013
New Revision: 1482195
URL: http://svn.apache.org/r1482195
Log:
Reintegrate the 1.7.x-r1481010 branch:
* r1481010
Fix issue 4365, multi-threaded svnserve pool memory use after clear.
Justification:
Possible SEGV.
Branch: 1.7.x-r1481010
Votes:
+1: philip, danielsh, rhuijben
Modified:
subversion/branches/1.7.x/ (props changed)
subversion/branches/1.7.x/STATUS
subversion/branches/1.7.x/subversion/svnserve/main.c (contents, props
changed)
Propchange: subversion/branches/1.7.x/
------------------------------------------------------------------------------
Merged /subversion/trunk:r1481010
Merged /subversion/branches/1.7.x-r1481010:r1481034-1482194
Modified: subversion/branches/1.7.x/STATUS
URL:
http://svn.apache.org/viewvc/subversion/branches/1.7.x/STATUS?rev=1482195&r1=1482194&r2=1482195&view=diff
==============================================================================
--- subversion/branches/1.7.x/STATUS (original)
+++ subversion/branches/1.7.x/STATUS Tue May 14 04:02:25 2013
@@ -283,14 +283,6 @@ Veto-blocked changes:
Approved changes:
=================
- * r1481010
- Fix issue 4365, multi-threaded svnserve pool memory use after clear.
- Justification:
- Possible SEGV.
- Branch: 1.7.x-r1481010
- Votes:
- +1: philip, danielsh, rhuijben
-
* r1434405, r1434414, r1434418
Fix issue #4294 'diff --git shows wrong copy from'. Moving a dir
causes diff --git to output incorrect sources for the diff.
Modified: subversion/branches/1.7.x/subversion/svnserve/main.c
URL:
http://svn.apache.org/viewvc/subversion/branches/1.7.x/subversion/svnserve/main.c?rev=1482195&r1=1482194&r2=1482195&view=diff
==============================================================================
--- subversion/branches/1.7.x/subversion/svnserve/main.c (original)
+++ subversion/branches/1.7.x/subversion/svnserve/main.c Tue May 14 04:02:25
2013
@@ -51,6 +51,7 @@
#include "svn_private_config.h"
#include "private/svn_dep_compat.h"
+#include "private/svn_atomic.h"
#include "winservice.h"
#ifdef HAVE_UNISTD_H
@@ -342,11 +343,44 @@ static apr_status_t redirect_stdout(void
return apr_file_dup2(out_file, err_file, pool);
}
+#if APR_HAS_THREADS
+/* The pool passed to apr_thread_create can only be released when both
+
+ A: the call to apr_thread_create has returned to the calling thread
+ B: the new thread has started running and reached apr_thread_start_t
+
+ So we set the atomic counter to 2 then both the calling thread and
+ the new thread decrease it and when it reaches 0 the pool can be
+ released. */
+struct shared_pool_t {
+ svn_atomic_t count;
+ apr_pool_t *pool;
+};
+
+static struct shared_pool_t *
+attach_shared_pool(apr_pool_t *pool)
+{
+ struct shared_pool_t *shared = apr_palloc(pool, sizeof(struct
shared_pool_t));
+
+ shared->pool = pool;
+ svn_atomic_set(&shared->count, 2);
+
+ return shared;
+}
+
+static void
+release_shared_pool(struct shared_pool_t *shared)
+{
+ if (svn_atomic_dec(&shared->count) == 0)
+ svn_pool_destroy(shared->pool);
+}
+#endif
+
/* "Arguments" passed from the main thread to the connection thread */
struct serve_thread_t {
svn_ra_svn_conn_t *conn;
serve_params_t *params;
- apr_pool_t *pool;
+ struct shared_pool_t *shared_pool;
};
#if APR_HAS_THREADS
@@ -354,8 +388,8 @@ static void * APR_THREAD_FUNC serve_thre
{
struct serve_thread_t *d = data;
- svn_error_clear(serve(d->conn, d->params, d->pool));
- svn_pool_destroy(d->pool);
+ svn_error_clear(serve(d->conn, d->params, d->shared_pool->pool));
+ release_shared_pool(d->shared_pool);
return NULL;
}
@@ -420,6 +454,7 @@ int main(int argc, const char *argv[])
#if APR_HAS_THREADS
apr_threadattr_t *tattr;
apr_thread_t *tid;
+ struct shared_pool_t *shared_pool;
struct serve_thread_t *thread_data;
#endif
@@ -1011,6 +1046,7 @@ int main(int argc, const char *argv[])
particularly sophisticated strategy for a threaded server, it's
little different from forking one process per connection. */
#if APR_HAS_THREADS
+ shared_pool = attach_shared_pool(connection_pool);
status = apr_threadattr_create(&tattr, connection_pool);
if (status)
{
@@ -1030,9 +1066,9 @@ int main(int argc, const char *argv[])
thread_data = apr_palloc(connection_pool, sizeof(*thread_data));
thread_data->conn = conn;
thread_data->params = ¶ms;
- thread_data->pool = connection_pool;
+ thread_data->shared_pool = shared_pool;
status = apr_thread_create(&tid, tattr, serve_thread, thread_data,
- connection_pool);
+ shared_pool->pool);
if (status)
{
err = svn_error_wrap_apr(status, _("Can't create thread"));
@@ -1040,6 +1076,7 @@ int main(int argc, const char *argv[])
svn_error_clear(err);
exit(1);
}
+ release_shared_pool(shared_pool);
#endif
break;
Propchange: subversion/branches/1.7.x/subversion/svnserve/main.c
------------------------------------------------------------------------------
Merged
/subversion/branches/1.7.x-r1481010/subversion/svnserve/main.c:r1481034-1482194
Merged /subversion/trunk/subversion/svnserve/svnserve.c:r1481010