X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Fcsl%2Fparser.yy;h=48d4d4e925ee2fc457f7c9cebbf9d364cbe03115;hb=3dcd41c50068eec906a1a11a178e9b3f08ef2326;hp=08441987e9b9e7412a447d1e13338b937e1c681d;hpb=3645e647825396693c46a4de5d9e45dfde54dabd;p=m6w6%2Flibmemcached diff --git a/libmemcached/csl/parser.yy b/libmemcached/csl/parser.yy index 08441987..48d4d4e9 100644 --- a/libmemcached/csl/parser.yy +++ b/libmemcached/csl/parser.yy @@ -188,7 +188,7 @@ statement: | ERROR { context->rc= MEMCACHED_PARSE_USER_ERROR; - parser_abort(context, NULL); + parser_abort(context, "ERROR called directly"); } | RESET { @@ -202,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"); } } ; @@ -213,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(); } @@ -221,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(); } @@ -229,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 @@ -250,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