You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ji...@apache.org on 2009/10/03 14:54:36 UTC

svn commit: r821307 - in /httpd/httpd/trunk: include/scoreboard.h modules/experimental/mod_noloris.c server/scoreboard.c

Author: jim
Date: Sat Oct  3 12:54:35 2009
New Revision: 821307

URL: http://svn.apache.org/viewvc?rev=821307&view=rev
Log:
Provide new  ap_update_child_status_from_conn() mostly
for use with mod_noloris.c Add some logic protection, for
NULL ref, which shoulda be there in any case.

Modified:
    httpd/httpd/trunk/include/scoreboard.h
    httpd/httpd/trunk/modules/experimental/mod_noloris.c
    httpd/httpd/trunk/server/scoreboard.c

Modified: httpd/httpd/trunk/include/scoreboard.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/scoreboard.h?rev=821307&r1=821306&r2=821307&view=diff
==============================================================================
--- httpd/httpd/trunk/include/scoreboard.h (original)
+++ httpd/httpd/trunk/include/scoreboard.h Sat Oct  3 12:54:35 2009
@@ -173,6 +173,7 @@
 AP_DECLARE(int) ap_update_child_status(ap_sb_handle_t *sbh, int status, request_rec *r);
 AP_DECLARE(int) ap_update_child_status_from_indexes(int child_num, int thread_num,
                                                     int status, request_rec *r);
+AP_DECLARE(int) ap_update_child_status_from_conn(ap_sb_handle_t *sbh, int status, conn_rec *c);
 AP_DECLARE(void) ap_time_process_request(ap_sb_handle_t *sbh, int status);
 
 AP_DECLARE(worker_score *) ap_get_scoreboard_worker(ap_sb_handle_t *sbh);

Modified: httpd/httpd/trunk/modules/experimental/mod_noloris.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/experimental/mod_noloris.c?rev=821307&r1=821306&r2=821307&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/experimental/mod_noloris.c (original)
+++ httpd/httpd/trunk/modules/experimental/mod_noloris.c Sat Oct  3 12:54:35 2009
@@ -57,17 +57,9 @@
 
 static int noloris_conn(conn_rec *conn)
 {
-    /*** FIXME
-     * This is evil: we're assuming info that's private to the scoreboard
-     * We need to do that because there's no API to update the scoreboard
-     * on a connection, only with a request (or NULL to say not processing
-     * any request).  We need a version of ap_update_child_status that
-     * accepts a conn_rec.
-     */
     struct { int child_num; int thread_num; } *sbh = conn->sbh;
 
     char *shm_rec;
-    worker_score *ws;
     if (shm == NULL) {
         return DECLINED;  /* we're disabled */
     }
@@ -88,13 +80,8 @@
     }
 
     /* store this client IP for the monitor to pick up */
-    /* under traditional scoreboard, none of this happens until
-     * there's a request_rec.  This is where we use the illegally-
-     * obtained private info from the scoreboard.
-     */
-
-    ws = &ap_scoreboard_image->servers[sbh->child_num][sbh->thread_num];
-    strcpy(ws->client, conn->remote_ip);
+ 
+    ap_update_child_status_from_conn(conn->sbh, SERVER_READY, conn);
 
     return DECLINED;
 }

Modified: httpd/httpd/trunk/server/scoreboard.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/scoreboard.c?rev=821307&r1=821306&r2=821307&view=diff
==============================================================================
--- httpd/httpd/trunk/server/scoreboard.c (original)
+++ httpd/httpd/trunk/server/scoreboard.c Sat Oct  3 12:54:35 2009
@@ -472,8 +472,10 @@
             apr_cpystrn(ws->client, ap_get_remote_host(c, r->per_dir_config,
                         REMOTE_NOLOOKUP, NULL), sizeof(ws->client));
             copy_request(ws->request, sizeof(ws->request), r);
-            apr_cpystrn(ws->vhost, r->server->server_hostname,
-                        sizeof(ws->vhost));
+            if (r->server) {
+            	apr_cpystrn(ws->vhost, r->server->server_hostname,
+                            sizeof(ws->vhost));
+            }
         }
     }
 
@@ -490,6 +492,19 @@
                                                status, r);
 }
 
+AP_DECLARE(int) ap_update_child_status_from_conn(ap_sb_handle_t *sbh, int status,
+                                       conn_rec *c)
+{
+    if (!sbh)
+        return -1;
+    
+    request_rec fake_rec;
+    fake_rec.connection = c;
+            
+    return ap_update_child_status_from_indexes(sbh->child_num, sbh->thread_num,
+                                               status, &fake_rec);
+}
+
 AP_DECLARE(void) ap_time_process_request(ap_sb_handle_t *sbh, int status)
 {
     worker_score *ws;