X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;ds=sidebyside;f=libmemcached%2Fmemcached_get.c;h=2de7acbdbc7bde3eac8cd2399031c81cab7057c3;hb=7e0ffed050b62cc5dcf5d16c148185074bfd7d50;hp=a84ef4f2a12c2416c49748e93580f61e875bc779;hpb=6f42f1c77da54da0b19274cc0d6b6c9745e40de0;p=m6w6%2Flibmemcached diff --git a/libmemcached/memcached_get.c b/libmemcached/memcached_get.c index a84ef4f2..2de7acbd 100644 --- a/libmemcached/memcached_get.c +++ b/libmemcached/memcached_get.c @@ -27,6 +27,12 @@ char *memcached_get_by_key(memcached_st *ptr, uint32_t dummy_flags; memcached_return dummy_error; + if (ptr->flags & MEM_USE_UDP) + { + *error= MEMCACHED_NOT_SUPPORTED; + return NULL; + } + /* Request the key */ *error= memcached_mget_by_key(ptr, master_key, @@ -120,6 +126,9 @@ memcached_return memcached_mget_by_key(memcached_st *ptr, uint8_t get_command_length= 4; unsigned int master_server_key= 0; + if (ptr->flags & MEM_USE_UDP) + return MEMCACHED_NOT_SUPPORTED; + LIBMEMCACHED_MEMCACHED_MGET_START(); ptr->cursor_server= 0; @@ -250,7 +259,7 @@ static memcached_return binary_mget_by_key(memcached_st *ptr, unsigned int number_of_keys) { memcached_return rc= MEMCACHED_NOTFOUND; - int x; + uint32_t x; int flush= number_of_keys == 1; @@ -274,13 +283,23 @@ static memcached_return binary_mget_by_key(memcached_st *ptr, continue; } - protocol_binary_request_getk request= {0}; + protocol_binary_request_getk request= {.bytes= {0}}; request.message.header.request.magic= PROTOCOL_BINARY_REQ; if (number_of_keys == 1) request.message.header.request.opcode= PROTOCOL_BINARY_CMD_GETK; else request.message.header.request.opcode= PROTOCOL_BINARY_CMD_GETKQ; + memcached_return vk; + vk= memcached_validate_key_length(key_length[x], + ptr->flags & MEM_BINARY_PROTOCOL); + unlikely (vk != MEMCACHED_SUCCESS) + { + if (x > 0) + memcached_io_reset(&ptr->hosts[server_key]); + return vk; + } + request.message.header.request.keylen= htons((uint16_t)key_length[x]); request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES; request.message.header.request.bodylen= htonl(key_length[x]); @@ -302,7 +321,7 @@ static memcached_return binary_mget_by_key(memcached_st *ptr, /* * Send a noop command to flush the buffers */ - protocol_binary_request_noop request= {0}; + protocol_binary_request_noop request= {.bytes= {0}}; request.message.header.request.magic= PROTOCOL_BINARY_REQ; request.message.header.request.opcode= PROTOCOL_BINARY_CMD_NOOP; request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES;