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  Changes    Path
  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 -14    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.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 <stdarg.h>
  -#include <pthread.h>
   
   #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_pool;
   
  -    (void) pthread_mutex_unlock(&alloc_mutex);
  +    (void) ap_thread_mutex_unlock(alloc_mutex);
       return (pool *)new_pool;
   }
   
  @@ -573,6 +573,11 @@
       return permanent_pool;
   }
   
  +void ap_child_init_alloc(void)
  +{
  +    alloc_mutex = ap_thread_mutex_new();
  +}
  +
   API_EXPORT(void) ap_clear_pool(struct pool *a)
   {
   
  @@ -607,7 +612,7 @@
   {
       ap_clear_pool(a);
   
  -    (void) pthread_mutex_lock(&alloc_mutex);
  +    (void) ap_thread_mutex_lock(alloc_mutex);
       if (a->parent) {
        if (a->parent->sub_pools == a)
            a->parent->sub_pools = a->sub_next;
  @@ -616,7 +621,7 @@
        if (a->sub_next)
            a->sub_next->sub_prev = a->sub_prev;
       }
  -    (void) pthread_mutex_unlock(&alloc_mutex);
  +    (void) ap_thread_mutex_unlock(alloc_mutex);
   
       free_blocks(a->thread_root, a->first);
   }
  @@ -913,9 +918,9 @@
       cur_len = strp - blok->h.first_avail;
   
       /* must try another blok */
  -    (void) pthread_mutex_lock(&alloc_mutex);
  +    (void) ap_thread_mutex_lock(alloc_mutex);
       nblok = new_block(2 * cur_len);
  -    (void) pthread_mutex_unlock(&alloc_mutex);
  +    (void) ap_thread_mutex_unlock(alloc_mutex);
       memcpy(nblok->h.first_avail, blok->h.first_avail, cur_len);
       ps->vbuff.curpos = nblok->h.first_avail + cur_len;
       /* save a byte for the NUL terminator */
  @@ -924,10 +929,10 @@
       /* did we allocate the current blok? if so free it up */
       if (ps->got_a_new_block) {
        debug_fill(blok->h.first_avail, blok->h.endp - blok->h.first_avail);
  -     (void) pthread_mutex_lock(&alloc_mutex);
  +     (void) ap_thread_mutex_lock(alloc_mutex);
        blok->h.next = block_freelist;
        block_freelist = blok;
  -     (void) pthread_mutex_unlock(&alloc_mutex);
  +     (void) ap_thread_mutex_unlock(alloc_mutex);
       }
       ps->blok = nblok;
       ps->got_a_new_block = 1;
  
  
  
  1.2       +3 -0      apache-2.0/mpm/src/main/http_config.c
  
  Index: http_config.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/mpm/src/main/http_config.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- http_config.c     1999/06/18 18:39:29     1.1
  +++ http_config.c     1999/06/20 21:12:50     1.2
  @@ -1503,6 +1503,9 @@
   {
       module *m;
   
  +    /* TODO: uh this seems ugly, is there a better way? */
  +    ap_child_init_alloc();
  +
       for (m = top_module; m; m = m->next)
        if (m->child_init)
            (*m->child_init) (pchild, s);
  
  
  
  1.4       +28 -0     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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- mpm_prefork.c     1999/06/20 11:19:47     1.3
  +++ mpm_prefork.c     1999/06/20 21:12:50     1.4
  @@ -96,6 +96,7 @@
   #include "http_core.h"               /* for get_remote_host */
   #include "http_connection.h"
   #include "scoreboard_prefork.h"
  +#include "ap_mpm.h"
   #ifdef USE_SHMGET_SCOREBOARD
   #include <sys/types.h>
   #include <sys/ipc.h>
  @@ -3962,6 +3963,33 @@
       ap_listeners = new;
       return NULL;
   }
  +
  +/* there are no threads in the prefork model, so the mutexes are
  +   nops. */
  +/* TODO: make these #defines to eliminate the function call */
  +
  +struct ap_thread_mutex {
  +    int dummy;
  +};
  +
  +API_EXPORT(ap_thread_mutex *) ap_thread_mutex_new(void)
  +{
  +    return malloc(sizeof(ap_thread_mutex));
  +}
  +
  +API_EXPORT(void) ap_thread_mutex_lock(ap_thread_mutex *mtx)
  +{
  +}
  +
  +API_EXPORT(void) ap_thread_mutex_unlock(ap_thread_mutex *mtx)
  +{
  +}
  +
  +API_EXPORT(void) ap_thread_mutex_destroy(ap_thread_mutex *mtx)
  +{
  +    free(mtx);
  +}
  +
   
   static const command_rec prefork_cmds[] = {
   { "User", set_user, NULL, RSRC_CONF, TAKE1,
  
  
  

Reply via email to