httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Cox <...@hyperreal.com>
Subject cvs commit: apache/src http_main.c scoreboard.h CHANGES
Date Mon, 25 Mar 1996 10:54:34 GMT
mjc         96/03/25 02:54:33

  Modified:    src       http_main.c scoreboard.h CHANGES
  Log:
  Reviewed by: Ben Laurie
  
  Changes to core Apache to allow a module to obtain information from the
  scoreboard (in file or memory).  Addition of an extra server BUSY state
  to distinguish between a "read request" and a "write response".  A
  define allows the addition of full instrumentation into the scoreboard
  
  Revision  Changes    Path
  1.10      +58 -1     apache/src/http_main.c
  
  Index: http_main.c
  ===================================================================
  RCS file: /export/home/cvs/apache/src/http_main.c,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -C3 -r1.9 -r1.10
  *** http_main.c	1996/03/18 01:55:38	1.9
  --- http_main.c	1996/03/25 10:54:29	1.10
  ***************
  *** 118,123 ****
  --- 118,124 ----
    int daemons_min_free;
    int daemons_max_free;
    int daemons_limit;
  + time_t restart_time;
    
    char server_root[MAX_STRING_LEN];
    char server_confname[MAX_STRING_LEN];
  ***************
  *** 658,666 ****
  --- 659,711 ----
    void update_child_status (int child_num, int status)
    {
        short_score new_score_rec;
  +     memcpy(&new_score_rec,&scoreboard_image[child_num],sizeof new_score_rec);
        new_score_rec.pid = getpid();
        new_score_rec.status = status;
    
  + #if defined(STATUS_INSTRUMENTATION)
  +     new_score_rec.last_used=time(NULL);
  + #endif
  + 
  + #if defined(HAVE_MMAP) || defined(HAVE_SHMGET)
  +     memcpy(&scoreboard_image[child_num], &new_score_rec, sizeof(short_score));
  + #else
  +     lseek (scoreboard_fd, (long)child_num * sizeof(short_score), 0);
  +     force_write (scoreboard_fd, (char*)&new_score_rec, sizeof(short_score));
  + #endif
  + }
  + 
  + int count_busy_servers ()
  + {
  +     int i;
  +     int res = 0;
  + 
  +     for (i = 0; i < HARD_SERVER_MAX; ++i)
  +       if (scoreboard_image[i].status == SERVER_BUSY_READ ||
  +               scoreboard_image[i].status == SERVER_BUSY_WRITE)
  +           ++res;
  +     return res;
  + }
  + 
  + short_score get_scoreboard_info(int i)
  + {
  +     return (scoreboard_image[i]);
  + }
  + 
  + #if defined(STATUS_INSTRUMENTATION)
  + void increment_counts (int child_num, request_rec *r)
  + {
  +     long int bs=0;
  +     short_score new_score_rec=scoreboard_image[child_num];
  + 
  +     if (r->sent_bodyct)
  +         bgetopt(r->connection->client, BO_BYTECT, &bs);
  + 
  +     new_score_rec.access_count ++;
  +     new_score_rec.bytes_served += (long)bs;
  + 
  +     times(&new_score_rec.times);
  + 
    #if defined(HAVE_MMAP) || defined(HAVE_SHMGET)
        memcpy(&scoreboard_image[child_num], &new_score_rec, sizeof(short_score));
    #else
  ***************
  *** 668,673 ****
  --- 713,719 ----
        force_write (scoreboard_fd, (char*)&new_score_rec, sizeof(short_score));
    #endif
    }
  + #endif
    
    int count_idle_servers ()
    {
  ***************
  *** 1074,1080 ****
    	    continue;
    	}
    	
  ! 	update_child_status (child_num, SERVER_BUSY);
    	conn_io = bcreate(ptrans, B_RDWR);
    	dupped_csd = csd;
    #if defined(NEED_DUPPED_CSD)
  --- 1120,1126 ----
    	    continue;
    	}
    	
  ! 	update_child_status (child_num, SERVER_BUSY_READ);
    	conn_io = bcreate(ptrans, B_RDWR);
    	dupped_csd = csd;
    #if defined(NEED_DUPPED_CSD)
  ***************
  *** 1090,1102 ****
  --- 1136,1158 ----
    				       (struct sockaddr_in *)&sa_server);
    	
    	r = read_request (current_conn);
  + 	update_child_status (child_num, SERVER_BUSY_WRITE);
    	if (r) process_request (r); /* else premature EOF --- ignore */
    
  + #if defined(STATUS_INSTRUMENTATION)
  +         if (r) increment_counts(child_num,r);
  + #endif
    	while (r && current_conn->keepalive) {
    	  bflush(conn_io);
    	  destroy_pool(r->pool);
  + 	  update_child_status (child_num, SERVER_BUSY_READ);
    	  r = read_request (current_conn);
  + 	  update_child_status (child_num, SERVER_BUSY_WRITE);
    	  if (r) process_request (r);
  + 
  + #if defined(STATUS_INSTRUMENTATION)
  + 	  if (r) increment_counts(child_num,r);
  + #endif
    	}
    	
    	if (bytes_in_pool (ptrans) > 80000)
  ***************
  *** 1210,1215 ****
  --- 1266,1272 ----
    	log_error ("SIGHUP received.  Attempting to restart", server_conf);
        }
        
  +     restart_time = time(NULL);
        clear_pool (pconf);
        ptrans = make_sub_pool (pconf);
        
  
  
  
  1.3       +14 -5     apache/src/scoreboard.h
  
  Index: scoreboard.h
  ===================================================================
  RCS file: /export/home/cvs/apache/src/scoreboard.h,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -C3 -r1.2 -r1.3
  *** scoreboard.h	1996/02/22 11:47:20	1.2
  --- scoreboard.h	1996/03/25 10:54:30	1.3
  ***************
  *** 51,56 ****
  --- 51,57 ----
     *
     */
    
  + #include <sys/times.h>
    
    /* Scoreboard info on a process is, for now, kept very brief --- 
     * just status value and pid (the latter so that the caretaker process
  ***************
  *** 61,75 ****
     *
     * Status values:
     */
  !    
  ! #define SERVER_DEAD 0		/* Unused scoreboard entry */
  ! #define SERVER_READY 1		/* Waiting for connection (or accept() lock) */
  ! #define SERVER_BUSY 2		/* Processing a client request */
  ! #define SERVER_STARTING 3	/* Launched, but not yet live */
    
    typedef struct {
        pid_t pid;
        char status;
    } short_score;
    
    /*
  --- 62,83 ----
     *
     * Status values:
     */
  ! 
  ! #define SERVER_DEAD 0
  ! #define SERVER_READY 1          /* Waiting for connection (or accept() lock) */
  ! #define SERVER_STARTING 3       /* Server Starting up */
  ! #define SERVER_BUSY_READ 2      /* Reading a client request */
  ! #define SERVER_BUSY_WRITE 4     /* Processing a client request */
    
    typedef struct {
        pid_t pid;
        char status;
  + #if defined(STATUS_INSTRUMENTATION)
  +     long access_count;
  +     long bytes_served;
  +     struct tms times;
  +     time_t last_used;
  + #endif
    } short_score;
    
    /*
  ***************
  *** 85,87 ****
  --- 93,96 ----
    
    #define HARD_SERVER_MAX 150
    
  + extern void sync_scoreboard_image(void);
  
  
  
  1.14      +5 -0      apache/src/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /export/home/cvs/apache/src/CHANGES,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -C3 -r1.13 -r1.14
  *** CHANGES	1996/03/22 05:42:50	1.13
  --- CHANGES	1996/03/25 10:54:30	1.14
  ***************
  *** 1,3 ****
  --- 1,8 ----
  +   *) Added simple and complex instrumentation to Apache to allow a
  +      instantaneous status screen to be displayed.  Since the complex
  +      instrumentation makes the scoreboard file bigger it has been 
  +      made a compile-time define (add "-DSTATUS_INSTRUMENTATION" to 
  +      CLAGS in the Configuration file) [Mark Cox]
    
      *) Made it so XBITHACK behavior only occurs for files of type text/html, as
         any other file type doesn't really make sense. [Alexei Kosut]
  
  
  

Mime
View raw message