mirror of
https://github.com/apache/httpd.git
synced 2025-08-08 15:02:10 +03:00
Remove proxy_conn struct and add it's params to proxy_conn_rec.
Use named structure type declarations. Submitted by: mturk git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@104589 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -120,7 +120,7 @@ static const char *set_worker_param(proxy_worker *worker,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const char *set_balancer_param(struct proxy_balancer *balancer,
|
||||
static const char *set_balancer_param(proxy_balancer *balancer,
|
||||
const char *key,
|
||||
const char *val)
|
||||
{
|
||||
@@ -473,7 +473,7 @@ static int proxy_handler(request_rec *r)
|
||||
int direct_connect = 0;
|
||||
const char *str;
|
||||
long maxfwd;
|
||||
struct proxy_balancer *balancer = NULL;
|
||||
proxy_balancer *balancer = NULL;
|
||||
proxy_worker *worker = NULL;
|
||||
proxy_module_conf *mconf;
|
||||
|
||||
@@ -654,7 +654,7 @@ static void * create_proxy_config(apr_pool_t *p, server_rec *s)
|
||||
ps->dirconn = apr_array_make(p, 10, sizeof(struct dirconn_entry));
|
||||
ps->allowed_connect_ports = apr_array_make(p, 10, sizeof(int));
|
||||
ps->workers = apr_array_make(p, 10, sizeof(proxy_worker));
|
||||
ps->balancers = apr_array_make(p, 10, sizeof(struct proxy_balancer));
|
||||
ps->balancers = apr_array_make(p, 10, sizeof(proxy_balancer));
|
||||
ps->domain = NULL;
|
||||
ps->viaopt = via_off; /* initially backward compatible with 1.3.1 */
|
||||
ps->viaopt_set = 0; /* 0 means default */
|
||||
@@ -855,7 +855,7 @@ static const char *
|
||||
elts = (const apr_table_entry_t *)arr->elts;
|
||||
/* Distinguish the balancer from woker */
|
||||
if (strncasecmp(r, "balancer:", 9) == 0) {
|
||||
struct proxy_balancer *balancer = ap_proxy_get_balancer(cmd->pool, conf, r);
|
||||
proxy_balancer *balancer = ap_proxy_get_balancer(cmd->pool, conf, r);
|
||||
if (!balancer) {
|
||||
const char *err = ap_proxy_add_balancer(&balancer,
|
||||
cmd->pool,
|
||||
@@ -1203,7 +1203,7 @@ static const char *add_member(cmd_parms *cmd, void *dummy, const char *arg)
|
||||
server_rec *s = cmd->server;
|
||||
proxy_server_conf *conf =
|
||||
ap_get_module_config(s->module_config, &proxy_module);
|
||||
struct proxy_balancer *balancer;
|
||||
proxy_balancer *balancer;
|
||||
proxy_worker *worker;
|
||||
char *path = cmd->path;
|
||||
char *name = NULL;
|
||||
@@ -1279,7 +1279,7 @@ static const char *
|
||||
server_rec *s = cmd->server;
|
||||
proxy_server_conf *conf =
|
||||
ap_get_module_config(s->module_config, &proxy_module);
|
||||
struct proxy_balancer *balancer;
|
||||
proxy_balancer *balancer;
|
||||
const char *name, *sticky;
|
||||
|
||||
if (r != NULL && cmd->path == NULL ) {
|
||||
@@ -1540,14 +1540,14 @@ APR_IMPLEMENT_EXTERNAL_HOOK_RUN_FIRST(proxy, PROXY, int, canon_handler,
|
||||
url),DECLINED)
|
||||
APR_IMPLEMENT_EXTERNAL_HOOK_RUN_FIRST(proxy, PROXY, int, pre_request, (
|
||||
proxy_worker **worker,
|
||||
struct proxy_balancer **balancer,
|
||||
proxy_balancer **balancer,
|
||||
request_rec *r,
|
||||
proxy_server_conf *conf,
|
||||
char **url),(worker,balancer,
|
||||
r,conf,url),DECLINED)
|
||||
APR_IMPLEMENT_EXTERNAL_HOOK_RUN_FIRST(proxy, PROXY, int, post_request,
|
||||
(proxy_worker *worker,
|
||||
struct proxy_balancer *balancer,
|
||||
proxy_balancer *balancer,
|
||||
request_rec *r,
|
||||
proxy_server_conf *conf),(worker,
|
||||
balancer,r,conf),DECLINED)
|
||||
|
@@ -173,6 +173,11 @@ typedef struct {
|
||||
|
||||
} proxy_server_conf;
|
||||
|
||||
typedef struct proxy_balancer proxy_balancer;
|
||||
typedef struct proxy_worker proxy_worker;
|
||||
typedef struct proxy_conn proxy_conn;
|
||||
typedef struct proxy_conn_pool proxy_conn_pool;
|
||||
|
||||
typedef struct {
|
||||
const char *p; /* The path */
|
||||
int p_is_fnmatch; /* Is this path an fnmatch candidate? */
|
||||
@@ -180,10 +185,16 @@ typedef struct {
|
||||
} proxy_dir_conf;
|
||||
|
||||
typedef struct {
|
||||
conn_rec *connection;
|
||||
char *hostname;
|
||||
apr_port_t port;
|
||||
int is_ssl;
|
||||
conn_rec *connection;
|
||||
const char *hostname;
|
||||
apr_port_t port;
|
||||
int is_ssl;
|
||||
apr_pool_t *pool; /* Subpool used for creating socket */
|
||||
apr_socket_t *sock; /* Connection socket */
|
||||
apr_uint32_t flags; /* Conection flags */
|
||||
int close; /* Close 'this' connection */
|
||||
proxy_worker *worker; /* Connection pool this connection belogns to */
|
||||
void *data; /* per scheme connection data */
|
||||
} proxy_conn_rec;
|
||||
|
||||
typedef struct {
|
||||
@@ -191,26 +202,18 @@ typedef struct {
|
||||
int content_length; /* length of the content */
|
||||
} proxy_completion;
|
||||
|
||||
/* Physical connection to the backend server */
|
||||
typedef struct {
|
||||
apr_pool_t *pool; /* Subpool used for creating socket */
|
||||
apr_socket_t *sock;
|
||||
int flags; /* 0: newly created 1: initialized -1: in error */
|
||||
int close; /* Close 'this' connection */
|
||||
} proxy_conn;
|
||||
|
||||
/* Connection pool */
|
||||
typedef struct {
|
||||
struct proxy_conn_pool {
|
||||
apr_pool_t *pool; /* The pool used in constructor and destructor calls */
|
||||
apr_sockaddr_t *addr; /* Preparsed remote address info */
|
||||
#if APR_HAS_THREADS
|
||||
apr_reslist_t *res; /* Connection resource list */
|
||||
#endif
|
||||
proxy_conn *conn; /* Single connection for prefork mpm's */
|
||||
} proxy_conn_pool;
|
||||
proxy_conn_rec *conn; /* Single connection for prefork mpm's */
|
||||
};
|
||||
|
||||
/* Worker configuration */
|
||||
typedef struct {
|
||||
struct proxy_worker {
|
||||
int status;
|
||||
apr_time_t error_time; /* time of the last error */
|
||||
apr_interval_time_t retry; /* retry interval */
|
||||
@@ -229,10 +232,11 @@ typedef struct {
|
||||
|
||||
proxy_conn_pool *cp; /* Connection pool to use */
|
||||
void *opaque; /* per scheme worker data */
|
||||
} proxy_worker;
|
||||
};
|
||||
|
||||
/* Runtime worker status informations. Shared in scoreboard */
|
||||
typedef struct {
|
||||
proxy_balancer *b; /* balancer containing this worker */
|
||||
proxy_worker *w;
|
||||
double lbfactor; /* dynamic lbfactor */
|
||||
double lbsatus; /* Current lbstatus */
|
||||
@@ -352,9 +356,9 @@ PROXY_DECLARE(int) ap_proxy_ssl_disable(conn_rec *c);
|
||||
PROXY_DECLARE(proxy_worker *) ap_proxy_get_worker(apr_pool_t *p, proxy_server_conf *conf, const char *url);
|
||||
PROXY_DECLARE(const char *) ap_proxy_add_worker(proxy_worker **worker, apr_pool_t *p, proxy_server_conf *conf, const char *url);
|
||||
PROXY_DECLARE(struct proxy_balancer *) ap_proxy_get_balancer(apr_pool_t *p, proxy_server_conf *conf, const char *url);
|
||||
PROXY_DECLARE(const char *) ap_proxy_add_balancer(struct proxy_balancer **balancer, apr_pool_t *p, proxy_server_conf *conf, const char *url);
|
||||
PROXY_DECLARE(void) ap_proxy_add_worker_to_balancer(struct proxy_balancer *balancer, proxy_worker *worker);
|
||||
PROXY_DECLARE(int) ap_proxy_pre_request(proxy_worker **worker, struct proxy_balancer **balancer, request_rec *r, proxy_server_conf *conf, char **url);
|
||||
PROXY_DECLARE(const char *) ap_proxy_add_balancer(proxy_balancer **balancer, apr_pool_t *p, proxy_server_conf *conf, const char *url);
|
||||
PROXY_DECLARE(void) ap_proxy_add_worker_to_balancer(proxy_balancer *balancer, proxy_worker *worker);
|
||||
PROXY_DECLARE(int) ap_proxy_pre_request(proxy_worker **worker, proxy_balancer **balancer, request_rec *r, proxy_server_conf *conf, char **url);
|
||||
PROXY_DECLARE(apr_status_t) ap_proxy_determine_connection(apr_pool_t *p, request_rec *r, proxy_server_conf *conf, proxy_module_conf *mconf,
|
||||
apr_pool_t *ppool, apr_uri_t *uri, char **url, const char *proxyname, apr_port_t proxyport,
|
||||
char *server_portstr, int server_portstr_size);
|
||||
|
@@ -988,11 +988,11 @@ PROXY_DECLARE(void) ap_proxy_table_unmerge(apr_pool_t *p, apr_table_t *t, char *
|
||||
apr_table_add(t, key, value + offset);
|
||||
}
|
||||
|
||||
PROXY_DECLARE(struct proxy_balancer *) ap_proxy_get_balancer(apr_pool_t *p,
|
||||
proxy_server_conf *conf,
|
||||
const char *url)
|
||||
PROXY_DECLARE(proxy_balancer *) ap_proxy_get_balancer(apr_pool_t *p,
|
||||
proxy_server_conf *conf,
|
||||
const char *url)
|
||||
{
|
||||
struct proxy_balancer *balancer;
|
||||
proxy_balancer *balancer;
|
||||
char *c, *uri = apr_pstrdup(p, url);
|
||||
int i;
|
||||
|
||||
@@ -1002,7 +1002,7 @@ PROXY_DECLARE(struct proxy_balancer *) ap_proxy_get_balancer(apr_pool_t *p,
|
||||
/* remove path from uri */
|
||||
if ((c = strchr(c + 3, '/')))
|
||||
*c = '\0';
|
||||
balancer = (struct proxy_balancer *)conf->balancers->elts;
|
||||
balancer = (proxy_balancer *)conf->balancers->elts;
|
||||
for (i = 0; i < conf->balancers->nelts; i++) {
|
||||
if (strcasecmp(balancer->name, uri) == 0)
|
||||
return balancer;
|
||||
@@ -1011,7 +1011,7 @@ PROXY_DECLARE(struct proxy_balancer *) ap_proxy_get_balancer(apr_pool_t *p,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PROXY_DECLARE(const char *) ap_proxy_add_balancer(struct proxy_balancer **balancer,
|
||||
PROXY_DECLARE(const char *) ap_proxy_add_balancer(proxy_balancer **balancer,
|
||||
apr_pool_t *p,
|
||||
proxy_server_conf *conf,
|
||||
const char *url)
|
||||
@@ -1155,7 +1155,7 @@ PROXY_DECLARE(const char *) ap_proxy_add_worker(proxy_worker **worker,
|
||||
}
|
||||
|
||||
PROXY_DECLARE(void)
|
||||
ap_proxy_add_worker_to_balancer(struct proxy_balancer *balancer, proxy_worker *worker)
|
||||
ap_proxy_add_worker_to_balancer(proxy_balancer *balancer, proxy_worker *worker)
|
||||
{
|
||||
int i;
|
||||
double median, ffactor = 0.0;
|
||||
@@ -1202,7 +1202,7 @@ ap_proxy_add_worker_to_balancer(struct proxy_balancer *balancer, proxy_worker *w
|
||||
}
|
||||
|
||||
PROXY_DECLARE(int) ap_proxy_pre_request(proxy_worker **worker,
|
||||
struct proxy_balancer **balancer,
|
||||
proxy_balancer **balancer,
|
||||
request_rec *r,
|
||||
proxy_server_conf *conf, char **url)
|
||||
{
|
||||
@@ -1226,7 +1226,7 @@ PROXY_DECLARE(int) ap_proxy_pre_request(proxy_worker **worker,
|
||||
}
|
||||
|
||||
PROXY_DECLARE(int) ap_proxy_post_request(proxy_worker *worker,
|
||||
struct proxy_balancer *balancer,
|
||||
proxy_balancer *balancer,
|
||||
request_rec *r,
|
||||
proxy_server_conf *conf)
|
||||
{
|
||||
@@ -1315,7 +1315,7 @@ PROXY_DECLARE(int) ap_proxy_connect_to_backend(apr_socket_t **newsock,
|
||||
|
||||
static apr_status_t proxy_conn_cleanup(void *theconn)
|
||||
{
|
||||
proxy_conn *conn = (proxy_conn *)theconn;
|
||||
proxy_conn_rec *conn = (proxy_conn_rec *)theconn;
|
||||
/* Close the socket */
|
||||
if (conn->sock)
|
||||
apr_socket_close(conn->sock);
|
||||
@@ -1328,7 +1328,7 @@ static apr_status_t connection_constructor(void **resource, void *params,
|
||||
apr_pool_t *pool)
|
||||
{
|
||||
apr_pool_t *ctx;
|
||||
proxy_conn *conn;
|
||||
proxy_conn_rec *conn;
|
||||
server_rec *s = (server_rec *)params;
|
||||
|
||||
/* Create the subpool for each connection
|
||||
@@ -1336,7 +1336,7 @@ static apr_status_t connection_constructor(void **resource, void *params,
|
||||
* when disconnecting from backend.
|
||||
*/
|
||||
apr_pool_create(&ctx, pool);
|
||||
conn = apr_pcalloc(ctx, sizeof(proxy_conn));
|
||||
conn = apr_pcalloc(ctx, sizeof(proxy_conn_rec));
|
||||
|
||||
conn->pool = ctx;
|
||||
*resource = conn;
|
||||
@@ -1354,7 +1354,7 @@ static apr_status_t connection_constructor(void **resource, void *params,
|
||||
static apr_status_t connection_destructor(void *resource, void *params,
|
||||
apr_pool_t *pool)
|
||||
{
|
||||
proxy_conn *conn = (proxy_conn *)resource;
|
||||
proxy_conn_rec *conn = (proxy_conn_rec *)resource;
|
||||
server_rec *s = (server_rec *)params;
|
||||
|
||||
apr_pool_destroy(conn->pool);
|
||||
@@ -1378,7 +1378,7 @@ static apr_status_t init_conn_worker(proxy_worker *worker, server_rec *s)
|
||||
else
|
||||
#endif
|
||||
{
|
||||
worker->cp->conn = apr_pcalloc(worker->cp->pool, sizeof(proxy_conn));
|
||||
worker->cp->conn = apr_pcalloc(worker->cp->pool, sizeof(proxy_conn_rec));
|
||||
/* register the pool cleanup.
|
||||
* The cleanup is registered on conn_pool pool, so that
|
||||
* the same mechanism (apr_pool_cleanup) can be used
|
||||
|
Reference in New Issue
Block a user