Skip to content

Commit

Permalink
Merge pull request #241 from uhm0311/uhm0311/check_update_call_exist
Browse files Browse the repository at this point in the history
FIX: Call arcus_server_check_for_update() in memcached_exist_by_key() #240
  • Loading branch information
jhpark816 authored Mar 15, 2022
2 parents 83073f1 + 8fe7e52 commit 222d6cf
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions libmemcached/exist.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,25 @@
*/

#include <libmemcached/common.h>
#ifdef LIBMEMCACHED_WITH_ZK_INTEGRATION
#include "libmemcached/arcus_priv.h"
#endif

static memcached_return_t ascii_exist(memcached_st *memc,
const char *group_key,
size_t group_key_length,
const char *key,
size_t key_length)
{
#ifdef LIBMEMCACHED_WITH_ZK_INTEGRATION
struct libmemcached_io_vector_st vector[]=
{
{ sizeof("getattr ") -1, "getattr " },
{ memcached_array_size(memc->_namespace), memcached_array_string(memc->_namespace) },
{ key_length, key },
{ 2, "\r\n" }
};
#else
struct libmemcached_io_vector_st vector[]=
{
{ sizeof("add ") -1, "add " },
Expand All @@ -69,22 +81,33 @@ static memcached_return_t ascii_exist(memcached_st *memc,
{ 2, "\r\n" },
{ 2, "\r\n" }
};
#endif

uint32_t server_key= memcached_generate_hash_with_redistribution(memc, group_key, group_key_length);
memcached_server_write_instance_st instance= memcached_server_instance_fetch(memc, server_key);

/* Send command header */
#ifdef LIBMEMCACHED_WITH_ZK_INTEGRATION
memcached_return_t rc= memcached_vdo(instance, vector, 4, true);
#else
memcached_return_t rc= memcached_vdo(instance, vector, 8, true);
#endif
if (rc == MEMCACHED_SUCCESS)
{
char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
#ifdef LIBMEMCACHED_WITH_ZK_INTEGRATION
while ((rc= memcached_coll_response(instance, buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, NULL)) == MEMCACHED_ATTR);
if (rc == MEMCACHED_END)
rc= MEMCACHED_SUCCESS;
#else
rc= memcached_response(instance, buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, NULL);

if (rc == MEMCACHED_NOTSTORED)
rc= MEMCACHED_SUCCESS;

if (rc == MEMCACHED_STORED)
rc= MEMCACHED_NOTFOUND;
#endif
}

if (rc == MEMCACHED_WRITE_FAILURE)
Expand Down Expand Up @@ -152,6 +175,9 @@ memcached_return_t memcached_exist_by_key(memcached_st *memc,
const char *group_key, size_t group_key_length,
const char *key, size_t key_length)
{
#ifdef LIBMEMCACHED_WITH_ZK_INTEGRATION
arcus_server_check_for_update(memc);
#endif
memcached_return_t rc;
if (memcached_failed(rc= initialize_query(memc)))
{
Expand Down

0 comments on commit 222d6cf

Please sign in to comment.