++ * Added Twitter's memcached_server_error() functions.
+ * Fix for OSX compiles in development builds.
+ * Updated C++ interface.
+
+0.31 Fri Jul 10 09:02:50 PDT 2009
+ * Added support or HA via replication.
+ * malloc() removed for server key usage.
+ * Update build system.
* Added support for memcached_set_memory_allocators().
* Fixed bug in configure.ac for have_htoll.
memcached_server_st *memcached_servers_parse (const char *server_strings);
++ const char *memcached_server_error(memcached_server_st *ptr);
++
++ void memcached_server_error_reset(memcached_server_st *ptr);
++
=head1 DESCRIPTION
libmemcached(3) operates on a list of hosts which are stored in
The example is "localhost, foo:555, foo, bar". All hosts except foo:555 will
be set to the default port, while that host will have a port of 555.
++memcached_server_error() can be used to look at the text of the last error
++message sent by the server to to the client. Use memcached_server_error_reset()
++to reset the message (this does not currently free up the memory associated
++with the message).
++
++
=head1 RETURN
Varies, see particular functions.
memcached_server_response_increment(ptr);
return MEMCACHED_STAT;
}
-- else if (buffer[1] == 'E')
- return MEMCACHED_SERVER_ERROR;
++ else if (buffer[1] == 'E') /* SERVER_ERROR */
+ {
- /* SERVER_ERROR */
++ char *rel_ptr;
+ char *startptr= buffer + 13, *endptr= startptr;
++
+ while (*endptr != '\r' && *endptr != '\n') endptr++;
- if (ptr->cached_server_error) ptr->root->call_free(ptr->root, ptr->cached_server_error);
- ptr->cached_server_error= ptr->root->call_malloc(ptr->root, endptr - startptr + 1);
++
++ /*
++ Yes, we could make this "efficent" but to do that we would need
++ to maintain more state for the size of the buffer. Why waste
++ memory in the struct, which is important, for something that
++ rarely should happen?
++ */
++ rel_ptr= (char *)ptr->root->call_realloc(ptr->root, ptr->cached_server_error, endptr - startptr + 1);
++
++ if (rel_ptr == NULL)
++ {
++ /* If we happened to have some memory, we just null it since we don't know the size */
++ if (ptr->cached_server_error)
++ ptr->cached_server_error[0]= 0;
++ return MEMCACHED_SERVER_ERROR;
++ }
++ ptr->cached_server_error= rel_ptr;
++
+ memcpy(ptr->cached_server_error, startptr, endptr - startptr);
+ ptr->cached_server_error[endptr - startptr]= 0;
+ return MEMCACHED_SERVER_ERROR;
+ }
else if (buffer[1] == 'T')
return MEMCACHED_STORED;
else
{
memcached_quit_server(ptr, 0);
- {
+ if (ptr->cached_server_error)
- ptr->cached_server_error= NULL;
- }
+ free(ptr->cached_server_error);
+
if (ptr->address_info)
-- {
freeaddrinfo(ptr->address_info);
-- ptr->address_info= NULL;
-- }
if (ptr->is_allocated)
ptr->root->call_free(ptr->root, ptr);
*/
memcached_server_st *memcached_server_clone(memcached_server_st *clone, memcached_server_st *ptr)
{
- memcached_server_st *rv = NULL;
++ memcached_server_st *rv= NULL;
+
/* We just do a normal create if ptr is missing */
if (ptr == NULL)
return NULL;
return memcached_server_clone(NULL, &ptr->hosts[server_key]);
}
++
++const char *memcached_server_error(memcached_server_st *ptr)
++{
++ if (ptr)
++ return ptr->cached_server_error;
++ else
++ return NULL;
++}
++
++void memcached_server_error_reset(memcached_server_st *ptr)
++{
++ ptr->cached_server_error[0]= 0;
++}
uint8_t minor_version;
memcached_connection type;
char *read_ptr;
++ char *cached_server_error;
size_t read_buffer_length;
size_t read_data_length;
size_t write_buffer_offset;
memcached_server_st *memcached_server_by_key(memcached_st *ptr, const char *key,
size_t key_length, memcached_return *error);
++LIBMEMCACHED_API
++const char *memcached_server_error(memcached_server_st *ptr);
++
++LIBMEMCACHED_API
++void memcached_server_error_reset(memcached_server_st *ptr);
++
/* These should not currently be used by end users */
+/* TODO: Is the above comment valid? If so, how can we unit test these if they
+ * aren't exported. If not, we should remove the comment */
+LIBMEMCACHED_API
memcached_server_st *memcached_server_create(memcached_st *memc, memcached_server_st *ptr);
+LIBMEMCACHED_API
memcached_server_st *memcached_server_create_with(memcached_st *memc, memcached_server_st *host,
const char *hostname, unsigned int port,
uint32_t weight, memcached_connection type);