Author: rjung Date: Wed Dec 24 23:50:36 2014 New Revision: 1647863 URL: http://svn.apache.org/r1647863 Log: Replace fixed allocation of 32 entries for fail_on_status by dynamic allocation.
Modified: tomcat/jk/trunk/native/common/jk_ajp_common.c tomcat/jk/trunk/native/common/jk_ajp_common.h tomcat/jk/trunk/native/common/jk_map.c tomcat/jk/trunk/native/common/jk_map.h tomcat/jk/trunk/native/common/jk_util.c tomcat/jk/trunk/native/common/jk_util.h tomcat/jk/trunk/xdocs/miscellaneous/changelog.xml Modified: tomcat/jk/trunk/native/common/jk_ajp_common.c URL: http://svn.apache.org/viewvc/tomcat/jk/trunk/native/common/jk_ajp_common.c?rev=1647863&r1=1647862&r2=1647863&view=diff ============================================================================== --- tomcat/jk/trunk/native/common/jk_ajp_common.c (original) +++ tomcat/jk/trunk/native/common/jk_ajp_common.c Wed Dec 24 23:50:36 2014 @@ -2990,9 +2990,9 @@ int ajp_init(jk_worker_t *pThis, JK_SLEEP_DEF); p->cache_acquire_timeout = jk_get_worker_cache_acquire_timeout(props, p->name, p->retries * p->retry_interval); - p->http_status_fail_num = jk_get_worker_fail_on_status(props, p->name, - &p->http_status_fail[0], - JK_MAX_HTTP_STATUS_FAILS); + jk_get_worker_fail_on_status(props, p->name, + &(p->http_status_fail), + &(p->http_status_fail_num)); if (p->retries < 1) { jk_log(l, JK_LOG_INFO, Modified: tomcat/jk/trunk/native/common/jk_ajp_common.h URL: http://svn.apache.org/viewvc/tomcat/jk/trunk/native/common/jk_ajp_common.h?rev=1647863&r1=1647862&r2=1647863&view=diff ============================================================================== --- tomcat/jk/trunk/native/common/jk_ajp_common.h (original) +++ tomcat/jk/trunk/native/common/jk_ajp_common.h Wed Dec 24 23:50:36 2014 @@ -256,8 +256,6 @@ extern "C" #define RECOVER_ALWAYS_HTTP_HEAD 0x0008 /* RECOVER HTTP HEAD REQUESTS, EVEN IF ABORT OPTIONS ARE SET */ #define RECOVER_ALWAYS_HTTP_GET 0x0010 /* RECOVER HTTP GET REQUESTS, EVEN IF ABORT OPTIONS ARE SET */ -#define JK_MAX_HTTP_STATUS_FAILS 32 /* Should be enough for most 400 and 500 statuses */ - struct jk_res_data { int status; @@ -377,7 +375,7 @@ struct ajp_worker * HTTP status that will cause failover (0 means disabled) */ unsigned int http_status_fail_num; - int http_status_fail[JK_MAX_HTTP_STATUS_FAILS]; + int *http_status_fail; }; Modified: tomcat/jk/trunk/native/common/jk_map.c URL: http://svn.apache.org/viewvc/tomcat/jk/trunk/native/common/jk_map.c?rev=1647863&r1=1647862&r2=1647863&view=diff ============================================================================== --- tomcat/jk/trunk/native/common/jk_map.c (original) +++ tomcat/jk/trunk/native/common/jk_map.c Wed Dec 24 23:50:36 2014 @@ -286,13 +286,12 @@ char **jk_map_get_string_list(jk_map_t * #endif { - if (idex == capacity) { ar = jk_pool_realloc(&m->p, sizeof(char *) * (capacity + 5), ar, sizeof(char *) * capacity); if (!ar) { - return JK_FALSE; + return NULL; } capacity += 5; } @@ -306,29 +305,26 @@ char **jk_map_get_string_list(jk_map_t * return ar; } -int jk_map_get_int_list(jk_map_t *m, - const char *name, - int *list, - unsigned int list_len, - const char *def) +int *jk_map_get_int_list(jk_map_t *m, + const char *name, + unsigned int *list_len, + const char *def) { const char *l = jk_map_get_string(m, name, def); + int *ar = NULL; #ifdef _MT_CODE_PTHREAD char *lasts; #endif - if (!list_len) - return 0; - if (l) { - unsigned int capacity = list_len; - unsigned int index = 0; + unsigned int capacity = 0; + unsigned int idex = 0; char *p; char *v = jk_pool_strdup(&m->p, l); if (!v) { - return 0; + return NULL; } /* @@ -343,16 +339,22 @@ int jk_map_get_int_list(jk_map_t *m, #endif { - if (index < capacity) { - list[index] = atoi(p); - index++; + if (idex == capacity) { + ar = jk_pool_realloc(&m->p, + sizeof(int) * (capacity + 5), + ar, sizeof(int) * capacity); + if (!ar) { + return NULL; + } + capacity += 5; } - else - break; + ar[idex] = atoi(p); + idex++; } - return index; + + *list_len = idex; } - return 0; + return ar; } int jk_map_add(jk_map_t *m, const char *name, const void *value) @@ -471,8 +473,8 @@ int jk_map_read_property(jk_map_t *m, jk char *prp = &buf[0]; if (strlen(str) > LENGTH_OF_LINE) { - jk_log(l, JK_LOG_WARNING, - "Line to long (%d > %d), ignoring entry", + jk_log(l, JK_LOG_ERROR, + "Line too long (%d > %d), ignoring entry", strlen(str), LENGTH_OF_LINE); return JK_FALSE; } Modified: tomcat/jk/trunk/native/common/jk_map.h URL: http://svn.apache.org/viewvc/tomcat/jk/trunk/native/common/jk_map.h?rev=1647863&r1=1647862&r2=1647863&view=diff ============================================================================== --- tomcat/jk/trunk/native/common/jk_map.h (original) +++ tomcat/jk/trunk/native/common/jk_map.h Wed Dec 24 23:50:36 2014 @@ -75,10 +75,10 @@ char **jk_map_get_string_list(jk_map_t * const char *name, unsigned *list_len, const char *def); -int jk_map_get_int_list(jk_map_t *m, - const char *name, - int *list, unsigned int list_len, - const char *def); +int *jk_map_get_int_list(jk_map_t *m, + const char *name, + unsigned int *list_len, + const char *def); int jk_map_add(jk_map_t *m, const char *name, const void *value); Modified: tomcat/jk/trunk/native/common/jk_util.c URL: http://svn.apache.org/viewvc/tomcat/jk/trunk/native/common/jk_util.c?rev=1647863&r1=1647862&r2=1647863&view=diff ============================================================================== --- tomcat/jk/trunk/native/common/jk_util.c (original) +++ tomcat/jk/trunk/native/common/jk_util.c Wed Dec 24 23:50:36 2014 @@ -1422,21 +1422,26 @@ int jk_get_max_packet_size(jk_map_t *m, } int jk_get_worker_fail_on_status(jk_map_t *m, const char *wname, - int *list, unsigned int list_size) + int **list, unsigned int *list_size) { char buf[PARAM_BUFFER_SIZE]; - if (!m || !wname || !list) { + if (!m || !wname || !list || !list_size) { return 0; } MAKE_WORKER_PARAM(STATUS_FAIL_OF_WORKER); - if (list_size) { - return jk_map_get_int_list(m, buf, - list, list_size, - NULL); + int *ar = jk_map_get_int_list(m, + buf, + list_size, + NULL); + if (ar) { + *list = ar; + return JK_TRUE; } + *list = NULL; + *list_size = 0; - return 0; + return JK_FALSE; } int jk_get_worker_user_case_insensitive(jk_map_t *m, const char *wname) Modified: tomcat/jk/trunk/native/common/jk_util.h URL: http://svn.apache.org/viewvc/tomcat/jk/trunk/native/common/jk_util.h?rev=1647863&r1=1647862&r2=1647863&view=diff ============================================================================== --- tomcat/jk/trunk/native/common/jk_util.h (original) +++ tomcat/jk/trunk/native/common/jk_util.h Wed Dec 24 23:50:36 2014 @@ -235,7 +235,7 @@ const char *jk_get_worker_xml_doctype(jk const char *jk_get_worker_prop_prefix(jk_map_t *m, const char *wname, const char *def); int jk_get_worker_fail_on_status(jk_map_t *m, const char *wname, - int *list, unsigned int list_size); + int **list, unsigned int *list_size); int jk_get_worker_user_case_insensitive(jk_map_t *m, const char *wname); Modified: tomcat/jk/trunk/xdocs/miscellaneous/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/jk/trunk/xdocs/miscellaneous/changelog.xml?rev=1647863&r1=1647862&r2=1647863&view=diff ============================================================================== --- tomcat/jk/trunk/xdocs/miscellaneous/changelog.xml (original) +++ tomcat/jk/trunk/xdocs/miscellaneous/changelog.xml Wed Dec 24 23:50:36 2014 @@ -126,6 +126,10 @@ logging and add trailing "..." to lines which were likely truncated. (rjung) </fix> + <update> + Replace fixed allocation of 32 entries for fail_on_status by + dynamic allocation. (rjung) + </update> </changelog> </subsection> </section> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org