X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Foptions%2Fparser.yy;h=8e87230ade8c10e534d2d3c8db618ea31c3948c3;hb=d8dedbd561c7cb57daf4192fe57ce5e205bcadd7;hp=a628ac22968f3dd0b9f495184fd10c08fbcac8ba;hpb=1a237369acc2140ec76f46202dfde37047ef140d;p=m6w6%2Flibmemcached diff --git a/libmemcached/options/parser.yy b/libmemcached/options/parser.yy index a628ac22..8e87230a 100644 --- a/libmemcached/options/parser.yy +++ b/libmemcached/options/parser.yy @@ -39,14 +39,14 @@ #include +#include +#include + #include -#include #include -#include -#include +#include #pragma GCC diagnostic ignored "-Wold-style-cast" -#include int conf_lex(YYSTYPE* lvalp, void* scanner); @@ -80,7 +80,7 @@ inline void config_error(Context *context, yyscan_t *scanner, const char *error) %token CONNECT_TIMEOUT %token DISTRIBUTION %token HASH -%token HASH_WITH_PREFIX_KEY +%token HASH_WITH_NAMESPACE %token IO_BYTES_WATERMARK %token IO_KEY_PREFETCH %token IO_MSG_WATERMARK @@ -106,7 +106,11 @@ inline void config_error(Context *context, yyscan_t *scanner, const char *error) %token _TCP_NODELAY /* Callbacks */ -%token PREFIX_KEY +%token NAMESPACE + +/* Pool */ +%token POOL_MIN +%token POOL_MAX /* Hash types */ %token MD5 @@ -133,19 +137,21 @@ inline void config_error(Context *context, yyscan_t *scanner, const char *error) %token FLOAT %token NUMBER -%token PORT -%token WEIGHT_START +%token PORT +%token WEIGHT_START %token IPADDRESS %token HOSTNAME %token STRING %token QUOTED_STRING %token FILE_PATH -%type string -%type distribution -%type hash %type behavior_boolean %type behavior_number +%type distribution +%type hash +%type optional_port +%type optional_weight +%type string %% @@ -181,7 +187,7 @@ statement: } | INCLUDE ' ' string { - if ((context->rc= memcached_parse_configure_file(context->memc, $3.c_str, $3.length)) != MEMCACHED_SUCCESS) + if ((context->rc= memcached_parse_configure_file(*context->memc, $3.c_str, $3.size)) != MEMCACHED_SUCCESS) { parser_abort(context, NULL); } @@ -192,7 +198,7 @@ statement: expression: SERVER HOSTNAME optional_port optional_weight { - if ((context->rc= memcached_server_add_with_weight(context->memc, $2.c_str, $2.port, $2.weight)) != MEMCACHED_SUCCESS) + if (memcached_failed(context->rc= memcached_server_add_with_weight(context->memc, $2.c_str, $3, $4))) { parser_abort(context, NULL); } @@ -200,7 +206,7 @@ expression: } | SERVER IPADDRESS optional_port optional_weight { - if ((context->rc= memcached_server_add_with_weight(context->memc, $2.c_str, $2.port, $2.weight)) != MEMCACHED_SUCCESS) + if (memcached_failed(context->rc= memcached_server_add_with_weight(context->memc, $2.c_str, $3, $4))) { parser_abort(context, NULL); } @@ -208,15 +214,23 @@ expression: } | CONFIGURE_FILE string { - memcached_set_configuration_file(context->memc, $2.c_str, $2.length); + memcached_set_configuration_file(context->memc, $2.c_str, $2.size); + } + | POOL_MIN NUMBER + { + context->memc->configure.initial_pool_size= $2; + } + | POOL_MAX NUMBER + { + context->memc->configure.max_pool_size= $2; } | behaviors ; behaviors: - PREFIX_KEY string + NAMESPACE string { - if ((context->rc= memcached_set_prefix_key(context->memc, $2.c_str, $2.length)) != MEMCACHED_SUCCESS) + if ((context->rc= memcached_set_namespace(context->memc, $2.c_str, $2.size)) != MEMCACHED_SUCCESS) { parser_abort(context, NULL);; } @@ -325,7 +339,7 @@ behavior_boolean: { $$= MEMCACHED_BEHAVIOR_BUFFER_REQUESTS; } - | HASH_WITH_PREFIX_KEY + | HASH_WITH_NAMESPACE { $$= MEMCACHED_BEHAVIOR_HASH_WITH_PREFIX_KEY; } @@ -368,13 +382,13 @@ behavior_boolean: optional_port: - { } + { $$= MEMCACHED_DEFAULT_PORT;} | PORT { }; ; optional_weight: - { } + { $$= 1; } | WEIGHT_START { } ; @@ -426,7 +440,7 @@ string: | QUOTED_STRING { $$.c_str= $1.c_str +1; // +1 to move use passed the initial quote - $$.length= $1.length -1; // -1 removes the end quote + $$.size= $1.size -2; // -2 removes the begin and end quote } ;