}
global.tune.max_http_hdr = atol(args[1]);
}
- else if (!strcmp(args[0], "tune.zlib.memlevel")) {
-#ifdef USE_ZLIB
- if (alertif_too_many_args(1, file, linenum, args, &err_code))
- goto out;
- if (*args[1]) {
- global.tune.zlibmemlevel = atoi(args[1]);
- if (global.tune.zlibmemlevel < 1 || global.tune.zlibmemlevel > 9) {
- Alert("parsing [%s:%d] : '%s' expects a numeric value between 1 and 9\n",
- file, linenum, args[0]);
- err_code |= ERR_ALERT | ERR_FATAL;
- goto out;
- }
- } else {
- Alert("parsing [%s:%d] : '%s' expects a numeric value between 1 and 9\n",
- file, linenum, args[0]);
- err_code |= ERR_ALERT | ERR_FATAL;
- goto out;
- }
-#else
- Alert("parsing [%s:%d] : '%s' is not implemented.\n", file, linenum, args[0]);
- err_code |= ERR_ALERT | ERR_FATAL;
- goto out;
-#endif
- }
- else if (!strcmp(args[0], "tune.zlib.windowsize")) {
-#ifdef USE_ZLIB
- if (alertif_too_many_args(1, file, linenum, args, &err_code))
- goto out;
- if (*args[1]) {
- global.tune.zlibwindowsize = atoi(args[1]);
- if (global.tune.zlibwindowsize < 8 || global.tune.zlibwindowsize > 15) {
- Alert("parsing [%s:%d] : '%s' expects a numeric value between 8 and 15\n",
- file, linenum, args[0]);
- err_code |= ERR_ALERT | ERR_FATAL;
- goto out;
- }
- } else {
- Alert("parsing [%s:%d] : '%s' expects a numeric value between 8 and 15\n",
- file, linenum, args[0]);
- err_code |= ERR_ALERT | ERR_FATAL;
- goto out;
- }
-#else
- Alert("parsing [%s:%d] : '%s' is not implemented.\n", file, linenum, args[0]);
- err_code |= ERR_ALERT | ERR_FATAL;
- goto out;
-#endif
- }
else if (!strcmp(args[0], "tune.comp.maxlevel")) {
if (alertif_too_many_args(1, file, linenum, args, &err_code))
goto out;
#undef free_func
#endif /* USE_ZLIB */
+#include <common/cfgparse.h>
#include <common/compat.h>
#include <common/memory.h>
long zlib_used_memory = 0;
+static int global_tune_zlibmemlevel = 8; /* zlib memlevel */
+static int global_tune_zlibwindowsize = MAX_WBITS; /* zlib window size */
+
#endif
unsigned int compress_min_idle = 0;
strm = &(*comp_ctx)->strm;
- if (deflateInit2(strm, level, Z_DEFLATED, global.tune.zlibwindowsize + 16, global.tune.zlibmemlevel, Z_DEFAULT_STRATEGY) != Z_OK) {
+ if (deflateInit2(strm, level, Z_DEFLATED, global_tune_zlibwindowsize + 16, global_tune_zlibmemlevel, Z_DEFAULT_STRATEGY) != Z_OK) {
deinit_comp_ctx(comp_ctx);
return -1;
}
strm = &(*comp_ctx)->strm;
- if (deflateInit2(strm, level, Z_DEFLATED, -global.tune.zlibwindowsize, global.tune.zlibmemlevel, Z_DEFAULT_STRATEGY) != Z_OK) {
+ if (deflateInit2(strm, level, Z_DEFLATED, -global_tune_zlibwindowsize, global_tune_zlibmemlevel, Z_DEFAULT_STRATEGY) != Z_OK) {
deinit_comp_ctx(comp_ctx);
return -1;
}
strm = &(*comp_ctx)->strm;
- if (deflateInit2(strm, level, Z_DEFLATED, global.tune.zlibwindowsize, global.tune.zlibmemlevel, Z_DEFAULT_STRATEGY) != Z_OK) {
+ if (deflateInit2(strm, level, Z_DEFLATED, global_tune_zlibwindowsize, global_tune_zlibmemlevel, Z_DEFAULT_STRATEGY) != Z_OK) {
deinit_comp_ctx(comp_ctx);
return -1;
}
return ret;
}
+/* config parser for global "tune.zlibmemlevel" */
+static int zlib_parse_global_memlevel(char **args, int section_type, struct proxy *curpx,
+ struct proxy *defpx, const char *file, int line,
+ char **err)
+{
+ if (too_many_args(1, args, err, NULL))
+ return -1;
+
+ if (*(args[1]) == 0) {
+ memprintf(err, "'%s' expects a numeric value between 1 and 9.", args[0]);
+ return -1;
+ }
+
+ global_tune_zlibmemlevel = atoi(args[1]);
+ if (global_tune_zlibmemlevel < 1 || global_tune_zlibmemlevel > 9) {
+ memprintf(err, "'%s' expects a numeric value between 1 and 9.", args[0]);
+ return -1;
+ }
+ return 0;
+}
+
+
+/* config parser for global "tune.zlibwindowsize" */
+static int zlib_parse_global_windowsize(char **args, int section_type, struct proxy *curpx,
+ struct proxy *defpx, const char *file, int line,
+ char **err)
+{
+ if (too_many_args(1, args, err, NULL))
+ return -1;
+
+ if (*(args[1]) == 0) {
+ memprintf(err, "'%s' expects a numeric value between 8 and 15.", args[0]);
+ return -1;
+ }
+
+ global_tune_zlibwindowsize = atoi(args[1]);
+ if (global_tune_zlibwindowsize < 8 || global_tune_zlibwindowsize > 15) {
+ memprintf(err, "'%s' expects a numeric value between 8 and 15.", args[0]);
+ return -1;
+ }
+ return 0;
+}
+
#endif /* USE_ZLIB */
+
+/* config keyword parsers */
+static struct cfg_kw_list cfg_kws = {ILH, {
+#ifdef USE_ZLIB
+ { CFG_GLOBAL, "tune.zlib.memlevel", zlib_parse_global_memlevel },
+ { CFG_GLOBAL, "tune.zlib.windowsize", zlib_parse_global_windowsize },
+#endif
+ { 0, NULL, NULL }
+}};
+
__attribute__((constructor))
static void __comp_fetch_init(void)
{
slz_make_crc_table();
slz_prepare_dist_table();
#endif
+#if defined(USE_ZLIB) && defined(DEFAULT_MAXZLIBMEM)
+ global.tune.maxzlibmem = DEFAULT_MAXZLIBMEM * 1024U * 1024U,
+#endif
#ifdef USE_ZLIB
memprintf(&ptr, "Built with zlib version : " ZLIB_VERSION);
memprintf(&ptr, "%s\nRunning on zlib version : %s", ptr, zlibVersion());
memprintf(&ptr, "%s none", ptr);
hap_register_build_opts(ptr, 1);
+ cfg_register_keywords(&cfg_kws);
}