You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Ben Hyde <bh...@gensym.com> on 1997/12/17 17:01:44 UTC

[PATCH] Serialize the update to pool.sub_* in destroy_pool (take 2)

This patch superceeds <97...@gensym1.gensym.com>, aka 
  [PATCH] Serialize the update to pool.sub_* in destroy_pool.

Many people agree that it is a bummer if pool primitives require any
serialization and there is a proposal in the works to avoid it even for the
memory blocks that pools are assembled from.  In the meantime this patch stamps
out a race conditions in the existing code.

- 

This patch serializes access to the tree of pools when clearing a pool and when
deleting a subpool.

Additional gratuitous removal of an unnecessary assignment.

> cvs diff -u -b src/main/alloc.c
Index: src/main/alloc.c
===================================================================
RCS file: /cvs/apachen/src/main/alloc.c,v
retrieving revision 1.61
diff -u -b -r1.61 alloc.c
--- alloc.c	1997/12/14 20:48:54	1.61
+++ alloc.c	1997/12/17 17:01:05
@@ -376,11 +376,13 @@
 {
     block_alarms();
 
+    (void) acquire_mutex(alloc_mutex);
+    {
     while (a->sub_pools)
 	destroy_pool(a->sub_pools);
-
-    a->sub_pools = NULL;
-
+    }
+    (void) release_mutex(alloc_mutex);
+    /* Don't hold the mutex during cleanups. */
     run_cleanups(a->cleanups);
     a->cleanups = NULL;
     free_proc_chain(a->subprocesses);
@@ -413,6 +415,8 @@
     block_alarms();
     clear_pool(a);
 
+    (void) acquire_mutex(alloc_mutex);
+    {
     if (a->parent) {
 	if (a->parent->sub_pools == a)
 	    a->parent->sub_pools = a->sub_next;
@@ -421,6 +425,8 @@
 	if (a->sub_next)
 	    a->sub_next->sub_prev = a->sub_prev;
     }
+    }
+    (void) release_mutex(alloc_mutex);
 
     free_blocks(a->first);
     unblock_alarms();

Re: [PATCH] Serialize the update to pool.sub_* in destroy_pool (take 2)

Posted by Dean Gaudet <dg...@arctic.org>.
I'm happy with this for now, +1.  If you want to tackle the proper
thread_create() primitive which creates a parentless pool and places a
cleanup in the parent pool then that'd be great. 

Dean

On Wed, 17 Dec 1997, Ben Hyde wrote:

> This patch superceeds <97...@gensym1.gensym.com>, aka 
>   [PATCH] Serialize the update to pool.sub_* in destroy_pool.
> 
> Many people agree that it is a bummer if pool primitives require any
> serialization and there is a proposal in the works to avoid it even for the
> memory blocks that pools are assembled from.  In the meantime this patch stamps
> out a race conditions in the existing code.
> 
> - 
> 
> This patch serializes access to the tree of pools when clearing a pool and when
> deleting a subpool.
> 
> Additional gratuitous removal of an unnecessary assignment.
> 
> > cvs diff -u -b src/main/alloc.c
> Index: src/main/alloc.c
> ===================================================================
> RCS file: /cvs/apachen/src/main/alloc.c,v
> retrieving revision 1.61
> diff -u -b -r1.61 alloc.c
> --- alloc.c	1997/12/14 20:48:54	1.61
> +++ alloc.c	1997/12/17 17:01:05
> @@ -376,11 +376,13 @@
>  {
>      block_alarms();
>  
> +    (void) acquire_mutex(alloc_mutex);
> +    {
>      while (a->sub_pools)
>  	destroy_pool(a->sub_pools);
> -
> -    a->sub_pools = NULL;
> -
> +    }
> +    (void) release_mutex(alloc_mutex);
> +    /* Don't hold the mutex during cleanups. */
>      run_cleanups(a->cleanups);
>      a->cleanups = NULL;
>      free_proc_chain(a->subprocesses);
> @@ -413,6 +415,8 @@
>      block_alarms();
>      clear_pool(a);
>  
> +    (void) acquire_mutex(alloc_mutex);
> +    {
>      if (a->parent) {
>  	if (a->parent->sub_pools == a)
>  	    a->parent->sub_pools = a->sub_next;
> @@ -421,6 +425,8 @@
>  	if (a->sub_next)
>  	    a->sub_next->sub_prev = a->sub_prev;
>      }
> +    }
> +    (void) release_mutex(alloc_mutex);
>  
>      free_blocks(a->first);
>      unblock_alarms();
>