httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From traw...@apache.org
Subject cvs commit: httpd-2.0/server scoreboard.c
Date Mon, 24 Dec 2001 13:18:44 GMT
trawick     01/12/24 05:18:44

  Modified:    server   scoreboard.c
  Log:
  The scoreboard is no longer created while we can write to
  stderr, so call ap_log_error() to note problems allocating
  the scoreboard.
  
  apr_shm_malloc() doesn't set any kind of error code, so don't
  try to reference errno.
  
  setup_shared() now returns an error code to its caller rather
  than exiting directly.  This isn't a complete fix, as
  ap_create_scoreboard() needs to do the same thing.  Currently,
  when we can't allocate the scoreboard we leave the mod_cgid
  daemon process stranded.
  
  Revision  Changes    Path
  1.42      +16 -17    httpd-2.0/server/scoreboard.c
  
  Index: scoreboard.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/scoreboard.c,v
  retrieving revision 1.41
  retrieving revision 1.42
  diff -u -r1.41 -r1.42
  --- scoreboard.c	2001/12/21 15:20:20	1.41
  +++ scoreboard.c	2001/12/24 13:18:44	1.42
  @@ -156,32 +156,29 @@
    * a scoreboard shared between processes using any IPC technique, 
    * not just a shared memory segment
    */
  -static void setup_shared(apr_pool_t *p)
  +static apr_status_t setup_shared(apr_pool_t *p)
   {
   #if APR_HAS_SHARED_MEMORY
  -    char buf[512];
  -    char errmsg[120];
       const char *fname;
       apr_status_t rv;
   
       fname = ap_server_root_relative(p, ap_scoreboard_fname);
       rv = apr_shm_init(&scoreboard_shm, scoreboard_size, fname, p);
       if (rv != APR_SUCCESS) {
  -        apr_snprintf(buf, sizeof(buf), "%s: could not open(create) scoreboard: (%d)%s",
  -                    ap_server_argv0, rv, apr_strerror(rv, errmsg, sizeof errmsg));
  -        fprintf(stderr, "%s\n", buf);
  -        exit(APEXIT_INIT);
  +        ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL,
  +                     "Fatal error: could not open(create) scoreboard");
  +        return rv;
       }
       ap_scoreboard_image = apr_shm_malloc(scoreboard_shm, scoreboard_size);
       if (ap_scoreboard_image == NULL) {
  -        apr_snprintf(buf, sizeof(buf), "%s: cannot allocate scoreboard",
  -                    ap_server_argv0);
  -        perror(buf); /* o.k. since MM sets errno */
  +        ap_log_error(APLOG_MARK, APLOG_CRIT | APLOG_NOERRNO, 0, NULL,
  +                     "Fatal error: cannot allocate scoreboard");
           apr_shm_destroy(scoreboard_shm);
  -        exit(APEXIT_INIT);
  +        return APR_EGENERAL;
       }
       /* everything will be cleared shortly */
   #endif
  +    return APR_SUCCESS;
   }
   
   AP_DECLARE(void) reopen_scoreboard(apr_pool_t *p)
  @@ -214,22 +211,24 @@
   AP_DECLARE_NONSTD(void) ap_create_scoreboard(apr_pool_t *p, ap_scoreboard_e sb_type)
   {
       int running_gen = 0;
  +    apr_status_t rv;
  +
       if (ap_scoreboard_image)
   	running_gen = ap_scoreboard_image->global.running_generation;
       if (ap_scoreboard_image == NULL) {
           calc_scoreboard_size();
           if (sb_type == SB_SHARED) {
  -            setup_shared(p);
  +            rv = setup_shared(p);
  +            exit(APEXIT_INIT); /* XXX need to return an error from this function */
           }
           else {
               /* A simple malloc will suffice */
  -            char buf[512];
               ap_scoreboard_image = (scoreboard *) malloc(scoreboard_size);
               if (ap_scoreboard_image == NULL) {
  -                apr_snprintf(buf, sizeof(buf), "%s: cannot allocate scoreboard",
  -                             ap_server_argv0);
  -                perror(buf); /* o.k. since MM sets errno */
  -                exit(APEXIT_INIT);            
  +                ap_log_error(APLOG_MARK, APLOG_CRIT | APLOG_NOERRNO, 0, NULL,
  +                             "(%d)%s: cannot allocate scoreboard",
  +                             errno, strerror(errno));
  +                exit(APEXIT_INIT); /* XXX need to return an error from this function */
               }
           }
       }
  
  
  

Mime
View raw message