From: Paul Querna Date: Mon, 9 Feb 2009 00:57:58 +0000 (+0000) Subject: Add conn_rec::current_thread. X-Git-Tag: 2.3.2~73 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=69f2fd40dc51f67a88c4a9dcfb3de9a34d467040;p=thirdparty%2Fapache%2Fhttpd.git Add conn_rec::current_thread. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@742218 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/STATUS b/STATUS index c3e4a933285..967ddf8546f 100644 --- 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? diff --git a/include/ap_mmn.h b/include/ap_mmn.h index 2005d199072..8c003d28bbc 100644 --- a/include/ap_mmn.h +++ b/include/ap_mmn.h @@ -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 */ diff --git a/include/httpd.h b/include/httpd.h index c5f8c8448db..5156707323f 100644 --- a/include/httpd.h +++ b/include/httpd.h @@ -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 }; /** diff --git a/server/mpm/experimental/event/event.c b/server/mpm/experimental/event/event.c index a3a3c47c254..be496937119 100644 --- a/server/mpm/experimental/event/event.c +++ b/server/mpm/experimental/event/event.c @@ -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--; } diff --git a/server/mpm/prefork/prefork.c b/server/mpm/prefork/prefork.c index 2bbf7c3a951..8eb584e115f 100644 --- a/server/mpm/prefork/prefork.c +++ b/server/mpm/prefork/prefork.c @@ -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); } diff --git a/server/mpm/simple/simple_io.c b/server/mpm/simple/simple_io.c index 8774ed323e8..b0f33f01012 100644 --- a/server/mpm/simple/simple_io.c +++ b/server/mpm/simple/simple_io.c @@ -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; diff --git a/server/mpm/worker/worker.c b/server/mpm/worker/worker.c index accf4c71fec..a530dc5a6be 100644 --- a/server/mpm/worker/worker.c +++ b/server/mpm/worker/worker.c @@ -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);