
jim at hyperreal
May 22, 1996, 10:35 AM
Post #1 of 1
(80 views)
Permalink
|
|
cvs commit: apache/src http_core.c http_main.c http_main.h http_request.c httpd.h mod_cgi.c mod_status.c scoreboard.h
|
|
jim 96/05/22 10:35:47 Modified: src http_core.c http_main.c http_main.h http_request.c httpd.h mod_cgi.c mod_status.c scoreboard.h Log: DNS/Logging/Keepalive status modes Revision Changes Path 1.12 +9 -0 apache/src/http_core.c Index: http_core.c =================================================================== RCS file: /export/home/cvs/apache/src/http_core.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C3 -r1.11 -r1.12 *** http_core.c 1996/04/11 02:56:17 1.11 --- http_core.c 1996/05/22 17:35:36 1.12 *************** *** 63,68 **** --- 63,69 ---- #include "http_log.h" #include "rfc1413.h" #include "util_md5.h" + #include "scoreboard.h" /* Server core module... This module provides support for really basic * server operations, including options and commands which control the *************** *** 272,277 **** --- 273,283 ---- if (conn->remote_host == NULL && dir_conf->hostname_lookups) { + #ifdef STATUS + int old_stat = update_child_status(conn->child_num, + SERVER_BUSY_DNS, + (request_rec*)NULL); + #endif /* STATUS */ iaddr = &(conn->remote_addr.sin_addr); hptr = gethostbyaddr((char *)iaddr, sizeof(struct in_addr), AF_INET); if (hptr != NULL) *************** *** 296,301 **** --- 302,310 ---- } /* if failed, set it to the NULL string to indicate error */ if (conn->remote_host == NULL) conn->remote_host = ""; + #ifdef STATUS + (void)update_child_status(conn->child_num,old_stat,(request_rec*)NULL); + #endif /* STATUS */ } /* 1.28 +42 -18 apache/src/http_main.c Index: http_main.c =================================================================== RCS file: /export/home/cvs/apache/src/http_main.c,v retrieving revision 1.27 retrieving revision 1.28 diff -C3 -r1.27 -r1.28 *** http_main.c 1996/05/15 12:57:44 1.27 --- http_main.c 1996/05/22 17:35:36 1.28 *************** *** 657,667 **** #endif } ! void update_child_status (int child_num, int status, request_rec *r) { 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) --- 657,673 ---- #endif } ! int update_child_status (int child_num, int status, request_rec *r) { short_score new_score_rec; + int old_status; + + if (child_num < 0) + return -1; + memcpy(&new_score_rec,&scoreboard_image[child_num],sizeof new_score_rec); new_score_rec.pid = getpid(); + old_status = new_score_rec.status; new_score_rec.status = status; #if defined(STATUS) *************** *** 695,700 **** --- 701,716 ---- lseek (scoreboard_fd, (long)child_num * sizeof(short_score), 0); force_write (scoreboard_fd, (char*)&new_score_rec, sizeof(short_score)); #endif + + return old_status; + } + + int get_child_status (int child_num) + { + if (child_num<0 || child_num>=HARD_SERVER_MAX) + return -1; + else + return scoreboard_image[child_num].status; } int count_busy_servers () *************** *** 704,710 **** 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; } --- 720,729 ---- for (i = 0; i < HARD_SERVER_MAX; ++i) if (scoreboard_image[i].status == SERVER_BUSY_READ || ! scoreboard_image[i].status == SERVER_BUSY_WRITE || ! scoreboard_image[i].status == SERVER_BUSY_KEEPALIVE || ! scoreboard_image[i].status == SERVER_BUSY_LOG || ! scoreboard_image[i].status == SERVER_BUSY_DNS) ++res; return res; } *************** *** 1058,1064 **** conn_rec *new_connection (pool *p, server_rec *server, BUFF *inout, const struct sockaddr_in *remaddr, ! const struct sockaddr_in *saddr) { conn_rec *conn = (conn_rec *)pcalloc (p, sizeof(conn_rec)); --- 1077,1084 ---- conn_rec *new_connection (pool *p, server_rec *server, BUFF *inout, const struct sockaddr_in *remaddr, ! const struct sockaddr_in *saddr, ! int child_num) { conn_rec *conn = (conn_rec *)pcalloc (p, sizeof(conn_rec)); *************** *** 1067,1072 **** --- 1087,1093 ---- */ conn = (conn_rec *)pcalloc(p, sizeof(conn_rec)); + conn->child_num = child_num; conn->pool = p; conn->local_addr = *saddr; *************** *** 1077,1082 **** --- 1098,1104 ---- conn->remote_addr = *remaddr; conn->remote_ip = pstrdup (conn->pool, inet_ntoa(conn->remote_addr.sin_addr)); + return conn; } *************** *** 1102,1108 **** child_num = child_num_arg; requests_this_child = 0; reopen_scoreboard (pconf); ! update_child_status (child_num, SERVER_READY, (request_rec*)NULL); /* Only try to switch if we're running as root */ if(!geteuid() && setuid(user_id) == -1) { --- 1124,1130 ---- child_num = child_num_arg; requests_this_child = 0; reopen_scoreboard (pconf); ! (void)update_child_status (child_num, SERVER_READY, (request_rec*)NULL); /* Only try to switch if we're running as root */ if(!geteuid() && setuid(user_id) == -1) { *************** *** 1140,1146 **** } clen=sizeof(sa_client); ! update_child_status (child_num, SERVER_READY, (request_rec*)NULL); accept_mutex_on(); /* Lock around "accept", if necessary */ --- 1162,1168 ---- } clen=sizeof(sa_client); ! (void)update_child_status (child_num, SERVER_READY, (request_rec*)NULL); accept_mutex_on(); /* Lock around "accept", if necessary */ *************** *** 1177,1183 **** continue; } ! update_child_status (child_num, SERVER_BUSY_READ, (request_rec*)NULL); conn_io = bcreate(ptrans, B_RDWR); dupped_csd = csd; #if defined(NEED_DUPPED_CSD) --- 1199,1205 ---- continue; } ! (void)update_child_status (child_num, SERVER_BUSY_READ, (request_rec*)NULL); conn_io = bcreate(ptrans, B_RDWR); dupped_csd = csd; #if defined(NEED_DUPPED_CSD) *************** *** 1190,1199 **** current_conn = new_connection (ptrans, server_conf, conn_io, (struct sockaddr_in *)&sa_client, ! (struct sockaddr_in *)&sa_server); r = read_request (current_conn); ! update_child_status (child_num, SERVER_BUSY_WRITE, r); if (r) process_request (r); /* else premature EOF --- ignore */ #if defined(STATUS) --- 1212,1222 ---- current_conn = new_connection (ptrans, server_conf, conn_io, (struct sockaddr_in *)&sa_client, ! (struct sockaddr_in *)&sa_server, ! child_num); r = read_request (current_conn); ! (void)update_child_status (child_num, SERVER_BUSY_WRITE, r); if (r) process_request (r); /* else premature EOF --- ignore */ #if defined(STATUS) *************** *** 1202,1210 **** while (r && current_conn->keepalive) { bflush(conn_io); destroy_pool(r->pool); ! update_child_status (child_num, SERVER_BUSY_READ, (request_rec*)NULL); r = read_request (current_conn); ! update_child_status (child_num, SERVER_BUSY_WRITE, r); if (r) process_request (r); #if defined(STATUS) --- 1225,1233 ---- while (r && current_conn->keepalive) { bflush(conn_io); destroy_pool(r->pool); ! (void)update_child_status (child_num, SERVER_BUSY_KEEPALIVE, (request_rec*)NULL); r = read_request (current_conn); ! (void)update_child_status (child_num, SERVER_BUSY_WRITE, r); if (r) process_request (r); #if defined(STATUS) *************** *** 1381,1398 **** /* Child died... note that it's gone in the scoreboard. */ sync_scoreboard_image(); child_slot = find_child_by_pid (pid); ! if (child_slot >= 0) update_child_status (child_slot, SERVER_DEAD, ! (request_rec*)NULL); } sync_scoreboard_image(); if ((count_idle_servers() < daemons_min_free) ! && (child_slot = find_free_child_num()) >= 0 ! && child_slot <= daemons_limit) ! { ! update_child_status(child_slot,SERVER_STARTING,(request_rec*)NULL); make_child(server_conf, child_slot); ! } } } /* standalone_main */ --- 1404,1422 ---- /* Child died... note that it's gone in the scoreboard. */ sync_scoreboard_image(); child_slot = find_child_by_pid (pid); ! if (child_slot >= 0) ! (void)update_child_status (child_slot, SERVER_DEAD, ! (request_rec*)NULL); } sync_scoreboard_image(); if ((count_idle_servers() < daemons_min_free) ! && (child_slot = find_free_child_num()) >= 0 ! && child_slot <= daemons_limit) { ! (void)update_child_status(child_slot,SERVER_STARTING, ! (request_rec*)NULL); make_child(server_conf, child_slot); ! } } } /* standalone_main */ *************** *** 1491,1497 **** bpushfd(cio, fileno(stdin), fileno(stdout)); conn = new_connection (ptrans, server_conf, cio, (struct sockaddr_in *)&sa_client, ! (struct sockaddr_in *)&sa_server); r = read_request (conn); if (r) process_request (r); /* else premature EOF (ignore) */ --- 1515,1521 ---- bpushfd(cio, fileno(stdin), fileno(stdout)); conn = new_connection (ptrans, server_conf, cio, (struct sockaddr_in *)&sa_client, ! (struct sockaddr_in *)&sa_server,-1); r = read_request (conn); if (r) process_request (r); /* else premature EOF (ignore) */ 1.3 +6 -0 apache/src/http_main.h Index: http_main.h =================================================================== RCS file: /export/home/cvs/apache/src/http_main.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C3 -r1.2 -r1.3 *** http_main.h 1996/02/22 11:46:48 1.2 --- http_main.h 1996/05/22 17:35:37 1.3 *************** *** 91,93 **** --- 91,99 ---- void soft_timeout (char *, request_rec *); void kill_timeout (request_rec *); void reset_timeout (request_rec *); + + void sync_scoreboard_image (); + int update_child_status (int child_num, int status, request_rec *r); + int get_child_status (int child_num); + int count_busy_servers (); + int count_idle_servers (); 1.7 +9 -0 apache/src/http_request.c Index: http_request.c =================================================================== RCS file: /export/home/cvs/apache/src/http_request.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C3 -r1.6 -r1.7 *** http_request.c 1996/04/09 23:06:03 1.6 --- http_request.c 1996/05/22 17:35:37 1.7 *************** *** 70,75 **** --- 70,76 ---- #include "http_protocol.h" #include "http_log.h" #include "http_main.h" + #include "scoreboard.h" /***************************************************************** * *************** *** 737,744 **** --- 738,753 ---- void process_request (request_rec *r) { + int old_stat; process_request_internal (r); + #ifdef STATUS + old_stat = update_child_status (r->connection->child_num, SERVER_BUSY_LOG, + r); + #endif /* STATUS */ log_transaction (r); + #ifdef STATUS + (void)update_child_status (r->connection->child_num, old_stat, r); + #endif /* STATUS */ } table *rename_original_env (pool *p, table *t) 1.20 +2 -1 apache/src/httpd.h Index: httpd.h =================================================================== RCS file: /export/home/cvs/apache/src/httpd.h,v retrieving revision 1.19 retrieving revision 1.20 diff -C3 -r1.19 -r1.20 *** httpd.h 1996/05/15 12:57:45 1.19 --- httpd.h 1996/05/22 17:35:38 1.20 *************** *** 394,400 **** server_rec *server; /* Information about the connection itself */ ! BUFF *client; /* Connetion to the guy */ int aborted; /* Are we still talking? */ --- 394,401 ---- server_rec *server; /* Information about the connection itself */ ! ! int child_num; /* The number of the child handling conn_rec */ BUFF *client; /* Connetion to the guy */ int aborted; /* Are we still talking? */ 1.8 +2 -2 apache/src/mod_cgi.c Index: mod_cgi.c =================================================================== RCS file: /export/home/cvs/apache/src/mod_cgi.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C3 -r1.7 -r1.8 *** mod_cgi.c 1996/04/25 05:18:26 1.7 --- mod_cgi.c 1996/05/22 17:35:38 1.8 *************** *** 275,282 **** #else if (!spawn_child (r->connection->pool, cgi_child, (void *)&cld, ! nph ? just_wait : kill_after_timeout, ! &script_out, nph ? NULL : &script_in)) { log_reason ("couldn't spawn child process", r->filename, r); return SERVER_ERROR; } --- 275,282 ---- #else if (!spawn_child (r->connection->pool, cgi_child, (void *)&cld, ! nph ? just_wait : kill_after_timeout, ! &script_out, nph ? NULL : &script_in)) { log_reason ("couldn't spawn child process", r->filename, r); return SERVER_ERROR; } 1.17 +34 -5 apache/src/mod_status.c Index: mod_status.c =================================================================== RCS file: /export/home/cvs/apache/src/mod_status.c,v retrieving revision 1.16 retrieving revision 1.17 diff -C3 -r1.16 -r1.17 *** mod_status.c 1996/05/13 20:22:01 1.16 --- mod_status.c 1996/05/22 17:35:39 1.17 *************** *** 75,80 **** --- 75,82 ---- * 09.4.96 Added message for non-STATUS compiled version * 18.4.96 Added per child and per slot counters [Jim Jagielski] * 01.5.96 Table format, cleanup, even more spiffy data [Chuck Murcko/Jim J.] + * 21.5.96 Additional Status codes (DNS and LOGGING only enabled if + extended STATUS is enabled) [George Burgyan/Jim J.] */ #include "httpd.h" *************** *** 191,197 **** int no_table_report=0; server_rec *server = r->server; short_score score_record; ! char status[]="???????"; char buffer[200]; char stat_buffer[HARD_SERVER_MAX]; clock_t tu,ts,tcu,tcs; --- 193,199 ---- int no_table_report=0; server_rec *server = r->server; short_score score_record; ! char status[]="??????????"; char buffer[200]; char stat_buffer[HARD_SERVER_MAX]; clock_t tu,ts,tcu,tcs; *************** *** 203,208 **** --- 205,213 ---- status[SERVER_STARTING]='S'; status[SERVER_BUSY_READ]='R'; status[SERVER_BUSY_WRITE]='W'; + status[SERVER_BUSY_KEEPALIVE]='K'; + status[SERVER_BUSY_LOG]='L'; + status[SERVER_BUSY_DNS]='D'; if (r->method_number != M_GET) return NOT_IMPLEMENTED; r->content_type = "text/html"; *************** *** 255,261 **** if (res == SERVER_READY) ready++; else if (res == SERVER_BUSY_READ || res==SERVER_BUSY_WRITE || ! res == SERVER_STARTING) busy++; #if defined(STATUS) lres = score_record.access_count; --- 260,267 ---- if (res == SERVER_READY) ready++; else if (res == SERVER_BUSY_READ || res==SERVER_BUSY_WRITE || ! res == SERVER_STARTING || res==SERVER_BUSY_KEEPALIVE || ! res == SERVER_BUSY_LOG || res==SERVER_BUSY_DNS) busy++; #if defined(STATUS) lres = score_record.access_count; *************** *** 387,397 **** else { rputs("</PRE>\n",r); ! rputs("Key: \n",r); rputs("\"<code>_</code>\" Waiting for Connection, \n",r); ! rputs("\"<code>S</code>\" Starting up, \n",r); rputs("\"<code>R</code>\" Reading Request, \n",r); ! rputs("\"<code>W</code>\" Sending Reply<p>\n",r); sprintf(buffer,"\n%d requests currently being processed, %d idle servers\n",busy,ready); rputs(buffer,r); } --- 393,406 ---- else { rputs("</PRE>\n",r); ! rputs("Key:<br> \n",r); rputs("\"<code>_</code>\" Waiting for Connection, \n",r); ! rputs("\"<code>S</code>\" Starting up,<br> \n",r); rputs("\"<code>R</code>\" Reading Request, \n",r); ! rputs("\"<code>W</code>\" Sending Reply,<br> \n",r); ! rputs("\"<code>K</code>\" Keepalive (read), \n",r); ! rputs("\"<code>D</code>\" DNS Lookup, \n",r); ! rputs("\"<code>L</code>\" Logging<p>\n",r); sprintf(buffer,"\n%d requests currently being processed, %d idle servers\n",busy,ready); rputs(buffer,r); } *************** *** 438,443 **** --- 447,461 ---- case SERVER_BUSY_WRITE: rputs("<b>Write</b>",r); break; + case SERVER_BUSY_KEEPALIVE: + rputs("<b>Keepalive</b>",r); + break; + case SERVER_BUSY_LOG: + rputs("<b>Logging</b>",r); + break; + case SERVER_BUSY_DNS: + rputs("<b>DNS lookup</b>",r); + break; case SERVER_DEAD: rputs("Dead",r); break; *************** *** 479,484 **** --- 497,511 ---- case SERVER_BUSY_WRITE: rputs("<td><b>W</b>",r); break; + case SERVER_BUSY_KEEPALIVE: + rputs("<td><b>K</b>",r); + break; + case SERVER_BUSY_LOG: + rputs("<td><b>L</b>",r); + break; + case SERVER_BUSY_DNS: + rputs("<td><b>D</b>",r); + break; case SERVER_DEAD: rputs("<td>.",r); break; *************** *** 524,529 **** --- 551,558 ---- rputs("you need to recompile Apache adding the <code>-DSTATUS</code> \n",r); rputs("directive on the <code>CFLAGS</code> line in the \n",r); rputs("<code>Configuration</code> file.\n",r); + rputs("<code>DNS</code> and <code>LOGGING</code> status \n",r); + rputs("also requires the <code>-DSTATUS</code> directive. \n",r); #endif /* STATUS */ 1.10 +4 -0 apache/src/scoreboard.h Index: scoreboard.h =================================================================== RCS file: /export/home/cvs/apache/src/scoreboard.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C3 -r1.9 -r1.10 *** scoreboard.h 1996/05/07 18:29:35 1.9 --- scoreboard.h 1996/05/22 17:35:39 1.10 *************** *** 63,73 **** --- 63,77 ---- * Status values: */ + #define SERVER_UNKNOWN (-1) /* should never be in this state */ #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 */ + #define SERVER_BUSY_KEEPALIVE 5 /* Waiting for more requests via keepalive */ + #define SERVER_BUSY_LOG 6 /* Logging the request */ + #define SERVER_BUSY_DNS 7 /* Looking up a hostname */ typedef struct { pid_t pid;
|