In case one of the pre_connection hooks causes the hook run to stop by an error

the pre_connection hook of the core module maybe did not run
(it is APR_HOOK_REALLY_LAST) and hence we missed to

- Put the socket in c->conn_config
- Setup core output and input filters
- Set socket options and timeouts

For calls of ap_run_pre_connection where this matters create a wrapper named
ap_pre_connection that ensures that this happens.

* include/ap_mmn.h: Bump minor version as we added new ap_pre_connection
  function.

* include/http_connection.h: Declare ap_pre_connection prototype.

* server/connection.c: Make use of ap_pre_connection in ap_process_connection.

* server/core.c: Implement ap_pre_connection.

* server/mpm/event/event.c: Make use of ap_pre_connection.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1893497 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Ruediger Pluem
2021-09-21 20:03:52 +00:00
parent 8e54d2793c
commit 6d9a8cd1f2
5 changed files with 44 additions and 8 deletions

View File

@ -135,6 +135,21 @@ AP_DECLARE_HOOK(int,process_connection,(conn_rec *c))
*/
AP_DECLARE_HOOK(int,pre_close_connection,(conn_rec *c))
/**
* This is a wrapper around ap_run_pre_connection. In case that
* ap_run_pre_connection returns an error it marks the connection as
* aborted and ensures that the basic connection setup normally done
* by the core module is done in case it was not done so far.
* @param c The connection on which the request has been received.
* Same as for the pre_connection hook.
* @param csd The mechanism on which this connection is to be read.
* Most times this will be a socket, but it is up to the module
* that accepts the request to determine the exact type.
* Same as for the pre_connection hook.
* @return The result of ap_run_pre_connection
*/
AP_DECLARE(int) ap_pre_connection(conn_rec *c, void *csd);
/**
* Create a new server/incoming or client/outgoing/proxy connection
* @param p The pool from which to allocate the connection record