X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=src%2Flibmemcachedprotocol%2Fbinary_handler.c;h=cdc03b93e3ae1b261b2b15f902312ff93d652038;hb=1a15a0895b863a02d598a317f4c0215edef12dc5;hp=ada4c42599cc999fe62c50d796fbe175b2cebdae;hpb=cb40bfe8923a2b06160a965d95b45ca0ea3421ab;p=awesomized%2Flibmemcached diff --git a/src/libmemcachedprotocol/binary_handler.c b/src/libmemcachedprotocol/binary_handler.c index ada4c425..cdc03b93 100644 --- a/src/libmemcachedprotocol/binary_handler.c +++ b/src/libmemcachedprotocol/binary_handler.c @@ -1,6 +1,6 @@ /* +--------------------------------------------------------------------+ - | libmemcached - C/C++ Client Library for memcached | + | libmemcached-awesome - C/C++ Client Library for memcached | +--------------------------------------------------------------------+ | Redistribution and use in source and binary forms, with or without | | modification, are permitted under the terms of the BSD license. | @@ -9,11 +9,12 @@ | the terms online at: https://opensource.org/licenses/BSD-3-Clause | +--------------------------------------------------------------------+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ | - | Copyright (c) 2020 Michael Wallner | + | Copyright (c) 2020-2021 Michael Wallner https://awesome.co/ | +--------------------------------------------------------------------+ */ #include "libmemcachedprotocol/common.h" +#include "p9y/socket.hpp" #include #include @@ -43,7 +44,7 @@ binary_raw_response_handler(const void *cookie, protocol_binary_request_header * protocol_binary_response_header *response) { memcached_protocol_client_st *client = (void *) cookie; - if (client->root->pedantic + if (response && client->root->pedantic && !memcached_binary_protocol_pedantic_check_response(request, response)) { return PROTOCOL_BINARY_RESPONSE_EINVAL; } @@ -52,6 +53,10 @@ binary_raw_response_handler(const void *cookie, protocol_binary_request_header * return PROTOCOL_BINARY_RESPONSE_EINTERNAL; } + if (!response) { + return PROTOCOL_BINARY_RESPONSE_SUCCESS; + } + size_t len = sizeof(protocol_binary_response_header) + htonl(response->response.bodylen); size_t offset = 0; char *ptr = (void *) response; @@ -916,6 +921,20 @@ stat_command_handler(const void *cookie, protocol_binary_request_header *header, rval = client->root->callback->interface.v1.stat(cookie, (void *) (header + 1), keylen, stat_response_handler); + if (rval == PROTOCOL_BINARY_RESPONSE_SUCCESS) { + /* END message */ + protocol_binary_response_no_extras response = { + .message = { + .header.response = + { + .magic = PROTOCOL_BINARY_RES, + .opcode = PROTOCOL_BINARY_CMD_STAT, + .status = htons(PROTOCOL_BINARY_RESPONSE_SUCCESS), + .opaque = header->request.opaque, + }, + }}; + rval = response_handler(cookie, header, (void *) &response); + } } else { rval = PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND; } @@ -940,6 +959,9 @@ version_command_handler(const void *cookie, protocol_binary_request_header *head memcached_protocol_client_st *client = (void *) cookie; if (client->root->callback->interface.v1.version) { rval = client->root->callback->interface.v1.version(cookie, version_response_handler); + if (rval == PROTOCOL_BINARY_RESPONSE_SUCCESS) { + rval = response_handler(cookie, header, NULL); + } } else { rval = PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND; }