You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by pq...@apache.org on 2009/02/09 01:57:58 UTC

svn commit: r742218 - in /httpd/httpd/trunk: STATUS include/ap_mmn.h include/httpd.h server/mpm/experimental/event/event.c server/mpm/prefork/prefork.c server/mpm/simple/simple_io.c server/mpm/worker/worker.c

Author: pquerna
Date: Mon Feb  9 00:57:58 2009
New Revision: 742218

URL: http://svn.apache.org/viewvc?rev=742218&view=rev
Log:
Add conn_rec::current_thread.

Modified:
    httpd/httpd/trunk/STATUS
    httpd/httpd/trunk/include/ap_mmn.h
    httpd/httpd/trunk/include/httpd.h
    httpd/httpd/trunk/server/mpm/experimental/event/event.c
    httpd/httpd/trunk/server/mpm/prefork/prefork.c
    httpd/httpd/trunk/server/mpm/simple/simple_io.c
    httpd/httpd/trunk/server/mpm/worker/worker.c

Modified: httpd/httpd/trunk/STATUS
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/STATUS?rev=742218&r1=742217&r2=742218&view=diff
==============================================================================
--- httpd/httpd/trunk/STATUS (original)
+++ httpd/httpd/trunk/STATUS Mon Feb  9 00:57:58 2009
@@ -50,6 +50,9 @@
 
 RELEASE SHOWSTOPPERS:
 
+  * Not all MPMs are updated to set conn_rec::current_thread correctly.
+      (Prefork, Worker, Event, Simple are updated).
+
   * Handling of non-trailing / config by non-default handler is broken
     http://marc.theaimsgroup.com/?l=apache-httpd-dev&m=105451701628081&w=2
     jerenkrantz asks: Why should this block a release?

Modified: httpd/httpd/trunk/include/ap_mmn.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/ap_mmn.h?rev=742218&r1=742217&r2=742218&view=diff
==============================================================================
--- httpd/httpd/trunk/include/ap_mmn.h (original)
+++ httpd/httpd/trunk/include/ap_mmn.h Mon Feb  9 00:57:58 2009
@@ -188,12 +188,13 @@
  *                         and make ap_escape_html a macro for it.
  * 20090130.0 (2.3.2-dev)  Add ap_ prefix to unixd_setup_child().
  * 20090131.0 (2.3.2-dev)  Remove ap_default_type(), disable DefaultType
+ * 20090208.0 (2.3.2-dev)  Add conn_rec::current_thread.
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */
 
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
-#define MODULE_MAGIC_NUMBER_MAJOR 20090131
+#define MODULE_MAGIC_NUMBER_MAJOR 20090208
 #endif
 #define MODULE_MAGIC_NUMBER_MINOR 0                     /* 0...n */
 

Modified: httpd/httpd/trunk/include/httpd.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/httpd.h?rev=742218&r1=742217&r2=742218&view=diff
==============================================================================
--- httpd/httpd/trunk/include/httpd.h (original)
+++ httpd/httpd/trunk/include/httpd.h Mon Feb  9 00:57:58 2009
@@ -53,6 +53,7 @@
 #include "apr_network_io.h"
 #include "apr_buckets.h"
 #include "apr_poll.h"
+#include "apr_thread_proc.h"
 
 #include "os.h"
 
@@ -988,6 +989,7 @@
     apr_thread_mutex_t *invoke_mtx;
 
     apr_table_t *body_table;
+
 /* Things placed at the end of the record to avoid breaking binary
  * compatibility.  It would be nice to remember to reorder the entire
  * record to improve 64bit alignment the next time we need to break
@@ -1094,6 +1096,15 @@
      *  the event mpm.
      */
     int clogging_input_filters;
+    
+    /** This points to the current thread being used to process this request,
+     * over the lifetime of a request, the value may change. Users of the connection
+     * record should not rely upon it staying the same between calls that invole
+     * the MPM.
+     */
+#if APR_HAS_THREADS
+    apr_thread_t *current_thread;
+#endif
 };
 
 /** 

Modified: httpd/httpd/trunk/server/mpm/experimental/event/event.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/experimental/event/event.c?rev=742218&r1=742217&r2=742218&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/experimental/event/event.c (original)
+++ httpd/httpd/trunk/server/mpm/experimental/event/event.c Mon Feb  9 00:57:58 2009
@@ -542,7 +542,7 @@
  * Child process main loop.
  */
 
-static int process_socket(apr_pool_t * p, apr_socket_t * sock,
+static int process_socket(apr_thread_t *thd, apr_pool_t * p, apr_socket_t * sock,
                           conn_state_t * cs, int my_child_num,
                           int my_thread_num)
 {
@@ -563,6 +563,7 @@
         cs->bucket_alloc = apr_bucket_alloc_create(p);
         c = ap_run_create_connection(p, ap_server_conf, sock,
                                      conn_id, sbh, cs->bucket_alloc);
+        c->current_thread = thd;
         cs->c = c;
         c->cs = cs;
         cs->p = p;
@@ -604,6 +605,7 @@
         c = cs->c;
         c->sbh = sbh;
         pt = cs->pfd.client_data;
+        c->current_thread = thd;
     }
 
     if (c->clogging_input_filters && !c->aborted) {
@@ -1319,7 +1321,7 @@
         else {
             is_idle = 0;
             worker_sockets[thread_slot] = csd;
-            rv = process_socket(ptrans, csd, cs, process_slot, thread_slot);
+            rv = process_socket(thd, ptrans, csd, cs, process_slot, thread_slot);
             if (!rv) {
                 requests_this_child--;
             }

Modified: httpd/httpd/trunk/server/mpm/prefork/prefork.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/prefork/prefork.c?rev=742218&r1=742217&r2=742218&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/prefork/prefork.c (original)
+++ httpd/httpd/trunk/server/mpm/prefork/prefork.c Mon Feb  9 00:57:58 2009
@@ -431,6 +431,10 @@
 
 static void child_main(int child_num_arg)
 {
+#if APR_HAS_THREADS
+    apr_thread_t *thd;
+    apr_os_thread_t osthd;
+#endif
     apr_pool_t *ptrans;
     apr_allocator_t *allocator;
     apr_status_t status;
@@ -460,6 +464,11 @@
     apr_allocator_owner_set(allocator, pchild);
     apr_pool_tag(pchild, "pchild");
 
+#if APR_HAS_THREADS
+    osthd = apr_os_thread_current();
+    apr_os_thread_put(&thd, &osthd, pchild);
+#endif
+    
     apr_pool_create(&ptrans, pchild);
     apr_pool_tag(ptrans, "transaction");
 
@@ -626,6 +635,9 @@
 
         current_conn = ap_run_create_connection(ptrans, ap_server_conf, csd, my_child_num, sbh, bucket_alloc);
         if (current_conn) {
+#if APR_HAS_THREADS
+            current_conn->current_thread = thd;
+#endif
             ap_process_connection(current_conn, csd);
             ap_lingering_close(current_conn);
         }

Modified: httpd/httpd/trunk/server/mpm/simple/simple_io.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/simple/simple_io.c?rev=742218&r1=742217&r2=742218&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/simple/simple_io.c (original)
+++ httpd/httpd/trunk/server/mpm/simple/simple_io.c Mon Feb  9 00:57:58 2009
@@ -177,6 +177,8 @@
     simple_conn_t *scon = (simple_conn_t *) sb->baton;
     apr_status_t rv;
 
+    scon->c->current_thread = thread;
+
     rv = simple_io_process(scon);
 
     if (rv) {
@@ -208,6 +210,8 @@
     cs = scon->c->cs;
     sb = apr_pcalloc(scon->pool, sizeof(simple_sb_t));
 
+    scon->c->current_thread = thread;
+
     cs->pfd.p = scon->pool;
     cs->pfd.desc_type = APR_POLL_SOCKET;
     cs->pfd.desc.s = scon->sock;

Modified: httpd/httpd/trunk/server/mpm/worker/worker.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/worker/worker.c?rev=742218&r1=742217&r2=742218&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/worker/worker.c (original)
+++ httpd/httpd/trunk/server/mpm/worker/worker.c Mon Feb  9 00:57:58 2009
@@ -517,7 +517,8 @@
  * Child process main loop.
  */
 
-static void process_socket(apr_pool_t *p, apr_socket_t *sock, int my_child_num,
+static void process_socket(apr_thread_t *thd, apr_pool_t *p, apr_socket_t *sock,
+                           int my_child_num,
                            int my_thread_num, apr_bucket_alloc_t *bucket_alloc)
 {
     conn_rec *current_conn;
@@ -529,6 +530,7 @@
     current_conn = ap_run_create_connection(p, ap_server_conf, sock,
                                             conn_id, sbh, bucket_alloc);
     if (current_conn) {
+        current_conn->current_thread = thd;
         ap_process_connection(current_conn, sock);
         ap_lingering_close(current_conn);
     }
@@ -880,7 +882,7 @@
         is_idle = 0;
         worker_sockets[thread_slot] = csd;
         bucket_alloc = apr_bucket_alloc_create(ptrans);
-        process_socket(ptrans, csd, process_slot, thread_slot, bucket_alloc);
+        process_socket(thd, ptrans, csd, process_slot, thread_slot, bucket_alloc);
         worker_sockets[thread_slot] = NULL;
         requests_this_child--; 
         apr_pool_clear(ptrans);