memcached_server_instance_st *instance;
bool no_reply= ptr->flags.no_reply;
- unlikely (ptr->hosts == NULL || memcached_server_count(ptr) == 0)
+ unlikely (memcached_server_count(ptr) == 0)
return MEMCACHED_NO_SERVERS;
if (ptr->flags.verify_key && (memcached_key_test((const char **)&key, &key_length, 1) == MEMCACHED_BAD_KEY_PROVIDED))
memcached_server_instance_st *instance;
bool no_reply= ptr->flags.no_reply;
- unlikely (ptr->hosts == NULL || memcached_server_count(ptr) == 0)
+ unlikely (memcached_server_count(ptr) == 0)
return MEMCACHED_NO_SERVERS;
server_key= memcached_generate_hash(ptr, master_key, master_key_length);
{
int sock_size;
socklen_t sock_length= sizeof(int);
+ memcached_server_instance_st *instance;
+
+ instance= memcached_server_instance_fetch(ptr, 0);
/* REFACTOR */
/* We just try the first host, and if it is down we return zero */
- if ((memcached_connect(&ptr->hosts[0])) != MEMCACHED_SUCCESS)
+ if ((memcached_connect(instance)) != MEMCACHED_SUCCESS)
return 0;
- if (getsockopt(ptr->hosts[0].fd, SOL_SOCKET,
+ if (getsockopt(instance->fd, SOL_SOCKET,
SO_SNDBUF, &sock_size, &sock_length))
return 0; /* Zero means error */
{
int sock_size;
socklen_t sock_length= sizeof(int);
+ memcached_server_instance_st *instance;
+
+ instance= memcached_server_instance_fetch(ptr, 0);
/**
@note REFACTOR
*/
/* We just try the first host, and if it is down we return zero */
- if ((memcached_connect(&ptr->hosts[0])) != MEMCACHED_SUCCESS)
+ if ((memcached_connect(instance)) != MEMCACHED_SUCCESS)
return 0;
- if (getsockopt(ptr->hosts[0].fd, SOL_SOCKET,
+ if (getsockopt(instance->fd, SOL_SOCKET,
SO_RCVBUF, &sock_size, &sock_length))
return 0; /* Zero means error */
unlikely (rc != MEMCACHED_SUCCESS)
return rc;
- unlikely (ptr->hosts == NULL || memcached_server_count(ptr) == 0)
+ unlikely (memcached_server_count(ptr) == 0)
return MEMCACHED_NO_SERVERS;
server_key= memcached_generate_hash(ptr, master_key, master_key_length);
for (x= 0; x < memcached_server_count(ptr); x++)
{
bool no_reply= ptr->flags.no_reply;
+ memcached_server_instance_st *instance=
+ memcached_server_instance_fetch(ptr, x);
if (expiration)
send_length= (size_t) snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE,
send_length= (size_t) snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE,
"flush_all%s\r\n", no_reply ? " noreply" : "");
- rc= memcached_do(&ptr->hosts[x], buffer, send_length, 1);
+ rc= memcached_do(instance, buffer, send_length, 1);
if (rc == MEMCACHED_SUCCESS && !no_reply)
- (void)memcached_response(&ptr->hosts[x], buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, NULL);
+ (void)memcached_response(instance, buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, NULL);
}
return MEMCACHED_SUCCESS;
static memcached_return_t memcached_flush_binary(memcached_st *ptr,
time_t expiration)
{
- unsigned int x;
+ uint32_t x;
protocol_binary_request_flush request= {.bytes= {0}};
unlikely (memcached_server_count(ptr) == 0)
for (x= 0; x < memcached_server_count(ptr); x++)
{
+ memcached_server_instance_st *instance=
+ memcached_server_instance_fetch(ptr, x);
+
if (ptr->flags.no_reply)
+ {
request.message.header.request.opcode= PROTOCOL_BINARY_CMD_FLUSHQ;
+ }
else
+ {
request.message.header.request.opcode= PROTOCOL_BINARY_CMD_FLUSH;
- if (memcached_do(&ptr->hosts[x], request.bytes,
+ }
+
+ if (memcached_do(instance, request.bytes,
sizeof(request.bytes), 1) != MEMCACHED_SUCCESS)
{
- memcached_io_reset(&ptr->hosts[x]);
+ memcached_io_reset(instance);
return MEMCACHED_WRITE_FAILURE;
}
}
for (x= 0; x < memcached_server_count(ptr); x++)
{
- if (memcached_server_response_count(&ptr->hosts[x]) > 0)
- (void)memcached_response(&ptr->hosts[x], NULL, 0, NULL);
+ memcached_server_instance_st *instance=
+ memcached_server_instance_fetch(ptr, x);
+
+ if (memcached_server_response_count(instance) > 0)
+ (void)memcached_response(instance, NULL, 0, NULL);
}
return MEMCACHED_SUCCESS;
memcached_return_t ret= MEMCACHED_SUCCESS;
for (uint32_t x= 0; x < memcached_server_count(memc); ++x)
- if (memc->hosts[x].write_buffer_offset != 0)
+ {
+ memcached_server_instance_st *instance=
+ memcached_server_instance_fetch(memc, x);
+
+ if (instance->write_buffer_offset != 0)
{
- if (memc->hosts[x].fd == -1 &&
- (ret= memcached_connect(&memc->hosts[x])) != MEMCACHED_SUCCESS)
+ if (instance->fd == -1 &&
+ (ret= memcached_connect(instance)) != MEMCACHED_SUCCESS)
{
WATCHPOINT_ERROR(ret);
return ret;
}
- if (memcached_io_write(&memc->hosts[x], NULL, 0, 1) == -1)
+ if (memcached_io_write(instance, NULL, 0, 1) == -1)
ret= MEMCACHED_SOME_ERRORS;
}
+ }
return ret;
}
*/
for (x= 0; x < memcached_server_count(ptr); x++)
{
- if (memcached_server_response_count(&ptr->hosts[x]))
+ memcached_server_instance_st *instance=
+ memcached_server_instance_fetch(ptr, x);
+
+ if (memcached_server_response_count(instance))
{
char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
if (ptr->flags.no_block)
- (void)memcached_io_write(&ptr->hosts[x], NULL, 0, 1);
+ (void)memcached_io_write(instance, NULL, 0, 1);
- while(memcached_server_response_count(&ptr->hosts[x]))
- (void)memcached_response(&ptr->hosts[x], buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, &ptr->result);
+ while(memcached_server_response_count(instance))
+ (void)memcached_response(instance, buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, &ptr->result);
}
}
*/
for (x= 0; x < memcached_server_count(ptr); x++)
{
- if (memcached_server_response_count(&ptr->hosts[x]))
+ memcached_server_instance_st *instance=
+ memcached_server_instance_fetch(ptr, x);
+
+ if (memcached_server_response_count(instance))
{
/* We need to do something about non-connnected hosts in the future */
- if ((memcached_io_write(&ptr->hosts[x], "\r\n", 2, 1)) == -1)
+ if ((memcached_io_write(instance, "\r\n", 2, 1)) == -1)
{
rc= MEMCACHED_SOME_ERRORS;
}
request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES;
for (x= 0; x < memcached_server_count(ptr); x++)
- if (memcached_server_response_count(&ptr->hosts[x]))
+ {
+ memcached_server_instance_st *instance=
+ memcached_server_instance_fetch(ptr, x);
+
+ if (memcached_server_response_count(instance))
{
- if (memcached_io_write(&ptr->hosts[x], NULL, 0, 1) == -1)
+ if (memcached_io_write(instance, NULL, 0, 1) == -1)
{
- memcached_server_response_reset(&ptr->hosts[x]);
- memcached_io_reset(&ptr->hosts[x]);
+ memcached_server_response_reset(instance);
+ memcached_io_reset(instance);
rc= MEMCACHED_SOME_ERRORS;
}
- if (memcached_io_write(&ptr->hosts[x], request.bytes,
+ if (memcached_io_write(instance, request.bytes,
sizeof(request.bytes), 1) == -1)
{
- memcached_server_response_reset(&ptr->hosts[x]);
- memcached_io_reset(&ptr->hosts[x]);
+ memcached_server_response_reset(instance);
+ memcached_io_reset(instance);
rc= MEMCACHED_SOME_ERRORS;
}
}
+ }
}
for (x= 0; x < number_of_keys; ++x)
{
+ memcached_server_instance_st *instance;
+
if (hash[x] == memcached_server_count(ptr))
continue; /* Already successfully sent */
if (dead_servers[server])
continue;
- if (memcached_server_response_count(&ptr->hosts[server]) == 0)
+ instance= memcached_server_instance_fetch(ptr, server);
+
+ if (memcached_server_response_count(instance) == 0)
{
- rc= memcached_connect(&ptr->hosts[server]);
+ rc= memcached_connect(instance);
if (rc != MEMCACHED_SUCCESS)
{
- memcached_io_reset(&ptr->hosts[server]);
+ memcached_io_reset(instance);
dead_servers[server]= true;
success= false;
continue;
* that we might have processed some of the responses etc. For now,
* just make sure we work _correctly_
*/
- if ((memcached_io_write(&ptr->hosts[server], request.bytes,
+ if ((memcached_io_write(instance, request.bytes,
sizeof(request.bytes), 0) == -1) ||
- (memcached_io_write(&ptr->hosts[server], keys[x],
+ (memcached_io_write(instance, keys[x],
key_length[x], 1) == -1))
{
- memcached_io_reset(&ptr->hosts[server]);
+ memcached_io_reset(instance);
dead_servers[server]= true;
success= false;
continue;
}
- memcached_server_response_increment(&ptr->hosts[server]);
+ memcached_server_response_increment(instance);
hash[x]= memcached_server_count(ptr);
}
{
if (memcached_server_count(ptr))
{
- qsort(ptr->hosts, memcached_server_count(ptr), sizeof(memcached_server_instance_st), compare_servers);
- ptr->hosts[0].number_of_hosts= memcached_server_count(ptr);
+ memcached_server_instance_st *instance;
+
+ qsort(memcached_server_list(ptr), memcached_server_count(ptr), sizeof(memcached_server_instance_st), compare_servers);
+ instance= memcached_server_instance_fetch(ptr, 0);
+ instance->number_of_hosts= memcached_server_count(ptr);
}
}
return MEMCACHED_ERRNO;
}
- list = ptr->hosts;
+ list = memcached_server_list(ptr);
/* count live servers (those without a retry delay set) */
is_auto_ejecting= memcached_behavior_get(ptr, MEMCACHED_BEHAVIOR_AUTO_EJECT_HOSTS);
return MEMCACHED_SUCCESS;
count= memcached_servers_count(list);
- new_host_list= ptr->call_realloc(ptr, ptr->hosts,
+ new_host_list= ptr->call_realloc(ptr, memcached_server_list(ptr),
sizeof(memcached_server_instance_st) * (count + memcached_server_count(ptr)));
if (! new_host_list)
return MEMCACHED_MEMORY_ALLOCATION_FAILURE;
- ptr->hosts= new_host_list;
+ memcached_server_list_set(ptr, new_host_list);
for (x= 0; x < count; x++)
{
+ memcached_server_instance_st *instance;
+
if ((ptr->flags.use_udp && list[x].type != MEMCACHED_CONNECTION_UDP)
|| ((list[x].type == MEMCACHED_CONNECTION_UDP)
&& ! (ptr->flags.use_udp)) )
return MEMCACHED_INVALID_HOST_PROTOCOL;
WATCHPOINT_ASSERT(list[x].hostname[0] != 0);
- memcached_server_create(ptr, &ptr->hosts[memcached_server_count(ptr)]);
+
+ instance= memcached_server_instance_fetch(ptr, memcached_server_count(ptr));
+
+ memcached_server_create(ptr, instance);
/* TODO check return type */
- (void)memcached_server_create_with(ptr, &ptr->hosts[memcached_server_count(ptr)], list[x].hostname,
+ (void)memcached_server_create_with(ptr, instance, list[x].hostname,
list[x].port, list[x].weight, list[x].type);
ptr->number_of_hosts++;
}
- ptr->hosts[0].number_of_hosts= memcached_server_count(ptr);
+
+ // Provides backwards compatibility with server list.
+ {
+ memcached_server_instance_st *instance;
+ instance= memcached_server_instance_fetch(ptr, 0);
+ instance->number_of_hosts= memcached_server_count(ptr);
+ }
return run_distribution(ptr);
}
memcached_connection_t type)
{
memcached_server_instance_st *new_host_list;
+ memcached_server_instance_st *instance;
if ( (ptr->flags.use_udp && type != MEMCACHED_CONNECTION_UDP)
|| ( (type == MEMCACHED_CONNECTION_UDP) && (! ptr->flags.use_udp) ) )
return MEMCACHED_INVALID_HOST_PROTOCOL;
- new_host_list= ptr->call_realloc(ptr, ptr->hosts,
+ new_host_list= ptr->call_realloc(ptr, memcached_server_list(ptr),
sizeof(memcached_server_instance_st) * (ptr->number_of_hosts + 1));
if (new_host_list == NULL)
return MEMCACHED_MEMORY_ALLOCATION_FAILURE;
- ptr->hosts= new_host_list;
+ memcached_server_list_set(ptr, new_host_list);
/* TODO: Check return type */
- (void)memcached_server_create_with(ptr, &ptr->hosts[memcached_server_count(ptr)], hostname, port, weight, type);
+ instance= memcached_server_instance_fetch(ptr, memcached_server_count(ptr));
+ (void)memcached_server_create_with(ptr, instance, hostname, port, weight, type);
ptr->number_of_hosts++;
- memcached_servers_set_count(&ptr->hosts[0], memcached_server_count(ptr));
+ instance= memcached_server_instance_fetch(ptr, 0);
+ memcached_servers_set_count(instance, memcached_server_count(ptr));
return run_distribution(ptr);
}
{
uint32_t x, host_index;
memcached_st *ptr= st_ptr->root;
- memcached_server_st *list= ptr->hosts;
+ memcached_server_st *list= memcached_server_list(ptr);
for (x= 0, host_index= 0; x < memcached_server_count(ptr); x++)
{
struct pollfd fds[MAX_SERVERS_TO_POLL];
unsigned int host_index= 0;
- for (unsigned int x= 0;
+ for (uint32_t x= 0;
x< memcached_server_count(memc) && host_index < MAX_SERVERS_TO_POLL;
++x)
{
- if (memc->hosts[x].read_buffer_length > 0) /* I have data in the buffer */
- return &memc->hosts[x];
+ memcached_server_instance_st *instance=
+ memcached_server_instance_fetch(memc, x);
- if (memcached_server_response_count(&memc->hosts[x]) > 0)
+ if (instance->read_buffer_length > 0) /* I have data in the buffer */
+ return instance;
+
+ if (memcached_server_response_count(instance) > 0)
{
fds[host_index].events = POLLIN;
fds[host_index].revents = 0;
- fds[host_index].fd = memc->hosts[x].fd;
+ fds[host_index].fd = instance->fd;
++host_index;
}
}
if (host_index < 2)
{
/* We have 0 or 1 server with pending events.. */
- for (unsigned int x= 0; x< memcached_server_count(memc); ++x)
- if (memcached_server_response_count(&memc->hosts[x]) > 0)
- return &memc->hosts[x];
+ for (uint32_t x= 0; x< memcached_server_count(memc); ++x)
+ {
+ memcached_server_instance_st *instance=
+ memcached_server_instance_fetch(memc, x);
+
+ if (memcached_server_response_count(instance) > 0)
+ {
+ return instance;
+ }
+ }
return NULL;
}
{
if (fds[x].revents & POLLIN)
{
- for (unsigned int y= 0; y < memcached_server_count(memc); ++y)
+ for (uint32_t y= 0; y < memcached_server_count(memc); ++y)
{
- if (memc->hosts[y].fd == fds[x].fd)
- return &memc->hosts[y];
+ memcached_server_instance_st *instance=
+ memcached_server_instance_fetch(memc, y);
+
+ if (instance->fd == fds[x].fd)
+ return instance;
}
}
}
void memcached_servers_reset(memcached_st *ptr)
{
- server_list_free(ptr, ptr->hosts);
+ server_list_free(ptr, memcached_server_list(ptr));
- ptr->hosts= NULL;
+ memcached_server_list_set(ptr, NULL);
ptr->number_of_hosts= 0;
ptr->last_disconnected_server= NULL;
ptr->server_failure_limit= 0;
{
/* If we have anything open, lets close it now */
memcached_quit(ptr);
- server_list_free(ptr, ptr->hosts);
+ server_list_free(ptr, memcached_server_list(ptr));
memcached_result_free(&ptr->result);
if (ptr->on_cleanup)
new_clone->io_key_prefetch= source->io_key_prefetch;
new_clone->number_of_replicas= source->number_of_replicas;
- if (source->hosts)
- rc= memcached_server_push(new_clone, source->hosts);
+ if (memcached_server_list(source))
+ rc= memcached_server_push(new_clone, memcached_server_list(source));
if (rc != MEMCACHED_SUCCESS)
{
void memcached_quit(memcached_st *ptr)
{
- unsigned int x;
+ uint32_t x;
- if (ptr->hosts == NULL ||
- memcached_server_count(ptr) == 0)
+ if (memcached_server_count(ptr) == 0)
return;
- if (ptr->hosts && memcached_server_count(ptr))
+ if (memcached_server_count(ptr))
{
for (x= 0; x < memcached_server_count(ptr); x++)
- memcached_quit_server(&ptr->hosts[x], 0);
+ {
+ memcached_server_instance_st *instance=
+ memcached_server_instance_fetch(ptr, x);
+
+ memcached_quit_server(instance, 0);
+ }
}
}
for (y= 0; y < memcached_server_count(ptr); y++)
{
uint32_t x;
+ memcached_server_instance_st *instance=
+ memcached_server_instance_fetch(ptr, y);
for (x= 0; x < number_of_callbacks; x++)
{
unsigned int iferror;
- iferror= (*callback[x])(ptr, &ptr->hosts[y], context);
+ iferror= (*callback[x])(ptr, instance, context);
if (iferror)
continue;
#define memcached_server_name(A,B) (B).hostname
#define memcached_server_port(A,B) (B).port
#define memcached_server_list(A) (A)->hosts
+#define memcached_server_list_set(A,B) (A)->hosts=(B)
#define memcached_server_response_count(A) (A)->cursor_active
LIBMEMCACHED_API
memcached_return_t memcached_verbosity(memcached_st *ptr, unsigned int verbosity)
{
- unsigned int x;
+ uint32_t x;
size_t send_length;
memcached_return_t rc;
char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
for (x= 0; x < memcached_server_count(ptr); x++)
{
memcached_return_t rrc;
+ memcached_server_instance_st *instance=
+ memcached_server_instance_fetch(ptr, x);
- rrc= memcached_do(&ptr->hosts[x], buffer, send_length, 1);
+ rrc= memcached_do(instance, buffer, send_length, 1);
if (rrc != MEMCACHED_SUCCESS)
{
rc= MEMCACHED_SOME_ERRORS;
unlikely (ptr->flags.use_udp)
continue;
- rrc= memcached_response(&ptr->hosts[x], buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, NULL);
+ rrc= memcached_response(instance, buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, NULL);
if (rrc != MEMCACHED_SUCCESS)
rc= MEMCACHED_SOME_ERRORS;
}
for (x= 0; x < memcached_server_count(ptr); x++)
{
memcached_return_t rrc;
+ memcached_server_instance_st *instance=
+ memcached_server_instance_fetch(ptr, x);
- rrc= memcached_do(&ptr->hosts[x], command, send_length, 1);
+ rrc= memcached_do(instance, command, send_length, 1);
if (rrc != MEMCACHED_SUCCESS)
{
rc= MEMCACHED_SOME_ERRORS;
continue;
}
- rrc= memcached_response(&ptr->hosts[x], buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, NULL);
+ rrc= memcached_response(instance, buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, NULL);
if (rrc != MEMCACHED_SUCCESS)
{
rc= MEMCACHED_SOME_ERRORS;
response_ptr= index(buffer, ' ');
response_ptr++;
- ptr->hosts[x].major_version= (uint8_t)strtol(response_ptr, (char **)NULL, 10);
+ instance->major_version= (uint8_t)strtol(response_ptr, (char **)NULL, 10);
response_ptr= index(response_ptr, '.');
response_ptr++;
- ptr->hosts[x].minor_version= (uint8_t)strtol(response_ptr, (char **)NULL, 10);
+ instance->minor_version= (uint8_t)strtol(response_ptr, (char **)NULL, 10);
response_ptr= index(response_ptr, '.');
response_ptr++;
- ptr->hosts[x].micro_version= (uint8_t)strtol(response_ptr, (char **)NULL, 10);
+ instance->micro_version= (uint8_t)strtol(response_ptr, (char **)NULL, 10);
}
return rc;
{
memcached_return_t rrc;
- rrc= memcached_do(&ptr->hosts[x], request.bytes, sizeof(request.bytes), 1);
+ memcached_server_instance_st *instance=
+ memcached_server_instance_fetch(ptr, x);
+
+ rrc= memcached_do(instance, request.bytes, sizeof(request.bytes), 1);
if (rrc != MEMCACHED_SUCCESS)
{
- memcached_io_reset(&ptr->hosts[x]);
+ memcached_io_reset(instance);
rc= MEMCACHED_SOME_ERRORS;
continue;
}
for (x= 0; x < memcached_server_count(ptr); x++)
{
- if (memcached_server_response_count(&ptr->hosts[x]) > 0)
+ memcached_server_instance_st *instance=
+ memcached_server_instance_fetch(ptr, x);
+
+ if (memcached_server_response_count(instance) > 0)
{
memcached_return_t rrc;
char buffer[32];
char *p;
- rrc= memcached_response(&ptr->hosts[x], buffer, sizeof(buffer), NULL);
+ rrc= memcached_response(instance, buffer, sizeof(buffer), NULL);
if (rrc != MEMCACHED_SUCCESS)
{
- memcached_io_reset(&ptr->hosts[x]);
+ memcached_io_reset(instance);
rc= MEMCACHED_SOME_ERRORS;
continue;
}
- ptr->hosts[x].major_version= (uint8_t)strtol(buffer, &p, 10);
- ptr->hosts[x].minor_version= (uint8_t)strtol(p + 1, &p, 10);
- ptr->hosts[x].micro_version= (uint8_t)strtol(p + 1, NULL, 10);
+ instance->major_version= (uint8_t)strtol(buffer, &p, 10);
+ instance->minor_version= (uint8_t)strtol(p + 1, &p, 10);
+ instance->micro_version= (uint8_t)strtol(p + 1, NULL, 10);
}
}
for (loop= 0; loop < memcached_server_list_count(container->construct.servers); loop++)
{
- test_truth(container->memc->hosts[loop].fd == -1);
- test_truth(container->memc->hosts[loop].cursor_active == 0);
+ memcached_server_st *instance=
+ memcached_server_instance_fetch(container->memc, loop);
+
+ test_truth(instance->fd == -1);
+ test_truth(instance->cursor_active == 0);
}
return TEST_SUCCESS;
test_ports[x]= (uint32_t)random() % 64000;
rc= memcached_server_add_with_weight(local_memc, "localhost", test_ports[x], 0);
test_truth(memcached_server_count(local_memc) == x + 1);
- test_truth(memcached_servers_count(local_memc->hosts) == x+1);
+ test_truth(memcached_servers_count(memcached_server_list(local_memc)) == x+1);
test_truth(rc == MEMCACHED_SUCCESS);
}
static test_return_t regression_bug_447342(memcached_st *memc)
{
+ memcached_server_instance_st *instance_one;
+ memcached_server_instance_st *instance_two;
+
if (memcached_server_count(memc) < 3 || pre_replication(memc) != MEMCACHED_SUCCESS)
return TEST_SKIPPED;
* This is to verify correct behavior in the library. Fake that two servers
* are dead..
*/
- in_port_t port0= memc->hosts[0].port;
- in_port_t port2= memc->hosts[2].port;
+ instance_one= memcached_server_instance_fetch(memc, 0);
+ instance_two= memcached_server_instance_fetch(memc, 2);
+ in_port_t port0= instance_one->port;
+ in_port_t port2= instance_two->port;
- memc->hosts[0].port= 0;
- memc->hosts[2].port= 0;
+ instance_one->port= 0;
+ instance_two->port= 0;
rc= memcached_mget(memc, (const char* const *)keys, key_length, max_keys);
test_truth(rc == MEMCACHED_SUCCESS);
test_truth(counter == (unsigned int)max_keys);
/* restore the memc handle */
- memc->hosts[0].port= port0;
- memc->hosts[2].port= port2;
+ instance_one->port= port0;
+ instance_two->port= port2;
memcached_quit(memc);
}
memcached_quit(memc);
- memc->hosts[0].port= 0;
- memc->hosts[2].port= 0;
+ instance_one->port= 0;
+ instance_two->port= 0;
/* now retry the command, this time we should have cache misses */
rc= memcached_mget(memc, (const char* const *)keys, key_length, max_keys);
free(key_length);
/* restore the memc handle */
- memc->hosts[0].port= port0;
- memc->hosts[2].port= port2;
+ instance_one->port= port0;
+ instance_two->port= port2;
return TEST_SUCCESS;
}
static test_return_t wrong_failure_counter_test(memcached_st *memc)
{
memcached_return_t rc;
+ memcached_server_instance_st *instance;
/* Set value to force connection to the server */
const char *key= "marmotte";
test_truth(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
+ instance= memcached_server_instance_fetch(memc, 0);
/* The test is to see that the memcached_quit doesn't increase the
* the server failure conter, so let's ensure that it is zero
* before sending quit
*/
- memc->hosts[0].server_failure_counter= 0;
+ instance->server_failure_counter= 0;
memcached_quit(memc);
* Please note that this isn't bullet proof, because an error could
* occur...
*/
- test_truth(memc->hosts[0].server_failure_counter == 0);
+ test_truth(instance->server_failure_counter == 0);
/* restore the instance */
memc->number_of_hosts= number_of_hosts;