http_core.c

Checkout Tools
  • last updated 1 hour ago
Constraints
Constraints: committers
 
Constraints: files
Constraints: dates
revert r1857857.

The comment is useful and the dead-code is future proof (and should be axed by the compiler anyway)

Axe a useless comment.

Remove some dead code and innacurate comment. 'r' can not be dereferenced later in the function. (this is obvious since r1814659)

(Reverted in r1858070)

Follow up to r1814659.

One more style fix in ap_process_http_async_connection().

We can't possibly loop in ap_process_http_async_connection().

While at it, fix style. No functional change overall.

Follow up to r1740928: including NOT_IN_PROXY in NOT_IN_DIR_LOC_FILE is both

incomplete and not backportable, fix it by introducing NOT_IN_DIR_CONTEXT and

restoring NOT_IN_DIR_LOC_FILE to its previous value.

Per ap_check_cmd_context(), NOT_IN_DIR_LOC_FILE actually/really means "not in

any directory context", while the definition itself does not include all the

existing directory contexts (e.g. <Limit>, or <Proxy> before r1740928).

This is a bit of a misnomer, at least, so instead of (ab)using it by adding the

missing contexts (in an incompatible way), let's define NOT_IN_DIR_CONTEXT to

really exclude all directory context (i.e. NOT_IN_DIR_LOC_FILE + NOT_IN_LIMIT +

NOT_IN_PROXY) and use it wherever NOT_IN_DIR_LOC_FILE was used.

This is by itself a major MMN bump (modules not compiled with this commit and

having directives checked against NOT_IN_DIR_LOC_FILE won't be caught the same

way by NOT_IN_DIR_CONTEXT in the new ap_check_cmd_context() code), but with the

below change, 2.4.x should work as before:

- if ((forbidden & NOT_IN_DIR_CONTEXT) == NOT_IN_DIR_CONTEXT) {

+ if ((forbidden & NOT_IN_DIR_LOC_FILE) == NOT_IN_DIR_LOC_FILE) {

if (cmd->path != NULL) {

return apr_pstrcat(cmd->pool, cmd->cmd->name, gt,

- " cannot occur within directory context", NULL);

+ " cannot occur within <Directory/Location/Files/Proxy> "

+ "section", NULL);

}

...

}

  1. … 7 more files in changeset.
* Silence compiler warning
PR60647: ACC per connection not available w/ event MPM

  1. … 4 more files in changeset.
Fix spelling in comments and text files.

No functional change.

PR 59990

  1. … 69 more files in changeset.
Avoid truncating the_request line when there is no request to 'W'rite.

Revert 1742822, incorrect assumptions here
Fix yet another case where we clobber the

server-status request info when a timeout happens.

reverting r1735176
  1. … 1 more file in changeset.
mod_http: Make sure HTTP filters are added on HTTP requests only.

  1. … 1 more file in changeset.
core: Extend support for setting aside data from the network input filter

to any connection or request input filter.

  1. … 13 more files in changeset.
core: Extend support for asynchronous write completion from the

network filter to any connection or request filter.

  1. … 15 more files in changeset.
core: Follow up to r1664071: comments on new keep_alive_timeout_set flag.
  1. … 1 more file in changeset.
core: If explicitly configured, use the KeepaliveTimeout value of the

virtual host which handled the latest request on the connection, or by

default the one of the first virtual host bound to the same IP:port.

For non-async MPMs, use either r->server's or c->base_server's value in

ap_process_http_sync_connection() depending on a new server_rec's flag

called keep_alive_timeout_set and determined at config time.

For event MPM, use a queue per timeout value, chaining the queues per

type (keepalive wrt KeepAliveTimeout, write completion wrt to Timeout)

so that maintenance can be done on all the queues from the head, and such

that insertions/maintenance remain in O(1).

A server config is created and pointing to the queue of each vhost at

post_config time, hence the config can be associated to the connection

state (cs) at post_read_request time (keep_alive_timeout_set is used to

determine r->server vs c->base_server here), and we can simply insert

with TO_QUEUE_INSERT(cs->sc->q, cs). PR56226.

While at it, since each queue now embeds it own timeout and hence the

expiration_time of the cs has changed to a queue_timestamp (the time it

was queued), we can detect clock skews and expire entries immediatly if

the system is set (eg. far) in the past during runtime and we want to

avoid waiting for (eg.) centuries before the current logic kills them.

Any entry which is registered above now + q->timeout is concerned, and

is now cleaned from the queue when encountered. PR57374.

  1. … 5 more files in changeset.
Fix segfault caused by r1204104 on non-async mpms.

  1. … 1 more file in changeset.
Remove MPM-private stuff from conn_state_t

  1. … 9 more files in changeset.
Cleanup effort in prep for GA push:

Trim trailing whitespace... no func change

  1. … 118 more files in changeset.
Create wrapper API for apr_random;

use in mod_lbmethod_heartbeat and mod_serf to

- replace some needles use of apr_generate_random_bytes

- remove code duplication

  1. … 7 more files in changeset.
Introduce new function ap_get_conn_socket() to access the socket of

a connection

  1. … 12 more files in changeset.
Introduce ap_(get|set)_core_module_config() functions/macros and use them

everywhere.

We know that the core module has module_index 0. Therefore we can save

some pointer operations in ap_get_module_config(cv, &core_module) and

ap_set_module_config(cv, &core_module, val). As these are called rather often,

this may actually have some (small) measurable effect.

  1. … 42 more files in changeset.
Use the new APLOG_USE_MODULE/AP_DECLARE_MODULE macros everywhere to take

advantage of per-module loglevels

  1. … 169 more files in changeset.
KeepAlive no longer accepts other than On|Off.
  1. … 1 more file in changeset.
Use the new ap_update_child_status_from_conn() to put the client IP into the

scoreboard (and show it in mod_status) as soon as we start reading the request.

Empty the vhost and request fields in ap_update_child_status_from_conn so that

mod_status does not display outdated data if the connection closes without

the request being completely read.

  1. … 1 more file in changeset.
handle an unfortunate implication of loadable MPMs:

calls to ap_mpm_query() must be deferred until after the register-hooks hook, since that's

where the MPM registers its mpm-query hook

  1. … 1 more file in changeset.
Enhance KeepAliveTimeout to support a value in milliseconds.

PR: 46275

  1. … 3 more files in changeset.
Introduce Suspendable Requests to the Event MPM.

Using this basic framework, you can return SUSPENDED from an HTTP Handler,

and then register a callback that is invoked by the MPM at a later time.

This initial version only supports _timers_ as callbacks, but in the future I

would like to add things like wait for socket activity, on a socket specified by

the handler.

Once in a callback, It is then the responsibility of the callback fucntion

to finish the HTTP Request handling, but this alows you to do cool things like

a fully async proxy, COMET support, or even rate limiting.

To prove I'm not insane, I've inlcuded an example module, mod_dialup.

You can configure it like this:

<Location "/docs">

ModemStandard "V.32"

</Location>

And for static files inside that path, you will be rate limited to V.32 speeds,

aka 9.6 kilobits/second.

Does anyone besides Rüdiger read commit emails :-) ?

I know there are likely huge problems with this, but I would like to see how far

we can push the Event MPM, figure out what to do better, if there is anything,

and then really dive into the 3.0 development before ApacheCon.

* server/mpm/experimental/event/fdqueue.h:

(timer_event_t): New structure to hold timer events and callback functions.

* server/mpm/experimental/event/fdqueue.c

(ap_queue_empty): Modify to also look at Timer Ring.

(ap_queue_init): Initialize Timer Ring.

(ap_queue_push_timer): New function, pushes a timer event into the queue.

(ap_queue_pop_something): Renamed function, returns a timer event or

a socket/pool for a worker thread to run.

* server/mpm/experimental/event/event.c

(process_socket): If the connection is in SUSPENDED state, don't force it

into linger mode yet, the callback will have to take care of that.

(push_timer2worker): New shortcut function, pushes timer event into queue

for a worker to run.

(timer_free_ring): New global data structure to recycle memory used by

timer events.

(timer_ring): New global data structure to hold active timer events.

(g_timer_ring_mtx): Thread mutex to protect timer event data structures.

(ap_mpm_register_timed_callback): New Function, registers a callback to be

invoked by the MPM at a later time.

(listener_thread): Calculate our wakeup time based on the upcoming Event

Queue, and after pollset_poll runs, push any Timers that have passed

onto worker threads to run.

(worker_thread): Call new queue pop method, and if the Timer Event is

non-null, invoke the callback. Once the callback is done, push the

structure onto the timer_free_ring, to be recycled.

(child_main): Initialize new mutex and ring structures.

* server/config.c

(ap_invoke_handler): Allow SUSPENDED aa valid return code from handlers.

* modules/http/http_core.c

(ap_process_http_async_connection): Don't close the connection when in

SUSPENDED state.

* modules/http/http_request.c

(ap_process_request_after_handler): New function, body pulled from the old,

ap_process_async_request. Split to let handlers invoke this so they

don't need to know all of the details of finishing a request.

(ap_process_async_request): If the handler returns SUSPENDED, don't do

anything but return.

* include/ap_mmn.h: Bump MMN.

* include/ap_mpm.h

(ap_mpm_register_timed_callback): New function.

* include/httpd.h:

(SUSPENDED): New return code for handlers.

(request_rec::invoke_mtx): New mutex to protect callback invokcations

from being run before the original handler finishes running.

(conn_state_e): Add a suspended state.

* include/http_request.h

(ap_process_request_after_handler): New function to make it easier for

handlers to finish the HTTP Request.

* modules/test/config.m4: Add mod_dialup to build.

* modules/test/mod_dialup.c: New rate limiting module, requires the Event MPM

to work.

  1. … 11 more files in changeset.
Move the KeptBodySize directive, kept_body filters and the

ap_parse_request_body function out of the http module and into a

new module called mod_request, reducing the size of the core.

  1. … 12 more files in changeset.