From f39cf0c6c01b2b21a6531479b11151f57852d7e5 Mon Sep 17 00:00:00 2001 From: Radoslav Husar Date: Thu, 14 May 2026 09:25:20 +0200 Subject: [PATCH] [#386] Rename PascalCase C identifiers to snake_case and add naming convention CI check Signed-off-by: Radoslav Husar --- .github/workflows/ci-ignored-workaround.yml | 6 + .github/workflows/ci.yml | 27 ++ native/.clang-tidy | 8 + native/balancers/mod_lbmethod_cluster.c | 2 +- native/common/common.c | 8 +- native/include/balancer.h | 14 +- native/include/domain.h | 14 +- native/include/host.h | 2 +- native/include/node.h | 24 +- native/include/sessionid.h | 2 +- native/mod_manager/domain.c | 8 +- native/mod_manager/mod_manager.c | 424 ++++++++++--------- native/mod_manager/node.c | 18 +- native/mod_proxy_cluster/mod_proxy_cluster.c | 132 +++--- 14 files changed, 366 insertions(+), 323 deletions(-) create mode 100644 native/.clang-tidy diff --git a/.github/workflows/ci-ignored-workaround.yml b/.github/workflows/ci-ignored-workaround.yml index 397c0eef..4f35e429 100644 --- a/.github/workflows/ci-ignored-workaround.yml +++ b/.github/workflows/ci-ignored-workaround.yml @@ -28,6 +28,12 @@ jobs: - name: Skip run: echo "Skipping the job" + clang-tidy-naming-check: + runs-on: ubuntu-latest + steps: + - name: Skip + run: echo "Skipping the job" + make-fedora-latest: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 97d92c18..59bda582 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -133,6 +133,33 @@ jobs: done; exit $code + clang-tidy-naming-check: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v6 + with: + path: mod_proxy_cluster + - name: Install clang-tidy + run: | + sudo apt-get update + sudo apt-get install -y clang-tidy + - name: Check naming conventions + run: | + code=0 + cd mod_proxy_cluster/native + for file in */*.c */*.h; do + output=$(clang-tidy --checks='-*,readability-identifier-naming' "$file" -- -I/usr/include/apache2 -I/usr/include/apr-1.0 2>&1 | grep 'warning:.*identifier naming' || true) + if [ -z "$output" ]; then + printf "%-42s ... OK\n" "$file" + else + echo "$output" + printf "%-42s ... NOK\n" "$file" + code=1 + fi + done + exit $code + make-httpd-maintainer-mode: runs-on: ubuntu-latest strategy: diff --git a/native/.clang-tidy b/native/.clang-tidy new file mode 100644 index 00000000..613e3457 --- /dev/null +++ b/native/.clang-tidy @@ -0,0 +1,8 @@ +Checks: '-*,readability-identifier-naming' +CheckOptions: + - key: readability-identifier-naming.LocalVariableCase + value: lower_case + - key: readability-identifier-naming.ParameterCase + value: lower_case + - key: readability-identifier-naming.MemberCase + value: lower_case diff --git a/native/balancers/mod_lbmethod_cluster.c b/native/balancers/mod_lbmethod_cluster.c index 7f9860f2..472cc554 100644 --- a/native/balancers/mod_lbmethod_cluster.c +++ b/native/balancers/mod_lbmethod_cluster.c @@ -18,7 +18,7 @@ static struct domain_storage_method *domain_storage = NULL; static apr_table_t *proxyhctemplate; static void (*set_proxyhctemplate_f)(apr_pool_t *, apr_table_t *) = NULL; -static int use_alias = 0; /* 1 : Compare Alias with server_name */ +static int use_alias = 0; /* 1 : Compare alias with server_name */ static int use_nocanon = 0; static apr_time_t lbstatus_recalc_time = apr_time_from_sec(5); /* recalcul the lbstatus based on number of request in the time interval */ diff --git a/native/common/common.c b/native/common/common.c index f9210fd7..a8ffa248 100644 --- a/native/common/common.c +++ b/native/common/common.c @@ -491,11 +491,11 @@ static apr_status_t find_nodedomain(request_rec *r, const char **domain, char *r /* XXX JFCLERE!!!! domaininfo_t *dom; */ ap_log_error(APLOG_MARK, APLOG_TRACE4, 0, r->server, "find_nodedomain: finding node for %s: %s", route, balancer); for (i = 0; i < node_table->sizenode; i++) { - if (strcmp(node_table->node_info[i].mess.JVMRoute, route) == 0) { + if (strcmp(node_table->node_info[i].mess.jvm_route, route) == 0) { const nodeinfo_t *ou = &node_table->node_info[i]; if (!strcasecmp(balancer, ou->mess.balancer)) { - if (ou->mess.Domain[0] != '\0') { - *domain = ou->mess.Domain; + if (ou->mess.domain[0] != '\0') { + *domain = ou->mess.domain; } return APR_SUCCESS; } @@ -600,7 +600,7 @@ nodeinfo_t *table_get_node_route(proxy_node_table *node_table, char *route, int { int i; for (i = 0; i < node_table->sizenode; i++) { - if (!strcmp(node_table->node_info[i].mess.JVMRoute, route)) { + if (!strcmp(node_table->node_info[i].mess.jvm_route, route)) { *id = node_table->nodes[i]; return &node_table->node_info[i]; } diff --git a/native/include/balancer.h b/native/include/balancer.h index ad31dca3..fdbc00f4 100644 --- a/native/include/balancer.h +++ b/native/include/balancer.h @@ -33,13 +33,13 @@ struct balancerinfo /* NOTE: Due to `loc_get_id`, struct MUST begin with id */ int id; /* id in table */ char balancer[BALANCERSZ]; /* Name of the balancer */ - int StickySession; /* 0 : Don't use, 1: Use it */ - char StickySessionCookie[COOKNAMESZ]; - char StickySessionPath[PATHNAMESZ]; - int StickySessionRemove; /* 0 : Don't remove, 1: Remove it */ - int StickySessionForce; /* 0: Don't force, 1: return error */ - int Timeout; - int Maxattempts; + int sticky_session; /* 0 : Don't use, 1: Use it */ + char sticky_session_cookie[COOKNAMESZ]; + char sticky_session_path[PATHNAMESZ]; + int sticky_session_remove; /* 0 : Don't remove, 1: Remove it */ + int sticky_session_force; /* 0: Don't force, 1: return error */ + int timeout; + int max_attempts; apr_time_t updatetime; /* time of last received message */ }; diff --git a/native/include/domain.h b/native/include/domain.h index 8ed15c2c..50d74855 100644 --- a/native/include/domain.h +++ b/native/include/domain.h @@ -31,10 +31,10 @@ typedef struct mem mem_t; struct domaininfo { /* NOTE: Due to `loc_get_id`, struct MUST begin with id */ - int id; /* id in table */ - char domain[DOMAINNDSZ]; /* domain value */ - char JVMRoute[JVMROUTESZ]; /* corresponding node */ - char balancer[BALANCERSZ]; /* name of the balancer */ + int id; /* id in table */ + char domain[DOMAINNDSZ]; /* domain value */ + char jvm_route[JVMROUTESZ]; /* corresponding node */ + char balancer[BALANCERSZ]; /* name of the balancer */ apr_time_t updatetime; /* time of last received message */ }; @@ -74,10 +74,10 @@ apr_status_t get_domain(mem_t *s, domaininfo_t **domain, int ids); apr_status_t remove_domain(mem_t *s, domaininfo_t *domain); /** - * Find a domain record from the shared table using JVMRoute and balancer + * Find a domain record from the shared table using jvm_route and balancer * @param s pointer to the shared table * @param domain address where the node is located in the shared table - * @param route JVMRoute to search + * @param route jvm_route to search * @param balancer balancer to search * @return APR_SUCCESS if all went well */ @@ -153,7 +153,7 @@ struct domain_storage_method */ apr_status_t (*insert_update_domain)(domaininfo_t *domain); /** - * Find the domain using the JVMRoute and balancer information + * Find the domain using the jvm_route and balancer information * @return APR_SUCCESS if all went well */ apr_status_t (*find_domain)(domaininfo_t **node, const char *route, const char *balancer); diff --git a/native/include/host.h b/native/include/host.h index e3378dfd..8a552dad 100644 --- a/native/include/host.h +++ b/native/include/host.h @@ -32,7 +32,7 @@ struct hostinfo { /* NOTE: Due to `loc_get_id`, struct MUST begin with id */ int id; /* id in table */ - char host[HOSTALIASZ + 1]; /* Alias element of the virtual host */ + char host[HOSTALIASZ + 1]; /* alias element of the virtual host */ int vhost; /* id of the correspond virtual host */ int node; /* id of the node containing the virtual host */ diff --git a/native/include/node.h b/native/include/node.h index fa0149e5..bc79eb9c 100644 --- a/native/include/node.h +++ b/native/include/node.h @@ -35,16 +35,16 @@ struct nodemess /* balancer info */ char balancer[BALANCERSZ]; /* name of the balancer */ - char JVMRoute[JVMROUTESZ]; - char Domain[DOMAINNDSZ]; - char Host[HOSTNODESZ]; - char Port[PORTNODESZ]; - char Type[SCHEMENDSZ]; - char Upgrade[SCHEMENDSZ]; - char AJPSecret[AJPSECRETSZ]; + char jvm_route[JVMROUTESZ]; + char domain[DOMAINNDSZ]; + char host[HOSTNODESZ]; + char port[PORTNODESZ]; + char type[SCHEMENDSZ]; + char upgrade[SCHEMENDSZ]; + char ajp_secret[AJPSECRETSZ]; int reversed; /* 1 : reversed... 0 : normal */ int remove; /* 1 : removed 0 : normal */ - long ResponseFieldSize; + long response_field_size; unsigned has_workers; /* node conf part */ @@ -126,16 +126,16 @@ apr_status_t get_node(mem_t *s, nodeinfo_t **node, int ids); apr_status_t remove_node(mem_t *s, int ids); /** - * Find a node record from the shared table using JVMRoute + * Find a node record from the shared table using jvm_route * @param s pointer to the shared table * @param node address where the node is located in the shared table - * @param route JVMRoute to search + * @param route jvm_route to search * @return APR_SUCCESS if all went well */ apr_status_t find_node(mem_t *s, nodeinfo_t **node, const char *route); /** - * Find a node record from the shared table using Host/Port + * Find a node record from the shared table using host/port * @param s pointer to the shared table * @param node address where the node is located in the shared table * @param host host to search @@ -227,7 +227,7 @@ struct node_storage_method */ int (*remove_node)(int node); /** - * Find the node using the JVMRoute information + * Find the node using the jvm_route information */ apr_status_t (*find_node)(nodeinfo_t **node, const char *route); /** diff --git a/native/include/sessionid.h b/native/include/sessionid.h index 087ceb17..c55be54a 100644 --- a/native/include/sessionid.h +++ b/native/include/sessionid.h @@ -33,7 +33,7 @@ struct sessionidinfo /* NOTE: Due to `loc_get_id`, struct MUST begin with id */ int id; /* id in table */ char sessionid[SESSIONIDSZ + 1]; /* Sessionid value */ - char JVMRoute[JVMROUTESZ + 1]; /* corresponding node */ + char jvm_route[JVMROUTESZ + 1]; /* corresponding node */ apr_time_t updatetime; /* time of last received message */ }; diff --git a/native/mod_manager/domain.c b/native/mod_manager/domain.c index e3f54ba6..ec666435 100644 --- a/native/mod_manager/domain.c +++ b/native/mod_manager/domain.c @@ -55,7 +55,7 @@ static apr_status_t update(void *mem, void *data, apr_pool_t *pool) domaininfo_t *ou = (domaininfo_t *)mem; (void)pool; - if (strcmp(in->JVMRoute, ou->JVMRoute) == 0 && strcmp(in->balancer, ou->balancer) == 0) { + if (strcmp(in->jvm_route, ou->jvm_route) == 0 && strcmp(in->balancer, ou->balancer) == 0) { in->id = ou->id; memcpy(ou, in, sizeof(domaininfo_t)); ou->updatetime = apr_time_sec(apr_time_now()); @@ -104,7 +104,7 @@ static apr_status_t loc_read_domain(void *mem, void *data, apr_pool_t *pool) domaininfo_t *ou = (domaininfo_t *)mem; (void)pool; - if (strcmp(in->JVMRoute, ou->JVMRoute) == 0 && strcmp(in->balancer, ou->balancer) == 0) { + if (strcmp(in->jvm_route, ou->jvm_route) == 0 && strcmp(in->balancer, ou->balancer) == 0) { in->id = ou->id; return APR_EEXIST; } @@ -155,8 +155,8 @@ apr_status_t find_domain(mem_t *s, domaininfo_t **domain, const char *route, con domaininfo_t ou; apr_status_t rv; - strncpy(ou.JVMRoute, route, sizeof(ou.JVMRoute)); - ou.JVMRoute[sizeof(ou.JVMRoute) - 1] = '\0'; + strncpy(ou.jvm_route, route, sizeof(ou.jvm_route)); + ou.jvm_route[sizeof(ou.jvm_route) - 1] = '\0'; strncpy(ou.balancer, balancer, sizeof(ou.balancer)); ou.balancer[sizeof(ou.balancer) - 1] = '\0'; *domain = &ou; diff --git a/native/mod_manager/mod_manager.c b/native/mod_manager/mod_manager.c index 6eb93910..d172178d 100644 --- a/native/mod_manager/mod_manager.c +++ b/native/mod_manager/mod_manager.c @@ -731,7 +731,7 @@ static apr_status_t insert_update_host_helper(server_rec *s, mem_t *mem, hostinf } /** - * Insert the hosts from Alias information + * Insert the hosts from alias information */ static apr_status_t insert_update_hosts(server_rec *s, mem_t *mem, char *str, int node, int vhost) { @@ -839,13 +839,13 @@ static int is_same_node(const nodeinfo_t *nodeinfo, const nodeinfo_t *node) if (strcmp(nodeinfo->mess.balancer, node->mess.balancer)) { return 0; } - if (strcmp(nodeinfo->mess.Host, node->mess.Host)) { + if (strcmp(nodeinfo->mess.host, node->mess.host)) { return 0; } - if (strcmp(nodeinfo->mess.Port, node->mess.Port)) { + if (strcmp(nodeinfo->mess.port, node->mess.port)) { return 0; } - if (strcmp(nodeinfo->mess.Type, node->mess.Type)) { + if (strcmp(nodeinfo->mess.type, node->mess.type)) { return 0; } if (nodeinfo->mess.reversed != node->mess.reversed) { @@ -884,18 +884,18 @@ static int is_same_worker_existing(const request_rec *r, const nodeinfo_t *node) } if (is_same_node(ou, node)) { /* we have a node that corresponds to the same worker */ - if (!strcmp(ou->mess.JVMRoute, node->mess.JVMRoute)) { + if (!strcmp(ou->mess.jvm_route, node->mess.jvm_route)) { return 0; /* well it is the same */ } if (ou->mess.remove) { - if (strcmp(ou->mess.JVMRoute, "REMOVED") == 0) { + if (strcmp(ou->mess.jvm_route, "REMOVED") == 0) { /* Look in remove_removed_node, only "REMOVED" have cleaned the contexts/hosts */ return 0; /* well it marked removed */ } } ap_log_error(APLOG_MARK, APLOG_WARNING, 0, r->server, - "process_config: nodes %s and %s correspond to the same worker", node->mess.JVMRoute, - ou->mess.JVMRoute); + "process_config: nodes %s and %s correspond to the same worker", node->mess.jvm_route, + ou->mess.jvm_route); return 1; } } @@ -917,14 +917,15 @@ static apr_status_t mod_manager_manage_worker(request_rec *r, const nodeinfo_t * /* balancer */ apr_table_set(params, "b", node->mess.balancer); apr_table_set(params, "b_lbm", "cluster"); - apr_table_set(params, "b_tmo", apr_psprintf(r->pool, "%d", bal->Timeout)); - apr_table_set(params, "b_max", apr_psprintf(r->pool, "%d", bal->Maxattempts)); - apr_table_set(params, "b_ss", apr_pstrcat(r->pool, bal->StickySessionCookie, "|", bal->StickySessionPath, NULL)); + apr_table_set(params, "b_tmo", apr_psprintf(r->pool, "%d", bal->timeout)); + apr_table_set(params, "b_max", apr_psprintf(r->pool, "%d", bal->max_attempts)); + apr_table_set(params, "b_ss", + apr_pstrcat(r->pool, bal->sticky_session_cookie, "|", bal->sticky_session_path, NULL)); /* and new worker */ apr_table_set(params, "b_wyes", "1"); apr_table_set(params, "b_nwrkr", - apr_pstrcat(r->pool, node->mess.Type, "://", node->mess.Host, ":", node->mess.Port, NULL)); + apr_pstrcat(r->pool, node->mess.type, "://", node->mess.host, ":", node->mess.port, NULL)); rv = balancer_manage(r, params); if (rv != APR_SUCCESS) { return rv; @@ -934,13 +935,13 @@ static apr_status_t mod_manager_manage_worker(request_rec *r, const nodeinfo_t * /* now process the worker */ apr_table_set(params, "b", node->mess.balancer); apr_table_set(params, "w", - apr_pstrcat(r->pool, node->mess.Type, "://", node->mess.Host, ":", node->mess.Port, NULL)); - apr_table_set(params, "w_wr", node->mess.JVMRoute); + apr_pstrcat(r->pool, node->mess.type, "://", node->mess.host, ":", node->mess.port, NULL)); + apr_table_set(params, "w_wr", node->mess.jvm_route); apr_table_set(params, "w_status_D", "0"); /* Not Dissabled */ /* set the health check (requires mod_proxy_hcheck) */ /* CPING for AJP and OPTIONS for HTTP/1.1 */ - apr_table_set(params, "w_hm", strcmp(node->mess.Type, "ajp") ? "OPTIONS" : "CPING"); + apr_table_set(params, "w_hm", strcmp(node->mess.type, "ajp") ? "OPTIONS" : "CPING"); /* Use 10 sec for the moment, the idea is to adjust it with the STATUS frequency */ apr_table_set(params, "w_hi", "10000"); @@ -965,8 +966,8 @@ static proxy_worker *proxy_node_getid(request_rec *r, const nodeinfo_t *nodeinfo const proxy_server_conf **the_conf) { if (balancerhandler != NULL) { - return balancerhandler->proxy_node_getid(r, nodeinfo->mess.balancer, nodeinfo->mess.Type, nodeinfo->mess.Host, - nodeinfo->mess.Port, id, the_conf); + return balancerhandler->proxy_node_getid(r, nodeinfo->mess.balancer, nodeinfo->mess.type, nodeinfo->mess.host, + nodeinfo->mess.port, id, the_conf); } return NULL; } @@ -1014,13 +1015,13 @@ static void process_config_balancer_defaults(request_rec *r, balancerinfo_t *bal } else { strcpy(balancerinfo->balancer, "mycluster"); } - balancerinfo->StickySession = 1; - balancerinfo->StickySessionForce = 1; - balancerinfo->StickySessionRemove = 0; - strcpy(balancerinfo->StickySessionCookie, "JSESSIONID"); - strcpy(balancerinfo->StickySessionPath, "jsessionid"); - balancerinfo->Maxattempts = 1; - balancerinfo->Timeout = 0; + balancerinfo->sticky_session = 1; + balancerinfo->sticky_session_force = 1; + balancerinfo->sticky_session_remove = 0; + strcpy(balancerinfo->sticky_session_cookie, "JSESSIONID"); + strcpy(balancerinfo->sticky_session_path, "jsessionid"); + balancerinfo->max_attempts = 1; + balancerinfo->timeout = 0; } static void process_config_node_defaults(request_rec *r, nodeinfo_t *nodeinfo, mod_manager_config *mconf) @@ -1033,11 +1034,11 @@ static void process_config_node_defaults(request_rec *r, nodeinfo_t *nodeinfo, m } else { strcpy(nodeinfo->mess.balancer, "mycluster"); } - strcpy(nodeinfo->mess.Host, "localhost"); - strcpy(nodeinfo->mess.Port, "8009"); - strcpy(nodeinfo->mess.Type, "ajp"); - nodeinfo->mess.Upgrade[0] = '\0'; - nodeinfo->mess.AJPSecret[0] = '\0'; + strcpy(nodeinfo->mess.host, "localhost"); + strcpy(nodeinfo->mess.port, "8009"); + strcpy(nodeinfo->mess.type, "ajp"); + nodeinfo->mess.upgrade[0] = '\0'; + nodeinfo->mess.ajp_secret[0] = '\0'; nodeinfo->mess.reversed = 0; nodeinfo->mess.remove = 0; /* not marked as removed */ nodeinfo->mess.flushpackets = flush_off; /* FLUSH_OFF; See enum flush_packets in proxy.h flush_off */ @@ -1066,35 +1067,35 @@ static char *process_config_balancer(const request_rec *r, const char *key, char balancerinfo->balancer[sizeof(balancerinfo->balancer) - 1] = '\0'; } if (strcasecmp(key, "StickySession") == 0) { - process_boolean_parameter(val, &balancerinfo->StickySession); + process_boolean_parameter(val, &balancerinfo->sticky_session); } if (strcasecmp(key, "StickySessionCookie") == 0) { - if (strlen(val) >= sizeof(balancerinfo->StickySessionCookie)) { + if (strlen(val) >= sizeof(balancerinfo->sticky_session_cookie)) { *errtype = TYPESYNTAX; return SBAFBIG; } - strcpy(balancerinfo->StickySessionCookie, val); + strcpy(balancerinfo->sticky_session_cookie, val); } if (strcasecmp(key, "StickySessionPath") == 0) { - if (strlen(val) >= sizeof(balancerinfo->StickySessionPath)) { + if (strlen(val) >= sizeof(balancerinfo->sticky_session_path)) { *errtype = TYPESYNTAX; return SBAFBIG; } - strcpy(balancerinfo->StickySessionPath, val); + strcpy(balancerinfo->sticky_session_path, val); } if (strcasecmp(key, "StickySessionRemove") == 0) { - process_boolean_parameter(val, &balancerinfo->StickySessionRemove); + process_boolean_parameter(val, &balancerinfo->sticky_session_remove); } - /* The java part assumes default = yes and sents only StickySessionForce=No */ + /* The java part assumes default = yes and sents only sticky_session_force=No */ if (strcasecmp(key, "StickySessionForce") == 0) { - process_boolean_parameter(val, &balancerinfo->StickySessionForce); + process_boolean_parameter(val, &balancerinfo->sticky_session_force); } /* Note that it is workerTimeout (set/getWorkerTimeout in java code) */ if (strcasecmp(key, "WaitWorker") == 0) { - balancerinfo->Timeout = apr_time_from_sec(atoi(val)); + balancerinfo->timeout = apr_time_from_sec(atoi(val)); } if (strcasecmp(key, "Maxattempts") == 0) { - balancerinfo->Maxattempts = atoi(val); + balancerinfo->max_attempts = atoi(val); } return NULL; @@ -1105,24 +1106,24 @@ static char *process_config_node(const char *key, char *val, nodeinfo_t *nodeinf apr_interval_time_t time; if (strcasecmp(key, "JVMRoute") == 0) { - if (strlen(val) >= sizeof(nodeinfo->mess.JVMRoute)) { + if (strlen(val) >= sizeof(nodeinfo->mess.jvm_route)) { *errtype = TYPESYNTAX; return SROUBIG; } - strcpy(nodeinfo->mess.JVMRoute, val); + strcpy(nodeinfo->mess.jvm_route, val); } /* We renamed it LBGroup */ if (strcasecmp(key, "Domain") == 0) { - if (strlen(val) >= sizeof(nodeinfo->mess.Domain)) { + if (strlen(val) >= sizeof(nodeinfo->mess.domain)) { *errtype = TYPESYNTAX; return SDOMBIG; } - strcpy(nodeinfo->mess.Domain, val); + strcpy(nodeinfo->mess.domain, val); } if (strcasecmp(key, "Host") == 0) { char *p_read = val, *p_write = val; int flag = 0; - if (strlen(val) >= sizeof(nodeinfo->mess.Host)) { + if (strlen(val) >= sizeof(nodeinfo->mess.host)) { *errtype = TYPESYNTAX; return SHOSBIG; } @@ -1138,21 +1139,21 @@ static char *process_config_node(const char *key, char *val, nodeinfo_t *nodeinf } *p_write = '\0'; } - strcpy(nodeinfo->mess.Host, val); + strcpy(nodeinfo->mess.host, val); } if (strcasecmp(key, "Port") == 0) { - if (strlen(val) >= sizeof(nodeinfo->mess.Port)) { + if (strlen(val) >= sizeof(nodeinfo->mess.port)) { *errtype = TYPESYNTAX; return SPORBIG; } - strcpy(nodeinfo->mess.Port, val); + strcpy(nodeinfo->mess.port, val); } if (strcasecmp(key, "Type") == 0) { - if (strlen(val) >= sizeof(nodeinfo->mess.Type)) { + if (strlen(val) >= sizeof(nodeinfo->mess.type)) { *errtype = TYPESYNTAX; return STYPBIG; } - strcpy(nodeinfo->mess.Type, val); + strcpy(nodeinfo->mess.type, val); } if (strcasecmp(key, "Reversed") == 0) { process_boolean_parameter(val, &nodeinfo->mess.reversed); @@ -1214,7 +1215,7 @@ static nodeinfo_t *read_node_by_id(mem_t *mem, int id) static void mark_node_removed(nodeinfo_t *node) { if (node) { - strcpy(node->mess.JVMRoute, "REMOVED"); + strcpy(node->mess.jvm_route, "REMOVED"); node->mess.remove = 1; node->updatetime = apr_time_now(); node->mess.num_remove_check = 0; @@ -1227,7 +1228,7 @@ static const proxy_worker_shared *read_shared_by_node(request_rec *r, nodeinfo_t char *name = apr_pstrcat(r->pool, BALANCER_PREFIX, node->mess.balancer, NULL); proxy_server_conf *conf = (proxy_server_conf *)ap_get_module_config(sconf, &proxy_module); proxy_balancer *balancer = (proxy_balancer *)conf->balancers->elts; - if (sscanf(node->mess.Port, "%u", &port) != 1) { + if (sscanf(node->mess.port, "%u", &port) != 1) { return NULL; /* something is wrong */ } for (i = 0; i < conf->balancers->nelts; i++, balancer++) { @@ -1245,8 +1246,8 @@ static const proxy_worker_shared *read_shared_by_node(request_rec *r, nodeinfo_t ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, "read_shared_by_node: Balancer %s worker (%d) %s, %s, %d", balancer->s->name, worker->s->index, worker->s->route, worker->s->hostname, worker->s->port); - if (worker->s->port == port && strcmp(worker->s->hostname, node->mess.Host) == 0 && - strcmp(worker->s->route, node->mess.JVMRoute) == 0) { + if (worker->s->port == port && strcmp(worker->s->hostname, node->mess.host) == 0 && + strcmp(worker->s->route, node->mess.jvm_route) == 0) { return worker->s; } } @@ -1274,7 +1275,7 @@ static int check_context_alias_length(const char *str, int limit) } /** - * Process Alias and Context if present. + * Process alias and Context if present. * We process both in two different context: * 1) during CONFIG command * 2) during APP command @@ -1333,18 +1334,18 @@ static char *process_context_alias(char *key, char *val, apr_pool_t *p, char **c * Process a CONFIG message * Balancer: * - * StickySession StickySessionCookie StickySessionPath StickySessionRemove - * StickySessionForce Timeout Maxattempts + * sticky_session sticky_session_cookie sticky_session_path sticky_session_remove + * sticky_session_force timeout max_attempts * JvmRoute?: - * Domain: - * - * Port: - * Type: + * domain: + * + * port: + * type: * Reserved: * * flushpackets flushwait ping smax ttl * Virtual hosts in JBossAS - * Alias: + * alias: * Context corresponding to the applications. * Context: */ @@ -1402,36 +1403,36 @@ static char *process_config(request_rec *r, char **ptr, int *errtype) i += 2; } - /* Check for JVMRoute */ - if (nodeinfo.mess.JVMRoute[0] == '\0') { + /* Check for jvm_route */ + if (nodeinfo.mess.jvm_route[0] == '\0') { *errtype = TYPESYNTAX; return SROUBAD; } - if (mconf->enable_ws_tunnel && strcmp(nodeinfo.mess.Type, "ajp")) { - if (!strcmp(nodeinfo.mess.Type, "http")) { - strcpy(nodeinfo.mess.Type, "ws"); + if (mconf->enable_ws_tunnel && strcmp(nodeinfo.mess.type, "ajp")) { + if (!strcmp(nodeinfo.mess.type, "http")) { + strcpy(nodeinfo.mess.type, "ws"); } - if (!strcmp(nodeinfo.mess.Type, "https")) { - strcpy(nodeinfo.mess.Type, "wss"); + if (!strcmp(nodeinfo.mess.type, "https")) { + strcpy(nodeinfo.mess.type, "wss"); } if (mconf->ws_upgrade_header) { - strncpy(nodeinfo.mess.Upgrade, mconf->ws_upgrade_header, sizeof(nodeinfo.mess.Upgrade)); - nodeinfo.mess.Upgrade[sizeof(nodeinfo.mess.Upgrade) - 1] = '\0'; + strncpy(nodeinfo.mess.upgrade, mconf->ws_upgrade_header, sizeof(nodeinfo.mess.upgrade)); + nodeinfo.mess.upgrade[sizeof(nodeinfo.mess.upgrade) - 1] = '\0'; } else { - strcpy(nodeinfo.mess.Upgrade, "websocket"); + strcpy(nodeinfo.mess.upgrade, "websocket"); } } - if (strcmp(nodeinfo.mess.Type, "ajp") == 0) { + if (strcmp(nodeinfo.mess.type, "ajp") == 0) { if (mconf->ajp_secret) { - strncpy(nodeinfo.mess.AJPSecret, mconf->ajp_secret, sizeof(nodeinfo.mess.AJPSecret)); - nodeinfo.mess.AJPSecret[sizeof(nodeinfo.mess.AJPSecret) - 1] = '\0'; + strncpy(nodeinfo.mess.ajp_secret, mconf->ajp_secret, sizeof(nodeinfo.mess.ajp_secret)); + nodeinfo.mess.ajp_secret[sizeof(nodeinfo.mess.ajp_secret) - 1] = '\0'; } } - if (mconf->response_field_size && strcmp(nodeinfo.mess.Type, "ajp")) { - nodeinfo.mess.ResponseFieldSize = mconf->response_field_size; + if (mconf->response_field_size && strcmp(nodeinfo.mess.type, "ajp")) { + nodeinfo.mess.response_field_size = mconf->response_field_size; } /* Insert or update balancer description */ rv = loc_lock_nodes(); @@ -1439,7 +1440,7 @@ static char *process_config(request_rec *r, char **ptr, int *errtype) if (insert_update_balancer(balancerstatsmem, &balancerinfo) != APR_SUCCESS) { loc_unlock_nodes(); *errtype = TYPEMEM; - return apr_psprintf(r->pool, MBALAUI, nodeinfo.mess.JVMRoute); + return apr_psprintf(r->pool, MBALAUI, nodeinfo.mess.jvm_route); } /* check for removed node */ @@ -1448,10 +1449,10 @@ static char *process_config(request_rec *r, char **ptr, int *errtype) /* If the node is removed (or kill and restarted) and recreated unchanged that is ok: network problems */ if (!is_same_node(node, &nodeinfo)) { /* Here we can't update it because the old one is still in */ - char *mess = apr_psprintf(r->pool, MNODERM, node->mess.JVMRoute); + char *mess = apr_psprintf(r->pool, MNODERM, node->mess.jvm_route); ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server, - "process_config: node %s %d %s : %s %s already exists, removing...", node->mess.JVMRoute, - node->mess.id, node->mess.Port, nodeinfo.mess.JVMRoute, nodeinfo.mess.Port); + "process_config: node %s %d %s : %s %s already exists, removing...", node->mess.jvm_route, + node->mess.id, node->mess.port, nodeinfo.mess.jvm_route, nodeinfo.mess.port); mark_node_removed(node); loc_remove_host_context(node->mess.id, r->pool); inc_version_node(); @@ -1473,27 +1474,27 @@ static char *process_config(request_rec *r, char **ptr, int *errtype) /* Same node should be OK, different nodes will bring problems */ if (node != NULL && node->mess.id == id) { ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, - "process_config: worker %d (%s) exists and should be OK", id, nodeinfo.mess.JVMRoute); + "process_config: worker %d (%s) exists and should be OK", id, nodeinfo.mess.jvm_route); } else { /* Here that is the tricky part, we will insert_update the whole node including proxy_worker_shared */ char *pptr; ap_log_error(APLOG_MARK, APLOG_WARNING, 0, r->server, - "process_config: worker %d (%s) exists and IS NOT OK!!!", id, nodeinfo.mess.JVMRoute); + "process_config: worker %d (%s) exists and IS NOT OK!!!", id, nodeinfo.mess.jvm_route); if (node == NULL) { /* try to read the node */ nodeinfo_t *workernode = read_node_by_id(nodestatsmem, id); if (workernode != NULL) { - if (strcmp(workernode->mess.JVMRoute, "REMOVED") == 0) { + if (strcmp(workernode->mess.jvm_route, "REMOVED") == 0) { /* We are in the remove process */ /* Something to clean ? */ - strcpy(workernode->mess.JVMRoute, nodeinfo.mess.JVMRoute); + strcpy(workernode->mess.jvm_route, nodeinfo.mess.jvm_route); /* if the workernode->mess is zeroed we are going to reinsert it */ - } else if ((workernode->mess.JVMRoute[0] != '\0') && - (strcmp(workernode->mess.JVMRoute, nodeinfo.mess.JVMRoute) != 0)) { + } else if ((workernode->mess.jvm_route[0] != '\0') && + (strcmp(workernode->mess.jvm_route, nodeinfo.mess.jvm_route) != 0)) { ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server, "process_config: worker %d (%s) exists and does NOT correspond to %s", id, - workernode->mess.JVMRoute, nodeinfo.mess.JVMRoute); + workernode->mess.jvm_route, nodeinfo.mess.jvm_route); loc_unlock_nodes(); *errtype = TYPEMEM; return MNODEET; @@ -1511,22 +1512,22 @@ static char *process_config(request_rec *r, char **ptr, int *errtype) } } else { nodeinfo_t *workernode; - rv = find_node_byhostport(nodestatsmem, &workernode, nodeinfo.mess.Host, nodeinfo.mess.Port); + rv = find_node_byhostport(nodestatsmem, &workernode, nodeinfo.mess.host, nodeinfo.mess.port); if (rv == APR_SUCCESS) { /* Normally the node is just being removed, so no host/context but some other child might have a worker */ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, "process_config: NOT NEW (%d %s) %s %s (%s)", - workernode->mess.id, workernode->mess.JVMRoute, workernode->mess.Host, workernode->mess.Port, - nodeinfo.mess.JVMRoute); + workernode->mess.id, workernode->mess.jvm_route, workernode->mess.host, workernode->mess.port, + nodeinfo.mess.jvm_route); id = workernode->mess.id; - if (strcmp(workernode->mess.JVMRoute, "REMOVED") == 0) { - strcpy(workernode->mess.JVMRoute, nodeinfo.mess.JVMRoute); + if (strcmp(workernode->mess.jvm_route, "REMOVED") == 0) { + strcpy(workernode->mess.jvm_route, nodeinfo.mess.jvm_route); workernode->mess.remove = 0; workernode->mess.num_remove_check = 0; } } else { - ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, "process_config: NEW (%s) %s", nodeinfo.mess.JVMRoute, - nodeinfo.mess.Port); + ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, "process_config: NEW (%s) %s", nodeinfo.mess.jvm_route, + nodeinfo.mess.port); } } if (id == -1) { @@ -1534,25 +1535,25 @@ static char *process_config(request_rec *r, char **ptr, int *errtype) id = proxy_node_get_free_id(r, node_storage.get_max_size_node()); if (id == -1 && balancerhandler != NULL) { ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, - "process_config: NEW (%s) %s %s will not be added (Maxnode reached)", nodeinfo.mess.JVMRoute, - nodeinfo.mess.Host, nodeinfo.mess.Port); + "process_config: NEW (%s) %s %s will not be added (Maxnode reached)", nodeinfo.mess.jvm_route, + nodeinfo.mess.host, nodeinfo.mess.port); } else if (id != -1) { ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, "process_config: NEW (%s) %s %s in %d", - nodeinfo.mess.JVMRoute, nodeinfo.mess.Host, nodeinfo.mess.Port, id); + nodeinfo.mess.jvm_route, nodeinfo.mess.host, nodeinfo.mess.port, id); } } /* Insert or update node description */ if (insert_update_node(nodestatsmem, &nodeinfo, &id, clean) != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, - "process_config: insert_update_node failed for %s clean: %d", nodeinfo.mess.JVMRoute, clean); + "process_config: insert_update_node failed for %s clean: %d", nodeinfo.mess.jvm_route, clean); if (removed != -1) { nodeinfo_t *workernode = read_node_by_id(nodestatsmem, removed); mark_node_removed(workernode); } loc_unlock_nodes(); *errtype = TYPEMEM; - return apr_psprintf(r->pool, MNODEUI, nodeinfo.mess.JVMRoute); + return apr_psprintf(r->pool, MNODEUI, nodeinfo.mess.jvm_route); } if (clean == 0) { @@ -1561,7 +1562,7 @@ static char *process_config(request_rec *r, char **ptr, int *errtype) ap_assert(workernode != NULL); ap_assert(the_conf); ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, "process_config: worker %d (%s) inserted", id, - nodeinfo.mess.JVMRoute); + nodeinfo.mess.jvm_route); /* make sure we can use it */ ap_assert(worker->context != NULL); ap_assert(workernode->mess.id == id); @@ -1580,11 +1581,11 @@ static char *process_config(request_rec *r, char **ptr, int *errtype) worker->s->index); } else { ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, "process_config: (%s) %s inserted/updated in worker %d", - nodeinfo.mess.JVMRoute, nodeinfo.mess.Port, id); + nodeinfo.mess.jvm_route, nodeinfo.mess.port, id); } inc_version_node(); - /* Insert the Alias and corresponding Context */ + /* Insert the alias and corresponding Context */ if (aliases == NULL && contexts == NULL) { /* if using mod_balancer create or update the worker */ if (balancer_manage) { @@ -1594,18 +1595,18 @@ static char *process_config(request_rec *r, char **ptr, int *errtype) ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, "process_config: NO balancer-manager"); } loc_unlock_nodes(); - return NULL; /* Alias and Context missing */ + return NULL; /* alias and Context missing */ } if (insert_update_hosts(r->server, hoststatsmem, aliases, id, vid) != APR_SUCCESS) { loc_unlock_nodes(); - return apr_psprintf(r->pool, MHOSTUI, nodeinfo.mess.JVMRoute); + return apr_psprintf(r->pool, MHOSTUI, nodeinfo.mess.jvm_route); } if (insert_update_contexts(r->server, contextstatsmem, contexts, id, vid, STOPPED) != APR_SUCCESS) { loc_unlock_nodes(); - return apr_psprintf(r->pool, MCONTUI, nodeinfo.mess.JVMRoute); + return apr_psprintf(r->pool, MCONTUI, nodeinfo.mess.jvm_route); } vid++; @@ -1693,19 +1694,20 @@ static char *process_dump(request_rec *r, int *errtype) "%d" "%d" "", - id[i], (int)sizeof(ou->balancer), ou->balancer, ou->StickySession, - (int)sizeof(ou->StickySessionCookie), ou->StickySessionCookie, - (int)sizeof(ou->StickySessionPath), ou->StickySessionPath, ou->StickySessionRemove, - ou->StickySessionForce, (int)apr_time_sec(ou->Timeout), ou->Maxattempts); + id[i], (int)sizeof(ou->balancer), ou->balancer, ou->sticky_session, + (int)sizeof(ou->sticky_session_cookie), ou->sticky_session_cookie, + (int)sizeof(ou->sticky_session_path), ou->sticky_session_path, ou->sticky_session_remove, + ou->sticky_session_force, (int)apr_time_sec(ou->timeout), ou->max_attempts); break; case TEXT_PLAIN: default: ap_rprintf( r, "balancer: [%d] Name: %.*s Sticky: %d [%.*s]/[%.*s] remove: %d force: %d Timeout: %d maxAttempts: %d\n", - id[i], (int)sizeof(ou->balancer), ou->balancer, ou->StickySession, (int)sizeof(ou->StickySessionCookie), - ou->StickySessionCookie, (int)sizeof(ou->StickySessionPath), ou->StickySessionPath, - ou->StickySessionRemove, ou->StickySessionForce, (int)apr_time_sec(ou->Timeout), ou->Maxattempts); + id[i], (int)sizeof(ou->balancer), ou->balancer, ou->sticky_session, + (int)sizeof(ou->sticky_session_cookie), ou->sticky_session_cookie, (int)sizeof(ou->sticky_session_path), + ou->sticky_session_path, ou->sticky_session_remove, ou->sticky_session_force, + (int)apr_time_sec(ou->timeout), ou->max_attempts); break; } } @@ -1743,10 +1745,10 @@ static char *process_dump(request_rec *r, int *errtype) "%d" "%d" "", - ou->mess.id, (int)sizeof(ou->mess.balancer), ou->mess.balancer, (int)sizeof(ou->mess.JVMRoute), - ou->mess.JVMRoute, (int)sizeof(ou->mess.Domain), ou->mess.Domain, (int)sizeof(ou->mess.Host), - ou->mess.Host, (int)sizeof(ou->mess.Port), ou->mess.Port, (int)sizeof(ou->mess.Type), - ou->mess.Type, ou->mess.flushpackets, ou->mess.flushwait / 1000, + ou->mess.id, (int)sizeof(ou->mess.balancer), ou->mess.balancer, (int)sizeof(ou->mess.jvm_route), + ou->mess.jvm_route, (int)sizeof(ou->mess.domain), ou->mess.domain, (int)sizeof(ou->mess.host), + ou->mess.host, (int)sizeof(ou->mess.port), ou->mess.port, (int)sizeof(ou->mess.type), + ou->mess.type, ou->mess.flushpackets, ou->mess.flushwait / 1000, (int)apr_time_sec(ou->mess.ping), ou->mess.smax, (int)apr_time_sec(ou->mess.ttl), (int)apr_time_sec(ou->mess.timeout)); break; @@ -1756,11 +1758,11 @@ static char *process_dump(request_rec *r, int *errtype) "node: [%d:%d],Balancer: %.*s,JVMRoute: %.*s,LBGroup: [%.*s],Host: %.*s,Port: %.*s," "Type: %.*s,flushpackets: %d,flushwait: %d,ping: %d,smax: %d,ttl: %d,timeout: %d\n", id[i], ou->mess.id, (int)sizeof(ou->mess.balancer), ou->mess.balancer, - (int)sizeof(ou->mess.JVMRoute), ou->mess.JVMRoute, (int)sizeof(ou->mess.Domain), ou->mess.Domain, - (int)sizeof(ou->mess.Host), ou->mess.Host, (int)sizeof(ou->mess.Port), ou->mess.Port, - (int)sizeof(ou->mess.Type), ou->mess.Type, ou->mess.flushpackets, ou->mess.flushwait / 1000, - (int)apr_time_sec(ou->mess.ping), ou->mess.smax, (int)apr_time_sec(ou->mess.ttl), - (int)apr_time_sec(ou->mess.timeout)); + (int)sizeof(ou->mess.jvm_route), ou->mess.jvm_route, (int)sizeof(ou->mess.domain), + ou->mess.domain, (int)sizeof(ou->mess.host), ou->mess.host, (int)sizeof(ou->mess.port), + ou->mess.port, (int)sizeof(ou->mess.type), ou->mess.type, ou->mess.flushpackets, + ou->mess.flushwait / 1000, (int)apr_time_sec(ou->mess.ping), ou->mess.smax, + (int)apr_time_sec(ou->mess.ttl), (int)apr_time_sec(ou->mess.timeout)); break; } } @@ -1783,7 +1785,7 @@ static char *process_dump(request_rec *r, int *errtype) ap_rprintf(r, "\ %d\ %d\ - ", + ", id[i], (int)sizeof(ou->host), ou->host, ou->vhost, ou->node); break; case TEXT_PLAIN: @@ -1893,18 +1895,18 @@ static char *process_info(request_rec *r, int *errtype) "%.*s" "%.*s" "%.*s", - id[i], (int)sizeof(ou->mess.JVMRoute), ou->mess.JVMRoute, (int)sizeof(ou->mess.balancer), - ou->mess.balancer, (int)sizeof(ou->mess.Domain), ou->mess.Domain, (int)sizeof(ou->mess.Host), - ou->mess.Host, (int)sizeof(ou->mess.Port), ou->mess.Port, (int)sizeof(ou->mess.Type), - ou->mess.Type); + id[i], (int)sizeof(ou->mess.jvm_route), ou->mess.jvm_route, (int)sizeof(ou->mess.balancer), + ou->mess.balancer, (int)sizeof(ou->mess.domain), ou->mess.domain, (int)sizeof(ou->mess.host), + ou->mess.host, (int)sizeof(ou->mess.port), ou->mess.port, (int)sizeof(ou->mess.type), + ou->mess.type); break; case TEXT_PLAIN: default: ap_rprintf(r, "Node: [%d],Name: %.*s,Balancer: %.*s,LBGroup: %.*s,Host: %.*s,Port: %.*s,Type: %.*s", id[i], - (int)sizeof(ou->mess.JVMRoute), ou->mess.JVMRoute, (int)sizeof(ou->mess.balancer), - ou->mess.balancer, (int)sizeof(ou->mess.Domain), ou->mess.Domain, (int)sizeof(ou->mess.Host), - ou->mess.Host, (int)sizeof(ou->mess.Port), ou->mess.Port, (int)sizeof(ou->mess.Type), - ou->mess.Type); + (int)sizeof(ou->mess.jvm_route), ou->mess.jvm_route, (int)sizeof(ou->mess.balancer), + ou->mess.balancer, (int)sizeof(ou->mess.domain), ou->mess.domain, (int)sizeof(ou->mess.host), + ou->mess.host, (int)sizeof(ou->mess.port), ou->mess.port, (int)sizeof(ou->mess.type), + ou->mess.type); break; } @@ -2116,11 +2118,11 @@ static char *process_appl_cmd(request_rec *r, char **ptr, int status, int *errty while (ptr[i]) { if (strcasecmp(ptr[i], "JVMRoute") == 0) { - if (strlen(ptr[i + 1]) >= sizeof(nodeinfo.mess.JVMRoute)) { + if (strlen(ptr[i + 1]) >= sizeof(nodeinfo.mess.jvm_route)) { *errtype = TYPESYNTAX; return SROUBIG; } - strcpy(nodeinfo.mess.JVMRoute, ptr[i + 1]); + strcpy(nodeinfo.mess.jvm_route, ptr[i + 1]); nodeinfo.mess.id = -1; } err_msg = process_context_alias(ptr[i], ptr[i + 1], r->pool, &contexts, &aliases, errtype, 0); @@ -2131,13 +2133,13 @@ static char *process_appl_cmd(request_rec *r, char **ptr, int status, int *errty i += 2; } - /* Check for JVMRoute, Alias and Context */ - if (nodeinfo.mess.JVMRoute[0] == '\0') { + /* Check for jvm_route, alias and Context */ + if (nodeinfo.mess.jvm_route[0] == '\0') { *errtype = TYPESYNTAX; return SROUBAD; } - /* Note: This applies only for non-wildcarded requests for which Alias and Context are required */ + /* Note: This applies only for non-wildcarded requests for which alias and Context are required */ if (contexts == NULL && aliases == NULL && strcmp(r->uri, "/*") != 0) { *errtype = TYPESYNTAX; return NOCONAL; @@ -2161,7 +2163,7 @@ static char *process_appl_cmd(request_rec *r, char **ptr, int status, int *errty return NULL; /* Already done */ } *errtype = TYPEMEM; - return apr_psprintf(r->pool, MNODERD, nodeinfo.mess.JVMRoute); + return apr_psprintf(r->pool, MNODERD, nodeinfo.mess.jvm_route); } /* If the node is marked removed check what to do */ @@ -2172,7 +2174,7 @@ static char *process_appl_cmd(request_rec *r, char **ptr, int status, int *errty } /* Act has if the node wasn't found */ *errtype = TYPEMEM; - return apr_psprintf(r->pool, MNODERD, node->mess.JVMRoute); + return apr_psprintf(r->pool, MNODERD, node->mess.jvm_route); } inc_version_node(); @@ -2185,7 +2187,7 @@ static char *process_appl_cmd(request_rec *r, char **ptr, int status, int *errty return ret; } - /* Go through the provided Aliases, the first Alias that matches an existing host gets used + /* Go through the provided Aliases, the first alias that matches an existing host gets used * otherwise, a new host will be created */ hostinfo.node = node->mess.id; @@ -2233,12 +2235,12 @@ static char *process_appl_cmd(request_rec *r, char **ptr, int status, int *errty } vid++; /* Use next one. */ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, "process_appl_cmd: adding vhost: %d node: %d route: %s", - vid, node->mess.id, nodeinfo.mess.JVMRoute); - /* If the Host doesn't exist yet create it */ + vid, node->mess.id, nodeinfo.mess.jvm_route); + /* If the host doesn't exist yet create it */ if (insert_update_hosts(r->server, hoststatsmem, aliases, node->mess.id, vid) != APR_SUCCESS) { loc_unlock_nodes(); *errtype = TYPEMEM; - return apr_psprintf(r->pool, MHOSTUI, nodeinfo.mess.JVMRoute); + return apr_psprintf(r->pool, MHOSTUI, nodeinfo.mess.jvm_route); } hostinfo.id = 0; hostinfo.node = node->mess.id; @@ -2252,7 +2254,7 @@ static char *process_appl_cmd(request_rec *r, char **ptr, int status, int *errty if (host == NULL) { loc_unlock_nodes(); *errtype = TYPEMEM; - return apr_psprintf(r->pool, MHOSTRD, node->mess.JVMRoute); + return apr_psprintf(r->pool, MHOSTRD, node->mess.jvm_route); } } @@ -2287,13 +2289,13 @@ static char *process_appl_cmd(request_rec *r, char **ptr, int status, int *errty APR_SUCCESS) { loc_unlock_nodes(); *errtype = TYPEMEM; - return apr_psprintf(r->pool, MCONTUI, node->mess.JVMRoute); + return apr_psprintf(r->pool, MCONTUI, node->mess.jvm_route); } if (insert_update_hosts(r->server, hoststatsmem, aliases, node->mess.id, host->vhost) != APR_SUCCESS) { loc_unlock_nodes(); *errtype = TYPEMEM; - return apr_psprintf(r->pool, MHOSTUI, node->mess.JVMRoute); + return apr_psprintf(r->pool, MHOSTUI, node->mess.jvm_route); } /* Remove the host if all the contextes have been removed */ @@ -2341,7 +2343,7 @@ static char *process_appl_cmd(request_rec *r, char **ptr, int status, int *errty if (fromnode) { ap_set_content_type(r, PLAINTEXT_CONTENT_TYPE); ap_rprintf(r, "Type=STOP-APP-RSP&JvmRoute=%.*s&Alias=%.*s&Context=%.*s&Requests=%d", - (int)sizeof(nodeinfo.mess.JVMRoute), nodeinfo.mess.JVMRoute, (int)sizeof(aliases), aliases, + (int)sizeof(nodeinfo.mess.jvm_route), nodeinfo.mess.jvm_route, (int)sizeof(aliases), aliases, (int)sizeof(contexts), contexts, ou->nbrequests); ap_rprintf(r, "\n"); } @@ -2377,9 +2379,9 @@ static char *process_remove(request_rec *r, char **ptr, int *errtype, int global * Call the ping/pong logic * Do a ping/png request to the node and set the load factor. */ -static int isnode_up(request_rec *r, int id, int Load) +static int isnode_up(request_rec *r, int id, int load) { - return balancerhandler != NULL ? balancerhandler->proxy_node_isup(r, id, Load) : OK; + return balancerhandler != NULL ? balancerhandler->proxy_node_isup(r, id, load) : OK; } /* @@ -2393,13 +2395,13 @@ static int ishost_up(request_rec *r, char *scheme, char *host, char *port) /* * Process the STATUS command - * Load -1 : Broken - * Load 0 : Standby. - * Load 1-100 : Load factor. + * load -1 : Broken + * load 0 : Standby. + * load 1-100 : load factor. */ static char *process_status(request_rec *r, const char *const *ptr, int *errtype) { - int Load = -1; + int load = -1; nodeinfo_t nodeinfo; nodeinfo_t *node; @@ -2408,14 +2410,14 @@ static char *process_status(request_rec *r, const char *const *ptr, int *errtype ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, "Processing STATUS"); while (ptr[i]) { if (strcasecmp(ptr[i], "JVMRoute") == 0) { - if (strlen(ptr[i + 1]) >= sizeof(nodeinfo.mess.JVMRoute)) { + if (strlen(ptr[i + 1]) >= sizeof(nodeinfo.mess.jvm_route)) { *errtype = TYPESYNTAX; return SROUBIG; } - strcpy(nodeinfo.mess.JVMRoute, ptr[i + 1]); + strcpy(nodeinfo.mess.jvm_route, ptr[i + 1]); nodeinfo.mess.id = -1; } else if (strcasecmp(ptr[i], "Load") == 0) { - Load = atoi(ptr[i + 1]); + load = atoi(ptr[i + 1]); } else { *errtype = TYPESYNTAX; return apr_psprintf(r->pool, SBADFLD, ptr[i]); @@ -2430,7 +2432,7 @@ static char *process_status(request_rec *r, const char *const *ptr, int *errtype loc_unlock_nodes(); if (node == NULL) { *errtype = TYPEMEM; - return apr_psprintf(r->pool, MNODERD, nodeinfo.mess.JVMRoute); + return apr_psprintf(r->pool, MNODERD, nodeinfo.mess.jvm_route); } /* @@ -2438,9 +2440,9 @@ static char *process_status(request_rec *r, const char *const *ptr, int *errtype * and update the worker status and load factor acccording to the test result. */ ap_set_content_type(r, PLAINTEXT_CONTENT_TYPE); - ap_rprintf(r, "Type=STATUS-RSP&JVMRoute=%.*s", (int)sizeof(nodeinfo.mess.JVMRoute), nodeinfo.mess.JVMRoute); + ap_rprintf(r, "Type=STATUS-RSP&JVMRoute=%.*s", (int)sizeof(nodeinfo.mess.jvm_route), nodeinfo.mess.jvm_route); - ap_rprintf(r, isnode_up(r, node->mess.id, Load) != OK ? "&State=NOTOK" : "&State=OK"); + ap_rprintf(r, isnode_up(r, node->mess.id, load) != OK ? "&State=NOTOK" : "&State=OK"); ap_rprintf(r, "&id=%d", (int)ap_scoreboard_image->global->restart_time); @@ -2472,7 +2474,7 @@ static char *process_version(request_rec *r, const char *const *const ptr, int * /* * Process the PING command - * With a JVMRoute does a cping/cpong in the node. + * With a jvm_route does a cping/cpong in the node. * Without just answers ok. * NOTE: It is hard to cping/cpong a host + port but CONFIG + PING + REMOVE_APP * * would do the same. @@ -2491,11 +2493,11 @@ static char *process_ping(request_rec *r, const char *const *ptr, int *errtype) nodeinfo.mess.id = -2; while (ptr[i] && ptr[i][0] != '\0') { if (strcasecmp(ptr[i], "JVMRoute") == 0) { - if (strlen(ptr[i + 1]) >= sizeof(nodeinfo.mess.JVMRoute)) { + if (strlen(ptr[i + 1]) >= sizeof(nodeinfo.mess.jvm_route)) { *errtype = TYPESYNTAX; return SROUBIG; } - strcpy(nodeinfo.mess.JVMRoute, ptr[i + 1]); + strcpy(nodeinfo.mess.jvm_route, ptr[i + 1]); nodeinfo.mess.id = -1; } else if (strcasecmp(ptr[i], "Scheme") == 0) { scheme = apr_pstrdup(r->pool, ptr[i + 1]); @@ -2532,7 +2534,7 @@ static char *process_ping(request_rec *r, const char *const *ptr, int *errtype) loc_unlock_nodes(); if (node == NULL) { *errtype = TYPEMEM; - return apr_psprintf(r->pool, MNODERD, nodeinfo.mess.JVMRoute); + return apr_psprintf(r->pool, MNODERD, nodeinfo.mess.jvm_route); } /* @@ -2540,7 +2542,7 @@ static char *process_ping(request_rec *r, const char *const *ptr, int *errtype) * and update the worker status and load factor acccording to the test result. */ ap_set_content_type(r, PLAINTEXT_CONTENT_TYPE); - ap_rprintf(r, "Type=PING-RSP&JVMRoute=%.*s", (int)sizeof(nodeinfo.mess.JVMRoute), nodeinfo.mess.JVMRoute); + ap_rprintf(r, "Type=PING-RSP&JVMRoute=%.*s", (int)sizeof(nodeinfo.mess.jvm_route), nodeinfo.mess.jvm_route); ap_rprintf(r, isnode_up(r, node->mess.id, -2) != OK ? "&State=NOTOK" : "&State=OK"); } @@ -2740,12 +2742,12 @@ static int manager_map_to_storage(request_rec *r) /* * Create the commands that are possible on the context */ -static char *context_string(request_rec *r, contextinfo_t *ou, const char *Alias, const char *JVMRoute) +static char *context_string(request_rec *r, contextinfo_t *ou, const char *alias, const char *jvm_route) { char context[CONTEXTSZ + 1]; strncpy(context, ou->context, CONTEXTSZ); context[CONTEXTSZ] = '\0'; - return apr_pstrcat(r->pool, "JVMRoute=", JVMRoute, "&Alias=", Alias, "&Context=", context, NULL); + return apr_pstrcat(r->pool, "JVMRoute=", jvm_route, "&Alias=", alias, "&Context=", context, NULL); } static char *balancer_nonce_string(request_rec *r) @@ -2759,44 +2761,44 @@ static char *balancer_nonce_string(request_rec *r) return ret; } -static void print_context_command(request_rec *r, contextinfo_t *ou, const char *Alias, const char *JVMRoute) +static void print_context_command(request_rec *r, contextinfo_t *ou, const char *alias, const char *jvm_route) { if (ou->status == DISABLED) { ap_rprintf(r, "Enable ", r->uri, balancer_nonce_string(r), - context_string(r, ou, Alias, JVMRoute)); + context_string(r, ou, alias, jvm_route)); ap_rprintf(r, " Stop", r->uri, balancer_nonce_string(r), - context_string(r, ou, Alias, JVMRoute)); + context_string(r, ou, alias, jvm_route)); } if (ou->status == ENABLED) { ap_rprintf(r, "Disable", r->uri, balancer_nonce_string(r), - context_string(r, ou, Alias, JVMRoute)); + context_string(r, ou, alias, jvm_route)); ap_rprintf(r, " Stop", r->uri, balancer_nonce_string(r), - context_string(r, ou, Alias, JVMRoute)); + context_string(r, ou, alias, jvm_route)); } if (ou->status == STOPPED) { ap_rprintf(r, "Enable ", r->uri, balancer_nonce_string(r), - context_string(r, ou, Alias, JVMRoute)); + context_string(r, ou, alias, jvm_route)); ap_rprintf(r, "Disable", r->uri, balancer_nonce_string(r), - context_string(r, ou, Alias, JVMRoute)); + context_string(r, ou, alias, jvm_route)); } } /* * Create the commands that are possible on the node */ -static char *node_string(request_rec *r, const char *JVMRoute) +static char *node_string(request_rec *r, const char *jvm_route) { - return apr_pstrcat(r->pool, "JVMRoute=", JVMRoute, NULL); + return apr_pstrcat(r->pool, "JVMRoute=", jvm_route, NULL); } -static void print_node_command(request_rec *r, const char *JVMRoute) +static void print_node_command(request_rec *r, const char *jvm_route) { ap_rprintf(r, "Enable Contexts ", r->uri, - balancer_nonce_string(r), node_string(r, JVMRoute)); + balancer_nonce_string(r), node_string(r, jvm_route)); ap_rprintf(r, "Disable Contexts ", r->uri, - balancer_nonce_string(r), node_string(r, JVMRoute)); + balancer_nonce_string(r), node_string(r, jvm_route)); ap_rprintf(r, "Stop Contexts", r->uri, balancer_nonce_string(r), - node_string(r, JVMRoute)); + node_string(r, jvm_route)); } /* @@ -2810,21 +2812,21 @@ static char *mc_escape_html(apr_pool_t *pool, const char *str, int len) return ap_escape_html(pool, s); } -static void print_domain_command(request_rec *r, const char *Domain) +static void print_domain_command(request_rec *r, const char *domain) { - ap_rprintf(r, "Enable Nodes ", r->uri, - balancer_nonce_string(r), Domain); - ap_rprintf(r, "Disable Nodes ", r->uri, - balancer_nonce_string(r), Domain); - ap_rprintf(r, "Stop Nodes", r->uri, - balancer_nonce_string(r), Domain); + ap_rprintf(r, "Enable Nodes ", r->uri, + balancer_nonce_string(r), domain); + ap_rprintf(r, "Disable Nodes ", r->uri, + balancer_nonce_string(r), domain); + ap_rprintf(r, "Stop Nodes", r->uri, + balancer_nonce_string(r), domain); } /* * Process the parameters and display corresponding informations */ -static void print_contexts(request_rec *r, int reduce_display, int allow_cmd, int node, int host, const char *Alias, - const char *JVMRoute) +static void print_contexts(request_rec *r, int reduce_display, int allow_cmd, int node, int host, const char *alias, + const char *jvm_route) { int size, i; int *id; @@ -2850,14 +2852,14 @@ static void print_contexts(request_rec *r, int reduce_display, int allow_cmd, in ap_rprintf(r, "%.*s, Status: %s Request: %d ", CONTEXTSZ, mc_escape_html(r->pool, ou->context, CONTEXTSZ), context_status_to_string(ou->status), ou->nbrequests); if (allow_cmd) { - print_context_command(r, ou, Alias, JVMRoute); + print_context_command(r, ou, alias, jvm_route); } ap_rprintf(r, "\n"); } ap_rprintf(r, ""); } -static void print_hosts(request_rec *r, int reduce_display, int allow_cmd, int node, const char *JVMRoute) +static void print_hosts(request_rec *r, int reduce_display, int allow_cmd, int node, const char *jvm_route) { int size, i, j; int *id, *idChecker; @@ -2890,7 +2892,7 @@ static void print_hosts(request_rec *r, int reduce_display, int allow_cmd, int n if (!reduce_display) { ap_rprintf(r, "

Virtual Host %d:

", ou->vhost); } - print_contexts(r, reduce_display, allow_cmd, ou->node, ou->vhost, ou->host, JVMRoute); + print_contexts(r, reduce_display, allow_cmd, ou->node, ou->vhost, ou->host, jvm_route); if (reduce_display) { ap_rprintf(r, "Aliases: "); } else { @@ -2953,7 +2955,7 @@ static void print_sessionid(request_rec *r) if (get_sessionid(sessionidstatsmem, &ou, id[i]) != APR_SUCCESS) { continue; } - ap_rprintf(r, "id: %.*s route: %.*s\n", SESSIONIDSZ, ou->sessionid, JVMROUTESZ, ou->JVMRoute); + ap_rprintf(r, "id: %.*s route: %.*s\n", SESSIONIDSZ, ou->sessionid, JVMROUTESZ, ou->jvm_route); } ap_rprintf(r, ""); } @@ -2982,7 +2984,7 @@ static void print_domain(request_rec *r, int reduce_display) if (get_domain(domainstatsmem, &ou, id[i]) != APR_SUCCESS) { continue; } - ap_rprintf(r, "dom: %.*s route: %.*s balancer: %.*s\n", DOMAINNDSZ, ou->domain, JVMROUTESZ, ou->JVMRoute, + ap_rprintf(r, "dom: %.*s route: %.*s balancer: %.*s\n", DOMAINNDSZ, ou->domain, JVMROUTESZ, ou->jvm_route, BALANCERSZ, ou->balancer); } ap_rprintf(r, ""); @@ -3010,7 +3012,7 @@ static int count_sessionid(request_rec *r, const char *route) if (get_sessionid(sessionidstatsmem, &ou, id[i]) != APR_SUCCESS) { continue; } - if (strcmp(route, ou->JVMRoute) == 0) { + if (strcmp(route, ou->jvm_route) == 0) { count++; } } @@ -3038,7 +3040,7 @@ static void process_error(request_rec *r, char *errstring, int errtype) static int cmp_nodes(const void *n1, const void *n2) { - return strcmp(((nodeinfo_t *)n1)->mess.Domain, ((nodeinfo_t *)n2)->mess.Domain); + return strcmp(((nodeinfo_t *)n1)->mess.domain, ((nodeinfo_t *)n2)->mess.domain); } static void sort_nodes(nodeinfo_t *nodes, int nbnodes) @@ -3092,11 +3094,11 @@ static char *process_domain(request_rec *r, char **ptr, int *errtype, const char if (get_node(nodestatsmem, &ou, id[i]) != APR_SUCCESS) { continue; } - if (strcmp(ou->mess.Domain, domain) != 0) { + if (strcmp(ou->mess.domain, domain) != 0) { continue; } - /* add the JVMRoute */ - ptr[pos + 1] = apr_pstrdup(r->pool, ou->mess.JVMRoute); + /* add the jvm_route */ + ptr[pos + 1] = apr_pstrdup(r->pool, ou->mess.jvm_route); process_appl(cmd, r, ptr, errtype, RANGENODE, &errstring, 0); } return errstring; @@ -3165,26 +3167,26 @@ static void print_node(request_rec *r, nodeinfo_t *ou, const mod_manager_config char *domain = ""; if (mconf->reduce_display) { - if (strcmp(domain, ou->mess.Domain) != 0) { - ap_rprintf(r, "

LBGroup %.*s: ", (int)sizeof(ou->mess.Domain), ou->mess.Domain); - domain = ou->mess.Domain; + if (strcmp(domain, ou->mess.domain) != 0) { + ap_rprintf(r, "

LBGroup %.*s: ", (int)sizeof(ou->mess.domain), ou->mess.domain); + domain = ou->mess.domain; if (mconf->allow_cmd) { print_domain_command(r, domain); } } - ap_rprintf(r, "

Node %.*s ", (int)sizeof(ou->mess.JVMRoute), ou->mess.JVMRoute); + ap_rprintf(r, "

Node %.*s ", (int)sizeof(ou->mess.jvm_route), ou->mess.jvm_route); print_proxystat(r, mconf->reduce_display, ou); if (mconf->allow_cmd) { - print_node_command(r, ou->mess.JVMRoute); + print_node_command(r, ou->mess.jvm_route); } ap_rprintf(r, "
\n"); } else { - if (strcmp(domain, ou->mess.Domain) != 0) { - ap_rprintf(r, "

LBGroup %.*s: ", (int)sizeof(ou->mess.Domain), ou->mess.Domain); - domain = ou->mess.Domain; + if (strcmp(domain, ou->mess.domain) != 0) { + ap_rprintf(r, "

LBGroup %.*s: ", (int)sizeof(ou->mess.domain), ou->mess.domain); + domain = ou->mess.domain; if (mconf->allow_cmd) { print_domain_command(r, domain); } @@ -3193,17 +3195,17 @@ static void print_node(request_rec *r, nodeinfo_t *ou, const mod_manager_config } } - ap_rprintf(r, "

Node %.*s (%.*s://%.*s:%.*s):

\n", (int)sizeof(ou->mess.JVMRoute), ou->mess.JVMRoute, - (int)sizeof(ou->mess.Type), ou->mess.Type, (int)sizeof(ou->mess.Host), ou->mess.Host, - (int)sizeof(ou->mess.Port), ou->mess.Port); + ap_rprintf(r, "

Node %.*s (%.*s://%.*s:%.*s):

\n", (int)sizeof(ou->mess.jvm_route), ou->mess.jvm_route, + (int)sizeof(ou->mess.type), ou->mess.type, (int)sizeof(ou->mess.host), ou->mess.host, + (int)sizeof(ou->mess.port), ou->mess.port); if (mconf->allow_cmd) { - print_node_command(r, ou->mess.JVMRoute); + print_node_command(r, ou->mess.jvm_route); } ap_rprintf(r, "
\n"); ap_rprintf(r, "Balancer: %.*s,LBGroup: %.*s", (int)sizeof(ou->mess.balancer), ou->mess.balancer, - (int)sizeof(ou->mess.Domain), ou->mess.Domain); + (int)sizeof(ou->mess.domain), ou->mess.domain); ap_rprintf(r, ",Flushpackets: %s,Flushwait: %d,Ping: %d,Smax: %d,Ttl: %d", flush_to_str(ou->mess.flushpackets), ou->mess.flushwait, (int)ou->mess.ping, ou->mess.smax, (int)ou->mess.ttl); @@ -3212,7 +3214,7 @@ static void print_node(request_rec *r, nodeinfo_t *ou, const mod_manager_config } if (sizesessionid) { - ap_rprintf(r, ",Num sessions: %d", count_sessionid(r, ou->mess.JVMRoute)); + ap_rprintf(r, ",Num sessions: %d", count_sessionid(r, ou->mess.jvm_route)); } ap_rprintf(r, "\n"); } @@ -3353,7 +3355,7 @@ static void print_nodes(request_rec *r, const mod_manager_config *mconf, int siz nodeinfo_t *ou = &nodes[i]; print_node(r, &nodes[i], mconf, sizesessionid); /* Process the Vhosts */ - print_hosts(r, mconf->reduce_display, mconf->allow_cmd, ou->mess.id, ou->mess.JVMRoute); + print_hosts(r, mconf->reduce_display, mconf->allow_cmd, ou->mess.id, ou->mess.jvm_route); } } diff --git a/native/mod_manager/node.c b/native/mod_manager/node.c index 561ba09d..8a98a44e 100644 --- a/native/mod_manager/node.c +++ b/native/mod_manager/node.c @@ -65,7 +65,7 @@ static apr_status_t update(void *mem, void *data, apr_pool_t *pool) nodeinfo_t *ou = (nodeinfo_t *)mem; (void)pool; - if (strcmp(in->mess.JVMRoute, ou->mess.JVMRoute) == 0) { + if (strcmp(in->mess.jvm_route, ou->mess.jvm_route) == 0) { in->mess.id = ou->mess.id; memcpy(ou, in, sizeof(nodemess_t)); ou->updatetime = apr_time_now(); @@ -134,7 +134,7 @@ static apr_status_t loc_read_node(void *mem, void *data, apr_pool_t *pool) nodeinfo_t *ou = (nodeinfo_t *)mem; (void)pool; - if (strcmp(in->mess.JVMRoute, ou->mess.JVMRoute) == 0) { + if (strcmp(in->mess.jvm_route, ou->mess.jvm_route) == 0) { in->mess.id = ou->mess.id; return APR_EEXIST; } @@ -175,8 +175,8 @@ apr_status_t find_node(mem_t *s, nodeinfo_t **node, const char *route) nodeinfo_t ou; apr_status_t rv; - strncpy(ou.mess.JVMRoute, route, sizeof(ou.mess.JVMRoute)); - ou.mess.JVMRoute[sizeof(ou.mess.JVMRoute) - 1] = '\0'; + strncpy(ou.mess.jvm_route, route, sizeof(ou.mess.jvm_route)); + ou.mess.jvm_route[sizeof(ou.mess.jvm_route) - 1] = '\0'; rv = s->storage->doall(s->slotmem, loc_read_node, &ou, s->p); if (rv == APR_SUCCESS) { return APR_NOTFOUND; @@ -227,7 +227,7 @@ static apr_status_t loc_read_node_byhostport(void *mem, void *data, apr_pool_t * nodeinfo_t *ou = (nodeinfo_t *)mem; (void)pool; - if (strcmp(in->mess.Host, ou->mess.Host) == 0 && strcmp(in->mess.Port, ou->mess.Port) == 0) { + if (strcmp(in->mess.host, ou->mess.host) == 0 && strcmp(in->mess.port, ou->mess.port) == 0) { in->mess.id = ou->mess.id; return APR_EEXIST; } @@ -247,10 +247,10 @@ apr_status_t find_node_byhostport(mem_t *s, nodeinfo_t **node, const char *host, nodeinfo_t ou; apr_status_t rv; - strncpy(ou.mess.Host, host, sizeof(ou.mess.Host)); - ou.mess.Host[sizeof(ou.mess.Host) - 1] = '\0'; - strncpy(ou.mess.Port, port, sizeof(ou.mess.Port)); - ou.mess.Port[sizeof(ou.mess.Port) - 1] = '\0'; + strncpy(ou.mess.host, host, sizeof(ou.mess.host)); + ou.mess.host[sizeof(ou.mess.host) - 1] = '\0'; + strncpy(ou.mess.port, port, sizeof(ou.mess.port)); + ou.mess.port[sizeof(ou.mess.port) - 1] = '\0'; rv = s->storage->doall(s->slotmem, loc_read_node_byhostport, &ou, s->p); if (rv == APR_EEXIST) { diff --git a/native/mod_proxy_cluster/mod_proxy_cluster.c b/native/mod_proxy_cluster/mod_proxy_cluster.c index 446eba65..03846421 100644 --- a/native/mod_proxy_cluster/mod_proxy_cluster.c +++ b/native/mod_proxy_cluster/mod_proxy_cluster.c @@ -27,13 +27,13 @@ #endif /* define OUR load balancer method names (lbpname), must start by MC */ -/* default behaviour be sticky StickySession="yes" */ +/* default behaviour be sticky sticky_session="yes" */ #define MC_STICKY "MC" -/* don't be STICKY use the best factor worker StickySession="no" */ +/* don't be STICKY use the best factor worker sticky_session="no" */ #define MC_NOT_STICKY "MC_NS" -/* remove session information on fail-over StickySessionRemove="yes", implies StickySession="yes" */ +/* remove session information on fail-over sticky_session_remove="yes", implies sticky_session="yes" */ #define MC_REMOVE_SESSION "MC_R" -/* Don't failover if the corresponding worker is failing StickySessionForce="yes", implies StickySession="yes" */ +/* Don't failover if the corresponding worker is failing sticky_session_force="yes", implies sticky_session="yes" */ #define MC_NO_FAILOVER "MC_NF" #if APR_HAS_THREADS @@ -87,7 +87,7 @@ static server_rec *main_server = NULL; #define CREAT_ROOT 2 /* Only create balancers/workers in the main server */ static int creat_bal = CREAT_ROOT; -static int use_alias = 0; /* 1 : Compare Alias with server_name */ +static int use_alias = 0; /* 1 : Compare alias with server_name */ static int deterministic_failover = 0; static int use_nocanon = 0; static int responsecode_when_no_context = HTTP_NOT_FOUND; @@ -304,16 +304,16 @@ static apr_status_t create_worker_reuse(proxy_server_conf *conf, const char *ptr /* the shared memory may have been removed and recreated */ if (!worker->s->status) { worker->s->status = PROXY_WORKER_INITIALIZED; - strncpy(worker->s->route, node->mess.JVMRoute, sizeof(worker->s->route)); + strncpy(worker->s->route, node->mess.jvm_route, sizeof(worker->s->route)); worker->s->route[sizeof(worker->s->route) - 1] = '\0'; - strncpy(worker->s->upgrade, node->mess.Upgrade, sizeof(worker->s->upgrade)); + strncpy(worker->s->upgrade, node->mess.upgrade, sizeof(worker->s->upgrade)); worker->s->upgrade[sizeof(worker->s->upgrade) - 1] = '\0'; - strncpy(worker->s->secret, node->mess.AJPSecret, sizeof(worker->s->secret)); + strncpy(worker->s->secret, node->mess.ajp_secret, sizeof(worker->s->secret)); worker->s->secret[sizeof(worker->s->secret) - 1] = '\0'; - if (node->mess.ResponseFieldSize > 0) { - worker->s->response_field_size = node->mess.ResponseFieldSize; + if (node->mess.response_field_size > 0) { + worker->s->response_field_size = node->mess.response_field_size; } - worker->s->response_field_size_set = node->mess.ResponseFieldSize > 0 ? 1 : 0; + worker->s->response_field_size_set = node->mess.response_field_size > 0 ? 1 : 0; /* XXX: We need that information from TC */ worker->s->redirect[0] = '\0'; worker->s->lbstatus = 0; @@ -373,7 +373,7 @@ static apr_status_t create_worker_reuse(proxy_server_conf *conf, const char *ptr static char *create_worker_build_name(const nodeinfo_t *node, apr_uri_t *uri, server_rec *server, apr_pool_t *pool) { char *url; - url = apr_pstrcat(pool, node->mess.Type, "://", normalize_hostname(pool, node->mess.Host), ":", node->mess.Port, + url = apr_pstrcat(pool, node->mess.type, "://", normalize_hostname(pool, node->mess.host), ":", node->mess.port, NULL); if (apr_uri_parse(pool, url, uri) != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_ERR, 0, server, "create_worker: worker for %s failed: Unable to parse URL", url); @@ -385,7 +385,7 @@ static char *create_worker_build_name(const nodeinfo_t *node, apr_uri_t *uri, se return NULL; } if (uri->port && uri->port == ap_proxy_port_of_scheme(uri->scheme)) { - url = apr_pstrcat(pool, node->mess.Type, "://", normalize_hostname(pool, node->mess.Host), NULL); + url = apr_pstrcat(pool, node->mess.type, "://", normalize_hostname(pool, node->mess.host), NULL); } return url; } @@ -422,17 +422,17 @@ static void create_worker_arrange_shared_mem(proxy_server_conf *conf, proxy_work strncpy(worker->s->scheme, shared->scheme, sizeof(worker->s->scheme)); worker->s->port = shared->port; worker->s->hmax = shared->hmax; - strncpy(worker->s->route, node->mess.JVMRoute, sizeof(worker->s->route)); + strncpy(worker->s->route, node->mess.jvm_route, sizeof(worker->s->route)); worker->s->route[sizeof(worker->s->route) - 1] = '\0'; - strncpy(worker->s->upgrade, node->mess.Upgrade, sizeof(worker->s->upgrade)); + strncpy(worker->s->upgrade, node->mess.upgrade, sizeof(worker->s->upgrade)); worker->s->upgrade[sizeof(worker->s->upgrade) - 1] = '\0'; - if (node->mess.ResponseFieldSize > 0) { - worker->s->response_field_size = node->mess.ResponseFieldSize; + if (node->mess.response_field_size > 0) { + worker->s->response_field_size = node->mess.response_field_size; worker->s->response_field_size_set = 1; } else { worker->s->response_field_size_set = 0; } - strncpy(worker->s->secret, node->mess.AJPSecret, sizeof(worker->s->secret)); + strncpy(worker->s->secret, node->mess.ajp_secret, sizeof(worker->s->secret)); worker->s->secret[sizeof(worker->s->secret) - 1] = '\0'; worker->s->redirect[0] = '\0'; worker->s->smax = node->mess.smax; @@ -653,24 +653,24 @@ static proxy_balancer *add_balancer_node(const nodeinfo_t *node, proxy_server_co if (balan == NULL) { return balancer; /* Done broken */ } - /* StickySession, StickySessionRemove we hack it via the lbpname (16 bytes) */ - strcpy(balancer->s->lbpname, balan->StickySession ? MC_STICKY : MC_NOT_STICKY); + /* sticky_session, sticky_session_remove we hack it via the lbpname (16 bytes) */ + strcpy(balancer->s->lbpname, balan->sticky_session ? MC_STICKY : MC_NOT_STICKY); - if (balan->StickySessionRemove) { + if (balan->sticky_session_remove) { strcpy(balancer->s->lbpname, MC_REMOVE_SESSION); } - strncpy(balancer->s->sticky, balan->StickySessionCookie, PROXY_BALANCER_MAX_STICKY_SIZE - 1); + strncpy(balancer->s->sticky, balan->sticky_session_cookie, PROXY_BALANCER_MAX_STICKY_SIZE - 1); balancer->s->sticky[PROXY_BALANCER_MAX_STICKY_SIZE - 1] = '\0'; - strncpy(balancer->s->sticky_path, balan->StickySessionPath, PROXY_BALANCER_MAX_STICKY_SIZE - 1); + strncpy(balancer->s->sticky_path, balan->sticky_session_path, PROXY_BALANCER_MAX_STICKY_SIZE - 1); balancer->s->sticky_path[PROXY_BALANCER_MAX_STICKY_SIZE - 1] = '\0'; - if (balan->StickySessionForce) { + if (balan->sticky_session_force) { strcpy(balancer->s->lbpname, MC_NO_FAILOVER); balancer->s->sticky_force = 1; balancer->s->sticky_force_set = 1; } - balancer->s->timeout = balan->Timeout; - balancer->s->max_attempts = balan->Maxattempts; + balancer->s->timeout = balan->timeout; + balancer->s->max_attempts = balan->max_attempts; balancer->s->max_attempts_set = 1; } return balancer; @@ -690,41 +690,41 @@ static void reuse_balancer(proxy_balancer *balancer, const char *name, apr_pool_ strcpy(balancer->s->lbpname, MC_STICKY); changed = 1; } - if (balan->StickySessionForce && !balancer->s->sticky_force) { + if (balan->sticky_session_force && !balancer->s->sticky_force) { balancer->s->sticky_force = 1; balancer->s->sticky_force_set = 1; strcpy(balancer->s->lbpname, MC_NO_FAILOVER); changed = 1; } - if (!balan->StickySessionForce && balancer->s->sticky_force) { + if (!balan->sticky_session_force && balancer->s->sticky_force) { balancer->s->sticky_force = 0; strcpy(balancer->s->lbpname, MC_STICKY); changed = 1; } - if (balan->StickySessionForce && strcmp(balancer->s->lbpname, MC_NO_FAILOVER)) { + if (balan->sticky_session_force && strcmp(balancer->s->lbpname, MC_NO_FAILOVER)) { strcpy(balancer->s->lbpname, MC_NO_FAILOVER); changed = 1; } - if (balan->StickySessionRemove && strcmp(balancer->s->lbpname, MC_REMOVE_SESSION)) { + if (balan->sticky_session_remove && strcmp(balancer->s->lbpname, MC_REMOVE_SESSION)) { strcpy(balancer->s->lbpname, MC_REMOVE_SESSION); changed = 1; } - if (!balan->StickySession && strcmp(balancer->s->lbpname, MC_NOT_STICKY)) { + if (!balan->sticky_session && strcmp(balancer->s->lbpname, MC_NOT_STICKY)) { strcpy(balancer->s->lbpname, MC_NOT_STICKY); changed = 1; } - if (strcmp(balan->StickySessionCookie, balancer->s->sticky) != 0) { - strncpy(balancer->s->sticky, balan->StickySessionCookie, PROXY_BALANCER_MAX_STICKY_SIZE - 1); + if (strcmp(balan->sticky_session_cookie, balancer->s->sticky) != 0) { + strncpy(balancer->s->sticky, balan->sticky_session_cookie, PROXY_BALANCER_MAX_STICKY_SIZE - 1); balancer->s->sticky[PROXY_BALANCER_MAX_STICKY_SIZE - 1] = '\0'; changed = 1; } - if (strcmp(balan->StickySessionPath, balancer->s->sticky_path) != 0) { - strncpy(balancer->s->sticky_path, balan->StickySessionPath, PROXY_BALANCER_MAX_STICKY_SIZE - 1); + if (strcmp(balan->sticky_session_path, balancer->s->sticky_path) != 0) { + strncpy(balancer->s->sticky_path, balan->sticky_session_path, PROXY_BALANCER_MAX_STICKY_SIZE - 1); balancer->s->sticky_path[PROXY_BALANCER_MAX_STICKY_SIZE - 1] = '\0'; changed = 1; } - balancer->s->timeout = balan->Timeout; - balancer->s->max_attempts = balan->Maxattempts; + balancer->s->timeout = balan->timeout; + balancer->s->max_attempts = balan->max_attempts; balancer->s->max_attempts_set = 1; if (changed) { ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, s, "Balancer %s changed", &balancer->s->name[11]); @@ -854,7 +854,7 @@ static void remove_workers_node(nodeinfo_t *node, proxy_server_conf *conf, apr_p i = helper->count_active; ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, server, "remove_workers_node: helper count_active: %d JVMRoute: %s", i, - node->mess.JVMRoute); + node->mess.jvm_route); if (i != 0) { node->mess.lastcleantry = apr_time_now(); @@ -1199,8 +1199,8 @@ static apr_status_t read_node_worker(int id, nodeinfo_t **node, const proxy_work return status; } apr_snprintf(sport, sizeof(sport), "%d", worker->s->port); - if (strcmp(worker->s->scheme, (*node)->mess.Type) || compare_hostname(worker->s->hostname, (*node)->mess.Host) || - strcmp(sport, (*node)->mess.Port)) { + if (strcmp(worker->s->scheme, (*node)->mess.type) || compare_hostname(worker->s->hostname, (*node)->mess.host) || + strcmp(sport, (*node)->mess.port)) { /* for some reasons it is not the right node */ return APR_NOTFOUND; } @@ -1309,12 +1309,12 @@ static proxy_worker *update_lbstatus_get_worker(server_rec *s, proxy_server_conf apr_snprintf(sport, sizeof(sport), "%d", worker->s->port); - if (strcmp(worker->s->scheme, ou->mess.Type) || compare_hostname(worker->s->hostname, ou->mess.Host) || - strcmp(sport, ou->mess.Port)) { + if (strcmp(worker->s->scheme, ou->mess.type) || compare_hostname(worker->s->hostname, ou->mess.host) || + strcmp(sport, ou->mess.port)) { /* the worker doesn't correspond to the node something is very broken */ ap_log_error(APLOG_MARK, APLOG_CRIT, 0, s, "update_workers_lbstatus worker: (%s) does not correspond to the node (%s)", worker->s->hostname, - ou->mess.Host); + ou->mess.host); return NULL; } @@ -1354,12 +1354,12 @@ static int update_lbstatus_hcheck(proxy_server_conf *conf, server_rec *server, a } apr_snprintf(sport, sizeof(sport), "%d", worker->s->port); - if (strcmp(worker->s->scheme, ou->mess.Type) || compare_hostname(worker->s->hostname, ou->mess.Host) || - strcmp(sport, ou->mess.Port)) { + if (strcmp(worker->s->scheme, ou->mess.type) || compare_hostname(worker->s->hostname, ou->mess.host) || + strcmp(sport, ou->mess.port)) { /* the worker doesn't correspond to the node something is very broken */ ap_log_error(APLOG_MARK, APLOG_CRIT, 0, server, "update_workers_lbstatus worker: (%s) does not correspond to the node (%s)", worker->s->hostname, - ou->mess.Host); + ou->mess.host); return 1; } @@ -1575,15 +1575,15 @@ static void remove_timeout_domain(apr_pool_t *pool) } } -/* Check that the worker corresponds to a node that belongs to the same domain according to the JVMRoute. */ +/* Check that the worker corresponds to a node that belongs to the same domain according to the jvm_route. */ static int isnode_domain_ok(const request_rec *r, const nodeinfo_t *node, const char *domain) { (void)r; - ap_log_error(APLOG_MARK, APLOG_TRACE4, 0, r->server, "isnode_domain_ok: domain %s:%s", domain, node->mess.Domain); + ap_log_error(APLOG_MARK, APLOG_TRACE4, 0, r->server, "isnode_domain_ok: domain %s:%s", domain, node->mess.domain); if (domain == NULL) { return 1; /* OK no domain in the corresponding to the SESSIONID */ } - if (strcmp(node->mess.Domain, domain) == 0) { + if (strcmp(node->mess.domain, domain) == 0) { return 1; /* OK */ } return 0; @@ -2101,14 +2101,14 @@ static void init_proxy_worker(server_rec *server, nodeinfo_t *node, proxy_worker const proxy_server_conf *the_conf) { worker->s->status = PROXY_WORKER_INITIALIZED; - strncpy(worker->s->route, node->mess.JVMRoute, sizeof(worker->s->route)); + strncpy(worker->s->route, node->mess.jvm_route, sizeof(worker->s->route)); worker->s->route[sizeof(worker->s->route) - 1] = '\0'; - strncpy(worker->s->upgrade, node->mess.Upgrade, sizeof(worker->s->upgrade)); + strncpy(worker->s->upgrade, node->mess.upgrade, sizeof(worker->s->upgrade)); worker->s->upgrade[sizeof(worker->s->upgrade) - 1] = '\0'; - strncpy(worker->s->secret, node->mess.AJPSecret, sizeof(worker->s->secret)); + strncpy(worker->s->secret, node->mess.ajp_secret, sizeof(worker->s->secret)); worker->s->secret[sizeof(worker->s->secret) - 1] = '\0'; - if (node->mess.ResponseFieldSize > 0) { - worker->s->response_field_size = node->mess.ResponseFieldSize; + if (node->mess.response_field_size > 0) { + worker->s->response_field_size = node->mess.response_field_size; worker->s->response_field_size_set = 1; } else { worker->s->response_field_size_set = 0; @@ -2177,7 +2177,7 @@ static void remove_removed_node(apr_pool_t *pool, const proxy_server_conf *conf, if (node_storage->read_node(id[i], &ou) != APR_SUCCESS) { continue; } - if (strcmp(ou->mess.JVMRoute, "REMOVED") == 0 && (now - ou->updatetime) >= wait_for_remove) { + if (strcmp(ou->mess.jvm_route, "REMOVED") == 0 && (now - ou->updatetime) >= wait_for_remove) { if (node_has_workers(ou)) { ou->updatetime = now; ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, server, @@ -2185,10 +2185,10 @@ static void remove_removed_node(apr_pool_t *pool, const proxy_server_conf *conf, } else { ou->mess.num_remove_check++; ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, server, "remove_removed_node: %d %s for REMOVED done %d", - ou->mess.id, ou->mess.Port, getpid()); + ou->mess.id, ou->mess.port, getpid()); if (ou->mess.num_remove_check > 10) { ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, server, - "remove_removed_node: %d %s for REMOVED done (DONE) %d", ou->mess.id, ou->mess.Port, + "remove_removed_node: %d %s for REMOVED done (DONE) %d", ou->mess.id, ou->mess.port, getpid()); node_storage->remove_node(ou->mess.id); } @@ -2198,13 +2198,13 @@ static void remove_removed_node(apr_pool_t *pool, const proxy_server_conf *conf, if (ou->mess.remove && (now - ou->updatetime) >= wait_for_remove && (now - ou->mess.lastcleantry) >= wait_for_remove) { /* if it has a domain store it in the domain */ - if (ou->mess.Domain[0] != '\0') { + if (ou->mess.domain[0] != '\0') { domaininfo_t dom; - strncpy(dom.JVMRoute, ou->mess.JVMRoute, sizeof(dom.JVMRoute)); - dom.JVMRoute[sizeof(dom.JVMRoute) - 1] = '\0'; + strncpy(dom.jvm_route, ou->mess.jvm_route, sizeof(dom.jvm_route)); + dom.jvm_route[sizeof(dom.jvm_route) - 1] = '\0'; strncpy(dom.balancer, ou->mess.balancer, sizeof(dom.balancer)); dom.balancer[sizeof(dom.balancer) - 1] = '\0'; - strncpy(dom.domain, ou->mess.Domain, sizeof(dom.domain)); + strncpy(dom.domain, ou->mess.domain, sizeof(dom.domain)); dom.domain[sizeof(dom.domain) - 1] = '\0'; if (domain_storage->insert_update_domain(&dom) != APR_SUCCESS) { remove_timeout_domain(pool); @@ -2213,11 +2213,11 @@ static void remove_removed_node(apr_pool_t *pool, const proxy_server_conf *conf, } /* remove the node from the shared memory */ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, server, "remove_removed_node: %d %s %s %d", ou->mess.id, - ou->mess.JVMRoute, ou->mess.Port, getpid()); + ou->mess.jvm_route, ou->mess.port, getpid()); node_storage->remove_host_context(ou->mess.id, pool); - strcpy(ou->mess.JVMRoute, "REMOVED"); - ou->mess.Domain[0] = '\0'; + strcpy(ou->mess.jvm_route, "REMOVED"); + ou->mess.domain[0] = '\0'; /* prevent real remove until processes don't have the node in workers */ ou->updatetime = now; @@ -2929,7 +2929,7 @@ static proxy_worker *find_route_worker(request_rec *r, const proxy_balancer *bal } /* - * Find the worker corresponding to the JVMRoute. + * Find the worker corresponding to the jvm_route. */ static proxy_worker *find_session_route(const proxy_balancer *balancer, request_rec *r, const char **route, const char **sticky_used, char **url, const char **domain, @@ -3443,7 +3443,7 @@ static int proxy_cluster_post_request(proxy_worker *worker, proxy_balancer *bala if (sessionid && route) { sessionidinfo_t ou; strncpy(ou.sessionid, sessionid, SESSIONIDSZ); - strncpy(ou.JVMRoute, route, JVMROUTESZ); + strncpy(ou.jvm_route, route, JVMROUTESZ); sessionid_storage->insert_update_sessionid(&ou); } }