You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by aa...@apache.org on 2002/02/15 21:48:19 UTC

cvs commit: httpd-2.0/server/mpm/worker worker.c mpm_default.h

aaron       02/02/15 12:48:19

  Modified:    server   scoreboard.c
               include  scoreboard.h
               server/mpm/beos beos.c mpm_default.h
               server/mpm/netware mpm_netware.c mpm_default.h
               server/mpm/perchild perchild.c mpm_default.h
               server/mpm/prefork prefork.c mpm_default.h
               server/mpm/worker worker.c mpm_default.h
  Log:
  Implement new ScoreBoardFile directive logic. This affects how we
  create the scoreboard's shared memory segment. We now have the best of
  both worlds:
  
  if config specifies ScoreBoardFile
    create name-based shared memory, errors are fatal
  else /* we get to choose */
    create anonymous shared memory
    if ENOTIMPL
      create name-based shared memory from DEFAULT_SCOREBOARD
    else
      errors are fatal
  
  This gives us the flexibility to have anonymous shared memory (on platforms
  that support it) as well as name-based shared memory when third-party
  programs want access to our scoreboard.
  
  The ap_scoreboard_fname static variable is now owned by the scoreboard.c
  file, and no longer by the MPMs. The MPMs MUST NOT set ap_scoreboard_fname
  to a default, since that will override the default creation logic and
  only allow name-based segments.
  
  Submitted by:	Aaron Bannert
  Reviewed by:	Justin Erenkrantz
  
  Revision  Changes    Path
  1.56      +46 -24    httpd-2.0/server/scoreboard.c
  
  Index: scoreboard.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/scoreboard.c,v
  retrieving revision 1.55
  retrieving revision 1.56
  diff -u -r1.55 -r1.56
  --- scoreboard.c	1 Feb 2002 18:07:08 -0000	1.55
  +++ scoreboard.c	15 Feb 2002 20:48:18 -0000	1.56
  @@ -161,6 +161,31 @@
       ap_assert(more_storage == (char*)shared_score + scoreboard_size);
   }
   
  +/**
  + * Create a name-based scoreboard in the given pool using the
  + * given filename.
  + */
  +static apr_status_t create_namebased_scoreboard(apr_pool_t *pool,
  +                                                const char *fname)
  +{
  +#if APR_HAS_SHARED_MEMORY
  +    apr_status_t rv;
  +
  +    /* The shared memory file must not exist before we create the
  +     * segment. */
  +    apr_file_remove(fname, pool); /* ignore errors */
  +
  +    rv = apr_shm_create(&ap_scoreboard_shm, scoreboard_size, fname, pool);
  +    if (rv != APR_SUCCESS) {
  +        ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL,
  +                     "unable to create scoreboard "
  +                     "(name-based shared memory failure)");
  +        return rv;
  +    }
  +#endif /* APR_HAS_SHARED_MEMORY */
  +    return APR_SUCCESS;
  +}
  +
   /* ToDo: This function should be made to handle setting up 
    * a scoreboard shared between processes using any IPC technique, 
    * not just a shared memory segment
  @@ -183,35 +208,32 @@
           return rv;
       }
   
  -#ifndef WIN32
  -    rv = apr_shm_create(&ap_scoreboard_shm, scoreboard_size, fname,
  -                        global_pool);
  -    if ((rv != APR_SUCCESS) && (rv != APR_ENOTIMPL)) {
  -        ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL,
  -                     "Fatal error: could not create scoreboard "
  -                     "(using anonymous shared memory)");
  -        return rv;
  +    /* The config says to create a name-based shmem */
  +    if (ap_scoreboard_fname) {
  +        /* make sure it's an absolute pathname */
  +        fname = ap_server_root_relative(pconf, ap_scoreboard_fname);
  +
  +        return create_namebased_scoreboard(global_pool, fname);
       }
  -    if (rv == APR_ENOTIMPL) {
  -#else
  -    {
  -#endif
  -        if (ap_scoreboard_fname) {
  -            fname = ap_server_root_relative(global_pool, ap_scoreboard_fname);
  -            /* make sure the file doesn't exist before trying 
  -             * to create the segment. */
  -            apr_file_remove(fname, global_pool);
  -        }
  -        rv = apr_shm_create(&ap_scoreboard_shm, scoreboard_size, fname,
  -                            global_pool);
  -        if (rv != APR_SUCCESS) {
  +    else { /* config didn't specify, we get to choose shmem type */
  +        rv = apr_shm_create(&ap_scoreboard_shm, scoreboard_size, NULL,
  +                            global_pool); /* anonymous shared memory */
  +        if ((rv != APR_SUCCESS) && (rv != APR_ENOTIMPL)) {
               ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL,
  -                         "Fatal error: could not open(create) scoreboard");
  +                         "Unable to create scoreboard "
  +                         "(anonymous shared memory failure)");
               return rv;
           }
  +        /* Make up a filename and do name-based shmem */
  +        else if (rv == APR_ENOTIMPL) {
  +            /* Make sure it's an absolute pathname */
  +            ap_scoreboard_fname = DEFAULT_SCOREBOARD;
  +            fname = ap_server_root_relative(pconf, ap_scoreboard_fname);
  +
  +            return create_namebased_scoreboard(global_pool, fname);
  +        }
       }
  -    /* everything will be cleared shortly */
  -#endif
  +#endif /* APR_HAS_SHARED_MEMORY */
       return APR_SUCCESS;
   }
   
  
  
  
  1.40      +6 -0      httpd-2.0/include/scoreboard.h
  
  Index: scoreboard.h
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/include/scoreboard.h,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- scoreboard.h	30 Jan 2002 22:35:56 -0000	1.39
  +++ scoreboard.h	15 Feb 2002 20:48:18 -0000	1.40
  @@ -58,6 +58,7 @@
   
   #ifndef APACHE_SCOREBOARD_H
   #define APACHE_SCOREBOARD_H
  +
   #ifdef __cplusplus
   extern "C" {
   #endif
  @@ -74,6 +75,11 @@
   #include "apr_thread_proc.h"
   #include "apr_portable.h"
   #include "apr_shm.h"
  +
  +/* Scoreboard file, if there is one */
  +#ifndef DEFAULT_SCOREBOARD
  +#define DEFAULT_SCOREBOARD "logs/apache_runtime_status"
  +#endif
   
   /* Scoreboard info on a process is, for now, kept very brief --- 
    * just status value and pid (the latter so that the caretaker process
  
  
  
  1.84      +0 -3      httpd-2.0/server/mpm/beos/beos.c
  
  Index: beos.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/mpm/beos/beos.c,v
  retrieving revision 1.83
  retrieving revision 1.84
  diff -u -r1.83 -r1.84
  --- beos.c	1 Feb 2002 22:16:31 -0000	1.83
  +++ beos.c	15 Feb 2002 20:48:18 -0000	1.84
  @@ -762,8 +762,6 @@
       pconf = _pconf;
       ap_server_conf = s;
   
  -    ap_scoreboard_fname = DEFAULT_SCOREBOARD;
  -
       /* Increase the available pool of fd's.  This code from
        * Joe Kloss <jo...@be.com>
        */
  @@ -1032,7 +1030,6 @@
       ap_thread_limit = HARD_THREAD_LIMIT;
       ap_pid_fname = DEFAULT_PIDLOG;
       ap_max_requests_per_thread = DEFAULT_MAX_REQUESTS_PER_THREAD;
  -    ap_scoreboard_fname = DEFAULT_SCOREBOARD;
   
       apr_cpystrn(ap_coredump_dir, ap_server_root, sizeof(ap_coredump_dir));
   
  
  
  
  1.7       +0 -5      httpd-2.0/server/mpm/beos/mpm_default.h
  
  Index: mpm_default.h
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/mpm/beos/mpm_default.h,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- mpm_default.h	18 Dec 2001 13:48:53 -0000	1.6
  +++ mpm_default.h	15 Feb 2002 20:48:18 -0000	1.7
  @@ -101,11 +101,6 @@
   #define DEFAULT_PIDLOG "logs/httpd.pid"
   #endif
   
  -/* Scoreboard file, if there is one */
  -#ifndef DEFAULT_SCOREBOARD
  -#define DEFAULT_SCOREBOARD "logs/apache_runtime_status"
  -#endif
  -
   /*
    * Interval, in microseconds, between scoreboard maintenance.
    */
  
  
  
  1.34      +0 -1      httpd-2.0/server/mpm/netware/mpm_netware.c
  
  Index: mpm_netware.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/mpm/netware/mpm_netware.c,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- mpm_netware.c	13 Feb 2002 22:56:10 -0000	1.33
  +++ mpm_netware.c	15 Feb 2002 20:48:19 -0000	1.34
  @@ -971,7 +971,6 @@
       ap_threads_min_free = DEFAULT_MIN_FREE_THREADS;
       ap_threads_max_free = DEFAULT_MAX_FREE_THREADS;
       ap_threads_limit = HARD_THREAD_LIMIT;
  -    ap_scoreboard_fname = DEFAULT_SCOREBOARD;
       ap_max_requests_per_child = DEFAULT_MAX_REQUESTS_PER_CHILD;
       ap_extended_status = 0;
   
  
  
  
  1.6       +0 -5      httpd-2.0/server/mpm/netware/mpm_default.h
  
  Index: mpm_default.h
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/mpm/netware/mpm_default.h,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- mpm_default.h	19 Dec 2001 16:23:34 -0000	1.5
  +++ mpm_default.h	15 Feb 2002 20:48:19 -0000	1.6
  @@ -122,11 +122,6 @@
     #endif
   */
   
  -/* Scoreboard file, if there is one */
  -#ifndef DEFAULT_SCOREBOARD
  -#define DEFAULT_SCOREBOARD "logs/apache_runtime_status"
  -#endif
  -
   /* Where the main/parent process's pid is logged */
   /*#ifndef DEFAULT_PIDLOG
     #define DEFAULT_PIDLOG "logs/httpd.pid"
  
  
  
  1.109     +0 -1      httpd-2.0/server/mpm/perchild/perchild.c
  
  Index: perchild.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/mpm/perchild/perchild.c,v
  retrieving revision 1.108
  retrieving revision 1.109
  diff -u -r1.108 -r1.109
  --- perchild.c	5 Feb 2002 22:18:49 -0000	1.108
  +++ perchild.c	15 Feb 2002 20:48:19 -0000	1.109
  @@ -1493,7 +1493,6 @@
       max_spare_threads = DEFAULT_MAX_SPARE_THREAD;
       max_threads = thread_limit;
       ap_pid_fname = DEFAULT_PIDLOG;
  -    ap_scoreboard_fname = DEFAULT_SCOREBOARD;
       ap_lock_fname = DEFAULT_LOCKFILE;
       max_requests_per_child = DEFAULT_MAX_REQUESTS_PER_CHILD;
       curr_child_num = 0;
  
  
  
  1.9       +0 -5      httpd-2.0/server/mpm/perchild/mpm_default.h
  
  Index: mpm_default.h
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/mpm/perchild/mpm_default.h,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- mpm_default.h	18 Dec 2001 13:48:53 -0000	1.8
  +++ mpm_default.h	15 Feb 2002 20:48:19 -0000	1.9
  @@ -91,11 +91,6 @@
   #define DEFAULT_LOCKFILE "logs/accept.lock"
   #endif
   
  -/* Scoreboard file, if there is one */
  -#ifndef DEFAULT_SCOREBOARD
  -#define DEFAULT_SCOREBOARD "logs/apache_runtime_status"
  -#endif
  -
   /* Where the main/parent process's pid is logged */
   #ifndef DEFAULT_PIDLOG
   #define DEFAULT_PIDLOG "logs/httpd.pid"
  
  
  
  1.242     +0 -1      httpd-2.0/server/mpm/prefork/prefork.c
  
  Index: prefork.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/mpm/prefork/prefork.c,v
  retrieving revision 1.241
  retrieving revision 1.242
  diff -u -r1.241 -r1.242
  --- prefork.c	11 Feb 2002 23:20:15 -0000	1.241
  +++ prefork.c	15 Feb 2002 20:48:19 -0000	1.242
  @@ -1254,7 +1254,6 @@
       ap_daemons_max_free = DEFAULT_MAX_FREE_DAEMON;
       ap_daemons_limit = server_limit;
       ap_pid_fname = DEFAULT_PIDLOG;
  -    ap_scoreboard_fname = DEFAULT_SCOREBOARD;
       ap_lock_fname = DEFAULT_LOCKFILE;
       ap_max_requests_per_child = DEFAULT_MAX_REQUESTS_PER_CHILD;
       ap_extended_status = 0;
  
  
  
  1.8       +0 -5      httpd-2.0/server/mpm/prefork/mpm_default.h
  
  Index: mpm_default.h
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/mpm/prefork/mpm_default.h,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- mpm_default.h	18 Dec 2001 13:48:53 -0000	1.7
  +++ mpm_default.h	15 Feb 2002 20:48:19 -0000	1.8
  @@ -85,11 +85,6 @@
   #define DEFAULT_LOCKFILE "logs/accept.lock"
   #endif
   
  -/* Scoreboard file, if there is one */
  -#ifndef DEFAULT_SCOREBOARD
  -#define DEFAULT_SCOREBOARD "logs/apache_runtime_status"
  -#endif
  -
   /* Where the main/parent process's pid is logged */
   #ifndef DEFAULT_PIDLOG
   #define DEFAULT_PIDLOG "logs/httpd.pid"
  
  
  
  1.77      +0 -1      httpd-2.0/server/mpm/worker/worker.c
  
  Index: worker.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/mpm/worker/worker.c,v
  retrieving revision 1.76
  retrieving revision 1.77
  diff -u -r1.76 -r1.77
  --- worker.c	14 Feb 2002 02:48:19 -0000	1.76
  +++ worker.c	15 Feb 2002 20:48:19 -0000	1.77
  @@ -1582,7 +1582,6 @@
       ap_daemons_limit = server_limit;
       ap_threads_per_child = DEFAULT_THREADS_PER_CHILD;
       ap_pid_fname = DEFAULT_PIDLOG;
  -    ap_scoreboard_fname = DEFAULT_SCOREBOARD;
       ap_lock_fname = DEFAULT_LOCKFILE;
       ap_max_requests_per_child = DEFAULT_MAX_REQUESTS_PER_CHILD;
       ap_extended_status = 0;
  
  
  
  1.4       +0 -5      httpd-2.0/server/mpm/worker/mpm_default.h
  
  Index: mpm_default.h
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/mpm/worker/mpm_default.h,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- mpm_default.h	18 Dec 2001 13:48:54 -0000	1.3
  +++ mpm_default.h	15 Feb 2002 20:48:19 -0000	1.4
  @@ -89,11 +89,6 @@
   #define DEFAULT_LOCKFILE "logs/accept.lock"
   #endif
   
  -/* Scoreboard file, if there is one */
  -#ifndef DEFAULT_SCOREBOARD
  -#define DEFAULT_SCOREBOARD "logs/apache_runtime_status"
  -#endif
  -
   /* Where the main/parent process's pid is logged */
   #ifndef DEFAULT_PIDLOG
   #define DEFAULT_PIDLOG "logs/httpd.pid"