X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Fcsl%2Fparser.yy;h=48d4d4e925ee2fc457f7c9cebbf9d364cbe03115;hb=a509498cb4ed697b20da4822d6ddccaf6a246b66;hp=fd8d0c264aa0fab5ce458fd63f1b5c24ee6a0c4b;hpb=aeb06adc2d73bd2e481c162e3ac162f93a006382;p=m6w6%2Flibmemcached diff --git a/libmemcached/csl/parser.yy b/libmemcached/csl/parser.yy index fd8d0c26..48d4d4e9 100644 --- a/libmemcached/csl/parser.yy +++ b/libmemcached/csl/parser.yy @@ -42,7 +42,9 @@ #include #include +#ifndef __INTEL_COMPILER #pragma GCC diagnostic ignored "-Wold-style-cast" +#endif int conf_lex(YYSTYPE* lvalp, void* scanner); @@ -186,7 +188,7 @@ statement: | ERROR { context->rc= MEMCACHED_PARSE_USER_ERROR; - parser_abort(context, NULL); + parser_abort(context, "ERROR called directly"); } | RESET { @@ -200,7 +202,7 @@ statement: { if ((context->rc= memcached_parse_configure_file(*context->memc, $3.c_str, $3.size)) != MEMCACHED_SUCCESS) { - parser_abort(context, NULL); + parser_abort(context, "Failed to parse configuration file"); } } ; @@ -211,7 +213,9 @@ expression: { if (memcached_failed(context->rc= memcached_server_add_with_weight(context->memc, $2.c_str, $3, $4))) { - parser_abort(context, NULL); + char buffer[1024]; + snprintf(buffer, sizeof(buffer), "Failed to add server: %s:%u", $2.c_str, uint32_t($3)); + parser_abort(context, buffer); } context->unset_server(); } @@ -219,7 +223,9 @@ expression: { if (memcached_failed(context->rc= memcached_server_add_with_weight(context->memc, $2.c_str, $3, $4))) { - parser_abort(context, NULL); + char buffer[1024]; + snprintf(buffer, sizeof(buffer), "Failed to add server: %s:%u", $2.c_str, uint32_t($3)); + parser_abort(context, buffer); } context->unset_server(); } @@ -227,7 +233,9 @@ expression: { if (memcached_failed(context->rc= memcached_server_add_unix_socket_with_weight(context->memc, $2.c_str, $3))) { - parser_abort(context, NULL); + char buffer[1024]; + snprintf(buffer, sizeof(buffer), "Failed to add server: %s", $2.c_str); + parser_abort(context, buffer); } } | CONFIGURE_FILE string @@ -248,48 +256,63 @@ expression: behaviors: NAMESPACE string { + if (memcached_callback_get(context->memc, MEMCACHED_CALLBACK_PREFIX_KEY, NULL)) + { + parser_abort(context, "--NAMESPACE can only be called once"); + } + if ((context->rc= memcached_set_namespace(context->memc, $2.c_str, $2.size)) != MEMCACHED_SUCCESS) { - parser_abort(context, NULL);; + parser_abort(context, memcached_last_error_message(context->memc)); } } | DISTRIBUTION distribution { + // Check to see if DISTRIBUTION has already been set + if ((context->rc= memcached_behavior_set(context->memc, MEMCACHED_BEHAVIOR_DISTRIBUTION, $2)) != MEMCACHED_SUCCESS) + { + parser_abort(context, "--DISTRIBUTION can only be called once"); + } + if ((context->rc= memcached_behavior_set(context->memc, MEMCACHED_BEHAVIOR_DISTRIBUTION, $2)) != MEMCACHED_SUCCESS) { - parser_abort(context, NULL);; + parser_abort(context, memcached_last_error_message(context->memc));; } } | DISTRIBUTION distribution ',' hash { + // Check to see if DISTRIBUTION has already been set if ((context->rc= memcached_behavior_set(context->memc, MEMCACHED_BEHAVIOR_DISTRIBUTION, $2)) != MEMCACHED_SUCCESS) { - parser_abort(context, NULL);; + parser_abort(context, "--DISTRIBUTION can only be called once"); } + if ((context->rc= memcached_behavior_set_distribution_hash(context->memc, $4)) != MEMCACHED_SUCCESS) { - parser_abort(context, NULL);; + parser_abort(context, "Unable to set the hash for the DISTRIBUTION requested"); } } | HASH hash { - if ((context->rc= memcached_behavior_set(context->memc, MEMCACHED_BEHAVIOR_HASH, $2)) != MEMCACHED_SUCCESS) + if (context->set_hash($2) == false) { - parser_abort(context, NULL);; + parser_abort(context, "--HASH can only be set once"); } } | behavior_number NUMBER { if ((context->rc= memcached_behavior_set(context->memc, $1, $2)) != MEMCACHED_SUCCESS) { - parser_abort(context, NULL);; + parser_abort(context, "Unable to set behavior"); } } | behavior_boolean { if ((context->rc= memcached_behavior_set(context->memc, $1, true)) != MEMCACHED_SUCCESS) { - parser_abort(context, NULL);; + char buffer[1024]; + snprintf(buffer, sizeof(buffer), "Could not set: %s", libmemcached_string_behavior($1)); + parser_abort(context, buffer); } } | USER_DATA