sent_length= memcached_io_write(ptr, command, command_length, with_flush);
- if (sent_length == -1 || sent_length != command_length)
+ if (sent_length == -1 || (size_t)sent_length != command_length)
rc= MEMCACHED_WRITE_FAILURE;
else
memcached_server_response_increment(ptr);
return return_value;
}
-void sort_hosts(memcached_st *ptr)
+static void sort_hosts(memcached_st *ptr)
{
if (ptr->number_of_hosts)
{
return original_length;
}
-memcached_return memcached_io_close(memcached_server_st *ptr, uint8_t io_death)
+memcached_return memcached_io_close(memcached_server_st *ptr)
{
+ int r;
/* in case of death shutdown to avoid blocking at close() */
- if (io_death)
- shutdown(ptr->fd, SHUT_RDWR);
- else
- close(ptr->fd);
+ r= shutdown(ptr->fd, SHUT_RDWR);
+ WATCHPOINT_ASSERT(r == 0);
+
+ r= close(ptr->fd);
+ WATCHPOINT_ASSERT(r == 0);
return MEMCACHED_SUCCESS;
}
static ssize_t io_flush(memcached_server_st *ptr,
memcached_return *error)
{
- size_t sent_length;
+ ssize_t sent_length;
size_t return_length;
char *local_write_ptr= ptr->write_buffer;
size_t write_length= ptr->write_buffer_offset;
return 0;
/* Looking for memory overflows */
+#if defined(HAVE_DEBUG)
if (write_length == MEMCACHED_MAX_BUFFER)
WATCHPOINT_ASSERT(ptr->write_buffer == local_write_ptr);
WATCHPOINT_ASSERT((ptr->write_buffer + MEMCACHED_MAX_BUFFER) >= (local_write_ptr + write_length));
+#endif
return_length= 0;
while (write_length)
}
else
{
- if ((ssize_t)(sent_length= write(ptr->fd, local_write_ptr,
+ if ((sent_length= write(ptr->fd, local_write_ptr,
write_length)) == -1)
{
switch (errno)
void memcached_io_reset(memcached_server_st *ptr);
ssize_t memcached_io_read(memcached_server_st *ptr,
void *buffer, size_t length);
-memcached_return memcached_io_close(memcached_server_st *ptr, uint8_t io_death);
+memcached_return memcached_io_close(memcached_server_st *ptr);
#endif __MEMCACHED_IO_H__
memcached_return memcachd_key_test(char **keys, size_t *key_length,
unsigned int number_of_keys)
{
- int x;
+ uint32_t x;
for (x= 0; x < number_of_keys; x++)
{
- int y;
+ size_t y;
if (*(key_length + x) == 0)
return MEMCACHED_BAD_KEY_PROVIDED;
memcached_io_read(ptr, buffer, sizeof(buffer)/sizeof(*buffer)))
> 0);
}
- memcached_io_close(ptr, io_death);
+ memcached_io_close(ptr);
ptr->fd= -1;
ptr->write_buffer_offset= 0;
memcached_server_response_decrement(ptr);
}
- uint64_t auto_return_value= 0;
switch(buffer[0])
{
case 'V': /* VALUE || VERSION */
memcached_io_reset(ptr);
return MEMCACHED_CLIENT_ERROR;
default:
- if (sscanf(buffer, "%lld", &auto_return_value) == 1)
+ {
+ unsigned long long auto_return_value;
+
+ if (sscanf(buffer, "%llu", &auto_return_value) == 1)
return MEMCACHED_SUCCESS;
- memcached_io_reset(ptr);
- return MEMCACHED_UNKNOWN_READ_FAILURE;
+
+ memcached_io_reset(ptr);
+
+ return MEMCACHED_UNKNOWN_READ_FAILURE;
+ }
}
static memcached_return safe_read(memcached_server_st *ptr, void *dta,
size_t size)
{
- int offset= 0;
+ size_t offset= 0;
char *data= dta;
+
while (offset < size)
{
ssize_t nread= memcached_io_read(ptr, data + offset, size - offset);
static char *global_keys[GLOBAL_COUNT];
static size_t global_keys_length[GLOBAL_COUNT];
-test_return cleanup_pairs(memcached_st *memc)
+static test_return cleanup_pairs(memcached_st *memc __attribute__((unused)))
{
pairs_free(global_pairs);
return 0;
}
-test_return generate_pairs(memcached_st *memc)
+static test_return generate_pairs(memcached_st *memc __attribute__((unused)))
{
unsigned long long x;
global_pairs= pairs_generate(GLOBAL_COUNT, 400);
return 0;
}
-test_return drizzle(memcached_st *memc)
+static test_return drizzle(memcached_st *memc)
{
unsigned int x;
memcached_return rc;
return 0;
}
-memcached_return pre_nonblock(memcached_st *memc)
+static memcached_return pre_nonblock(memcached_st *memc)
{
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, 0);
return MEMCACHED_SUCCESS;
}
-memcached_return pre_md5(memcached_st *memc)
+static memcached_return pre_md5(memcached_st *memc)
{
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_MD5);
return MEMCACHED_SUCCESS;
}
-memcached_return pre_hsieh(memcached_st *memc)
+static memcached_return pre_hsieh(memcached_st *memc)
{
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_HSIEH);
return MEMCACHED_SUCCESS;
}
-memcached_return enable_consistent(memcached_st *memc)
+static memcached_return enable_consistent(memcached_st *memc)
{
memcached_server_distribution value= MEMCACHED_DISTRIBUTION_CONSISTENT;
memcached_hash hash;
Set the value, then quit to make sure it is flushed.
Come back in and test that add fails.
*/
-test_return add_test(memcached_st *memc)
+static test_return add_test(memcached_st *memc)
{
memcached_return rc;
char *key= "foo";
* repeating add_tests many times
* may show a problem in timing
*/
-test_return many_adds(memcached_st *memc)
+static test_return many_adds(memcached_st *memc)
{
unsigned int i;
for (i = 0; i < TEST_COUNTER; i++){
#define SERVERS_TO_CREATE 5
-void *world_create(void)
+static void *world_create(void)
{
server_startup_st *construct;
return construct;
}
-void world_destroy(void *p)
+static void world_destroy(void *p)
{
server_startup_st *construct= (server_startup_st *)p;
memcached_server_st *servers= (memcached_server_st *)construct->servers;
#include "test.h"
-long int timedif(struct timeval a, struct timeval b)
+static long int timedif(struct timeval a, struct timeval b)
{
register int us, s;