]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Add conn_rec::current_thread.
authorPaul Querna <pquerna@apache.org>
Mon, 9 Feb 2009 00:57:58 +0000 (00:57 +0000)
committerPaul Querna <pquerna@apache.org>
Mon, 9 Feb 2009 00:57:58 +0000 (00:57 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@742218 13f79535-47bb-0310-9956-ffa450edef68

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

diff --git a/STATUS b/STATUS
index c3e4a933285e85e84d6bda44e75a5047b07fc15d..967ddf8546f98a084064961af34ed4043512c400 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -50,6 +50,9 @@ CURRENT RELEASE NOTES:
 
 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?
index 2005d199072e91c478e04571110ea04941ee0629..8c003d28bbc32802b3e0baf7ca5dd09b19192d82 100644 (file)
  *                         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 */
 
index c5f8c8448dbc7f527215dd855086f5e1c8be0912..5156707323f0c975ce9d904a8154a74363fdccfa 100644 (file)
@@ -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 @@ struct request_rec {
     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 @@ struct conn_rec {
      *  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
 };
 
 /** 
index a3a3c47c254ab650b1d9fe55578c454d19830cce..be4969371195d58115a45782e349e45e2f90ab3d 100644 (file)
@@ -542,7 +542,7 @@ static void set_signals(void)
  * 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 @@ static int process_socket(apr_pool_t * p, apr_socket_t * sock,
         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 @@ static int process_socket(apr_pool_t * p, apr_socket_t * sock,
         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 @@ static void *APR_THREAD_FUNC worker_thread(apr_thread_t * thd, void *dummy)
         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--;
             }
index 2bbf7c3a9515f07ede53ff7d0e4fd6716c79c3e7..8eb584e115f1f910e8a09fc5fad4edfaf2cdd6c5 100644 (file)
@@ -431,6 +431,10 @@ static int num_listensocks = 0;
 
 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 @@ static void child_main(int child_num_arg)
     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 @@ static void child_main(int child_num_arg)
 
         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);
         }
index 8774ed323e8f80a034c2620ea5235baf85e8751a..b0f33f010125f5ecea3ba3b470c9151d32d37baa 100644 (file)
@@ -177,6 +177,8 @@ static void *simple_io_invoke(apr_thread_t * thread, void *baton)
     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 @@ static void *simple_io_setup_conn(apr_thread_t * thread, void *baton)
     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;
index accf4c71feccd83112bcb703aaf1c655b415b25a..a530dc5a6bebe8e215e3d4abfeadc848d4e31af4 100644 (file)
@@ -517,7 +517,8 @@ static void set_signals(void)
  * 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 @@ static void process_socket(apr_pool_t *p, apr_socket_t *sock, int my_child_num,
     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 @@ worker_pop:
         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);