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/01 18:22:57 UTC

cvs commit: httpd-2.0/server scoreboard.c

aaron       02/02/01 09:22:57

  Modified:    server   scoreboard.c
  Log:
  Create the scoreboard (in the parent) in a global pool context, so it
  survives graceful restarts. This fixes a SEGV during graceful restarts.
  
  Children who attach to this scoreboard keep the same pool as before (pchild)
  since they should detach/unmap when the child process exits.
  
  Revision  Changes    Path
  1.54      +21 -4     httpd-2.0/server/scoreboard.c
  
  Index: scoreboard.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/scoreboard.c,v
  retrieving revision 1.53
  retrieving revision 1.54
  diff -u -r1.53 -r1.54
  --- scoreboard.c	30 Jan 2002 22:35:56 -0000	1.53
  +++ scoreboard.c	1 Feb 2002 17:22:57 -0000	1.54
  @@ -165,14 +165,27 @@
    * a scoreboard shared between processes using any IPC technique, 
    * not just a shared memory segment
    */
  -static apr_status_t open_scoreboard(apr_pool_t *p)
  +static apr_status_t open_scoreboard(apr_pool_t *pconf)
   {
   #if APR_HAS_SHARED_MEMORY
       apr_status_t rv;
       char *fname = NULL;
  +    apr_pool_t *global_pool;
  +
  +    /* We don't want to have to recreate the scoreboard after
  +     * restarts, so we'll create a global pool and never clean it.
  +     */
  +    rv = apr_pool_create(&global_pool, NULL);
  +    if (rv != APR_SUCCESS) {
  +        ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL,
  +                     "Fatal error: unable to create global pool "
  +                     "for use with by the scoreboard");
  +        return rv;
  +    }
   
   #ifndef WIN32
  -    rv = apr_shm_create(&ap_scoreboard_shm, scoreboard_size, fname, p);
  +    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 "
  @@ -184,9 +197,13 @@
       {
   #endif
           if (ap_scoreboard_fname) {
  -            fname = ap_server_root_relative(p, 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, p);
  +        rv = apr_shm_create(&ap_scoreboard_shm, scoreboard_size, fname,
  +                            global_pool);
           if (rv != APR_SUCCESS) {
               ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL,
                            "Fatal error: could not open(create) scoreboard");