On Tue, Sep 30, 2014 at 4:47 PM, Yann Ylavic <[email protected]> wrote:
>
> When acquire is NULL but baton isn't, a built-in acquire function is
> used to select an existing or create a new connection associated to a
> conn_rec (and still the worker). The baton is assumed to be a conn_rec
> (eg. the one of the client's connection), and this mode is hence a
> return back to the days of httpd <= 2.0.
This mode (the one used when env "proxy-aside-c" is defined) currently
issues no locking to use the conn_rec, ie. for each request, mod_proxy
will call :
+/* For the given conn_rec (baton), handle a connection per worker */
+static apr_status_t proxy_acquire_from_c(void *baton, proxy_conn_rec **conn,
+ proxy_worker *worker, server_rec *s)
+{
+ apr_hash_t *conns;
+ conn_rec *c = baton;
+
+ conns = ap_get_module_config(c->conn_config, &proxy_module);
+ if (!conns) {
+ conns = apr_hash_make(c->pool);
+ ap_set_module_config(c->conn_config, &proxy_module, conns);
+ *conn = NULL;
+ }
+ else {
+ *conn = apr_hash_get(conns, &worker->s, sizeof worker->s);
+ }
+ if (!*conn) {
+ ap_proxy_aside_connection(conn, worker, c->pool);
+ apr_hash_set(conns, &worker->s, sizeof worker->s, *conn);
+ }
+ else if ((*conn)->aside->expiry) {
+ if (apr_time_now() >= (*conn)->aside->expiry) {
+ socket_cleanup(*conn);
+ }
+ (*conn)->aside->expiry = 0;
+ }
+
+ return APR_SUCCESS;
+}
This assumes there will be only one request handled at a time for a
single connection, and I wonder if, for some MPM (event/windows?),
there may be multiple threads using the same client's conn_rec (eg.
pipelined requests on the same connection), is that ever possible?
In this case, I'd have to add locking there...