cvs commit: apache-2.0/mpm/src/main alloc.c

1999-08-06 Thread dgaudet
dgaudet 99/08/05 18:56:25

  Modified:mpm/src/main alloc.c
  Log:
  Remove a difference with 1.3's alloc.c ... the root_pool stuff was an
  experiment I tried with apache-nspr, and it really didn't win much.
  The idea was to have a free list per thread.  But in practice that's
  too many free lists, too much memory sitting around doing squat.  If
  we have lock contention on the alloc mutex then we might consider a
  handful, say 8, free lists, and use tid % 8 to figure out which one
  to go after.
  
  Revision  ChangesPath
  1.7   +23 -50apache-2.0/mpm/src/main/alloc.c
  
  Index: alloc.c
  ===
  RCS file: /home/cvs/apache-2.0/mpm/src/main/alloc.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- alloc.c   1999/07/06 21:32:09 1.6
  +++ alloc.c   1999/08/06 01:56:25 1.7
  @@ -179,7 +179,6 @@
   
   struct process_chain;
   struct cleanup;
  -struct root_pool;
   
   struct pool {
   union block_hdr *first;
  @@ -190,7 +189,6 @@
   struct pool *sub_next;
   struct pool *sub_prev;
   struct pool *parent;
  -struct root_pool *thread_root;   /* the root pool for this thread */
   char *free_first_avail;
   #ifdef ALLOC_USE_MALLOC
   void *allocation_list;
  @@ -200,13 +198,6 @@
   #endif
   };
   
  -/* there's really no difference between a root_pool and a regular pool
  - * at the moment.
  - */
  -typedef struct root_pool {
  -struct pool p;
  -} root_pool;
  -
   
   static union block_hdr *block_freelist = NULL;
   static ap_thread_mutex *alloc_mutex;
  @@ -320,7 +311,7 @@
   #endif
   
   
  -static void free_blocks(root_pool *root,union block_hdr *blok)
  +static void free_blocks(union block_hdr *blok)
   {
   #ifdef ALLOC_USE_MALLOC
   union block_hdr *next;
  @@ -422,7 +413,7 @@
   return blok;
   }
   
  -static ap_inline union block_hdr *new_local_block(root_pool *root, int 
min_size)
  +static ap_inline union block_hdr *new_local_block(int min_size)
   {
   union block_hdr *blok;
   
  @@ -465,32 +456,6 @@
* gets taken off the parent's sub-pool list...
*/
   
  -#define ROOT_HDR_CLICKS (1 + ((sizeof(struct root_pool) - 1) / CLICK_SZ))
  -#define ROOT_HDR_BYTES (ROOT_HDR_CLICKS * CLICK_SZ)
  -
  -API_EXPORT(struct pool *) ap_make_root_pool(void)
  -{
  -union block_hdr *blok;
  -root_pool *new_pool;
  -
  -(void) ap_thread_mutex_lock(alloc_mutex);
  -
  -blok = new_block(ROOT_HDR_BYTES);
  -new_pool = (root_pool *) blok->h.first_avail;
  -blok->h.first_avail += ROOT_HDR_BYTES;
  -#ifdef POOL_DEBUG
  -blok->h.owning_pool = &(new_pool->p);
  -#endif
  -
  -memset(new_pool, 0, sizeof(*new_pool));
  -new_pool->p.free_first_avail = blok->h.first_avail;
  -new_pool->p.first = new_pool->p.last = blok;
  -new_pool->p.thread_root = new_pool;
  -
  -(void) ap_thread_mutex_unlock(alloc_mutex);
  -return (pool *)new_pool;
  -}
  -
   static pool *permanent_pool;
   
   /* Each pool structure is allocated in the start of its own first block,
  @@ -508,7 +473,7 @@
   union block_hdr *blok;
   pool *new_pool;
   
  -blok = new_local_block(p->thread_root, POOL_HDR_BYTES);
  +blok = new_local_block(POOL_HDR_BYTES);
   new_pool = (pool *) blok->h.first_avail;
   blok->h.first_avail += POOL_HDR_BYTES;
   #ifdef POOL_DEBUG
  @@ -519,12 +484,13 @@
   new_pool->free_first_avail = blok->h.first_avail;
   new_pool->first = new_pool->last = blok;
   
  -new_pool->thread_root = p->thread_root;
  -new_pool->parent = p;
  -new_pool->sub_next = p->sub_pools;
  -if (new_pool->sub_next)
  -  new_pool->sub_next->sub_prev = new_pool;
  -p->sub_pools = new_pool;
  +if (p) {
  + new_pool->parent = p;
  + new_pool->sub_next = p->sub_pools;
  + if (new_pool->sub_next)
  + new_pool->sub_next->sub_prev = new_pool;
  + p->sub_pools = new_pool;
  +}
   
   return new_pool;
   }
  @@ -569,7 +535,7 @@
   #ifdef WIN32
   spawn_mutex = ap_thread_mutex_new();
   #endif
  -permanent_pool = ap_make_root_pool();
  +permanent_pool = ap_make_sub_pool(NULL);
   #ifdef ALLOC_STATS
   atexit(dump_stats);
   #endif
  @@ -591,7 +557,7 @@
   a->cleanups = NULL;
   free_proc_chain(a->subprocesses);
   a->subprocesses = NULL;
  -free_blocks(a->thread_root, a->first->h.next);
  +free_blocks(a->first->h.next);
   a->first->h.next = NULL;
   
   a->last = a->first;
  @@ -616,6 +582,15 @@
   {
   ap_clear_pool(a);
   
  +/* XXX: I don't think this mutex is required here.  In theory,
  + our plan is that upon thread creation, the creator thread
  + will create a pool A which it will hand the created thread.
  + The created thread then can create any subpools of A it
  + wants, and it doesn't need any locks to do this... and it
  + can destroy any subpool of A it desires -- it

cvs commit: apache-2.0/mpm/src/main alloc.c mpm_prefork.c

1999-06-20 Thread dgaudet
dgaudet 99/06/20 14:46:14

  Modified:mpm/src  CHANGES
   mpm/src/include alloc.h
   mpm/src/main alloc.c mpm_prefork.c
  Log:
  remove 1.3 timeout code; SIGUSR1/SIGHUP/SIGTERM working again
  
  Revision  ChangesPath
  1.7   +3 -0  apache-2.0/mpm/src/CHANGES
  
  Index: CHANGES
  ===
  RCS file: /home/cvs/apache-2.0/mpm/src/CHANGES,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- CHANGES   1999/06/20 21:12:47 1.6
  +++ CHANGES   1999/06/20 21:46:11 1.7
  @@ -1,5 +1,8 @@
   Changes with MPM
   
  +* mpm_prefork: throw away all the alarm/timeout crud; and clean up the
  +  signal handling for the new world order.  [Dean Gaudet]
  +
   * Crude ap_thread_mutex abstraction so that we get the pthread stuff out
 of alloc.c for now. [Dean Gaudet]
   
  
  
  
  1.2   +0 -22 apache-2.0/mpm/src/include/alloc.h
  
  Index: alloc.h
  ===
  RCS file: /home/cvs/apache-2.0/mpm/src/include/alloc.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- alloc.h   1999/06/18 18:39:27 1.1
  +++ alloc.h   1999/06/20 21:46:12 1.2
  @@ -287,10 +287,6 @@
*
* Cleanups are identified for purposes of finding & running them off by the
* plain_cleanup and data, which should presumably be unique.
  - *
  - * NB any code which invokes register_cleanup or kill_cleanup directly
  - * is a critical section which should be guarded by block_alarms() and
  - * unblock_alarms() below...
*/
   
   API_EXPORT(void) ap_register_cleanup(pool *p, void *data,
  @@ -303,24 +299,6 @@
   /* A "do-nothing" cleanup, for register_cleanup; it's faster to do
* things this way than to test for NULL. */
   API_EXPORT_NONSTD(void) ap_null_cleanup(void *data);
  -
  -/* The time between when a resource is actually allocated, and when it
  - * its cleanup is registered is a critical section, during which the
  - * resource could leak if we got interrupted or timed out.  So, anything
  - * which registers cleanups should bracket resource allocation and the
  - * cleanup registry with these.  (This is done internally by run_cleanup).
  - *
  - * NB they are actually implemented in http_main.c, since they are bound
  - * up with timeout handling in general...
  - */
  -
  -#ifdef TPF
  -#define ap_block_alarms() (0)
  -#define ap_unblock_alarms() (0)
  -#else
  -API_EXPORT(void) ap_block_alarms(void);
  -API_EXPORT(void) ap_unblock_alarms(void);
  -#endif /* TPF */
   
   /* Common cases which want utility support..
* the note_cleanups_for_foo routines are for 
  
  
  
  1.3   +4 -4  apache-2.0/mpm/src/main/alloc.c
  
  Index: alloc.c
  ===
  RCS file: /home/cvs/apache-2.0/mpm/src/main/alloc.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- alloc.c   1999/06/20 21:12:49 1.2
  +++ alloc.c   1999/06/20 21:46:12 1.3
  @@ -303,7 +303,7 @@
   #define test_is_free(_x)
   #endif
   
  -/* Free a chain of blocks --- must be called with alarms blocked. */
  +/* Free a chain of blocks --- must be called with mutex held. */
   #ifdef POOL_DEBUG
   #define reset_block(b) do { \
   test_is_free(b); \
  @@ -383,7 +383,7 @@
   
   
   /* Get a new block, from our own free list if possible, from the system
  - * if necessary.  Must be called with alarms blocked.
  + * if necessary.  Must be called with mutex held.
*/
   
   static union block_hdr *new_block(int min_size)
  @@ -873,8 +873,8 @@
* until all the output is done.
*
* Note that this is completely safe because nothing else can
  - * allocate in this pool while ap_psprintf is running.  alarms are
  - * blocked, and the only thing outside of alloc.c that's invoked
  + * allocate in this pool while ap_psprintf is running. 
  + * The only thing outside of alloc.c that's invoked
* is ap_vformatter -- which was purposefully written to be
* self-contained with no callouts.
*/
  
  
  
  1.5   +21 -348   apache-2.0/mpm/src/main/mpm_prefork.c
  
  Index: mpm_prefork.c
  ===
  RCS file: /home/cvs/apache-2.0/mpm/src/main/mpm_prefork.c,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- mpm_prefork.c 1999/06/20 21:12:50 1.4
  +++ mpm_prefork.c 1999/06/20 21:46:13 1.5
  @@ -82,7 +82,6 @@
* TODO: behave like apache-1.3... here's a short list of things I think
* TODO: need cleaning up still:
* TODO: - use ralf's mm stuff for the shared mem and mutexes
  - * TODO: - eliminate the timeout stuff... 2.0 timeouts are part of the BUFF
* TODO: - abstract the Listen stuff, it's going to be common with other MPM
* TODO: - clean up scoreboard stuff when we figure out how 

cvs commit: apache-2.0/mpm/src/main alloc.c http_config.c mpm_prefork.c

1999-06-20 Thread dgaudet
dgaudet 99/06/20 14:12:51

  Modified:mpm/src  CHANGES Configuration.mpm Configure
   mpm/src/include ap_mpm.h
   mpm/src/main alloc.c http_config.c mpm_prefork.c
  Log:
  crude ap_thread_mutex abstraction
  
  Revision  ChangesPath
  1.6   +3 -0  apache-2.0/mpm/src/CHANGES
  
  Index: CHANGES
  ===
  RCS file: /home/cvs/apache-2.0/mpm/src/CHANGES,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- CHANGES   1999/06/20 12:29:18 1.5
  +++ CHANGES   1999/06/20 21:12:47 1.6
  @@ -1,5 +1,8 @@
   Changes with MPM
   
  +* Crude ap_thread_mutex abstraction so that we get the pthread stuff out
  +  of alloc.c for now. [Dean Gaudet]
  +
   * Handle partial large writes correctly.
 [Ben Laurie]
   
  
  
  
  1.7   +1 -1  apache-2.0/mpm/src/Configuration.mpm
  
  Index: Configuration.mpm
  ===
  RCS file: /home/cvs/apache-2.0/mpm/src/Configuration.mpm,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Configuration.mpm 1999/06/20 15:59:56 1.6
  +++ Configuration.mpm 1999/06/20 21:12:47 1.7
  @@ -1,4 +1,4 @@
  -EXTRA_CFLAGS= -Wall #-pthread -D_THREAD_SAFE # Uncomment for FreeBSD
  +EXTRA_CFLAGS= -Wall
   EXTRA_LDFLAGS=
   EXTRA_LIBS=
   EXTRA_INCLUDES=
  
  
  
  1.3   +1 -1  apache-2.0/mpm/src/Configure
  
  Index: Configure
  ===
  RCS file: /home/cvs/apache-2.0/mpm/src/Configure,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Configure 1999/06/18 19:20:18 1.2
  +++ Configure 1999/06/20 21:12:48 1.3
  @@ -426,7 +426,7 @@
   *-linux2)
DEF_WANTHSREGEX=yes
OS='Linux'
  - CFLAGS="$CFLAGS -DLINUX=2 -pthread"
  + CFLAGS="$CFLAGS -DLINUX=2"
LIBS="$LIBS -lm"
;;
   *-linux1)
  
  
  
  1.2   +7 -0  apache-2.0/mpm/src/include/ap_mpm.h
  
  Index: ap_mpm.h
  ===
  RCS file: /home/cvs/apache-2.0/mpm/src/include/ap_mpm.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ap_mpm.h  1999/06/18 18:39:29 1.1
  +++ ap_mpm.h  1999/06/20 21:12:49 1.2
  @@ -66,6 +66,13 @@
  used by the connection loop */
   API_EXPORT(int) ap_mpm_graceful_stop(void);
   
  +/* a mutex which synchronizes threads within one process */
  +typedef struct ap_thread_mutex ap_thread_mutex;
  +API_EXPORT(ap_thread_mutex *) ap_thread_mutex_new(void);
  +API_EXPORT(void) ap_thread_mutex_lock(ap_thread_mutex *);
  +API_EXPORT(void) ap_thread_mutex_unlock(ap_thread_mutex *);
  +API_EXPORT(void) ap_thread_mutex_destroy(ap_thread_mutex *);
  +
   #ifdef HAS_OTHER_CHILD
   /*
* register an other_child -- a child which the main loop keeps track of
  
  
  
  1.2   +19 -14apache-2.0/mpm/src/main/alloc.c
  
  Index: alloc.c
  ===
  RCS file: /home/cvs/apache-2.0/mpm/src/main/alloc.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- alloc.c   1999/06/18 18:39:29 1.1
  +++ alloc.c   1999/06/20 21:12:49 1.2
  @@ -64,9 +64,9 @@
   
   #include "httpd.h"
   #include "http_log.h"
  +#include "ap_mpm.h"
   
   #include 
  -#include 
   
   #ifdef OS2
   #define INCL_DOS
  @@ -209,7 +209,7 @@
   
   
   static union block_hdr *block_freelist = NULL;
  -static pthread_mutex_t alloc_mutex = PTHREAD_MUTEX_INITIALIZER;
  +static ap_thread_mutex *alloc_mutex;
   #ifdef POOL_DEBUG
   static char *known_stack_point;
   static int stack_direction;
  @@ -343,7 +343,7 @@
   if (blok == NULL)
return; /* Sanity check --- freeing empty pool? */
   
  -(void) pthread_mutex_lock(&alloc_mutex);
  +(void) ap_thread_mutex_lock(alloc_mutex);
   old_free_list = block_freelist;
   block_freelist = blok;
   
  @@ -377,7 +377,7 @@
   num_blocks_freed += num_blocks;
   #endif
   
  -(void) pthread_mutex_unlock(&alloc_mutex);
  +(void) ap_thread_mutex_unlock(alloc_mutex);
   #endif
   }
   
  @@ -426,9 +426,9 @@
   {
   union block_hdr *blok;
   
  -(void) pthread_mutex_lock(&alloc_mutex);
  +(void) ap_thread_mutex_lock(alloc_mutex);
   blok = new_block(min_size);
  -(void) pthread_mutex_unlock(&alloc_mutex);
  +(void) ap_thread_mutex_unlock(alloc_mutex);
   return blok;
   }
   
  @@ -473,7 +473,7 @@
   union block_hdr *blok;
   root_pool *new_pool;
   
  -(void) pthread_mutex_lock(&alloc_mutex);
  +(void) ap_thread_mutex_lock(alloc_mutex);
   
   blok = new_block(ROOT_HDR_BYTES);
   new_pool = (root_pool *) blok->h.first_avail;
  @@ -487,7 +487,7 @@
   new_pool->p.first = new_pool->p.last = blok;
   new_pool->p.thread_root = new