unlikely (send_length >= MEMCACHED_DEFAULT_COMMAND_SIZE)
return MEMCACHED_WRITE_FAILURE;
- rc= memcached_do(instance, buffer, send_length, 1);
+ rc= memcached_do(instance, buffer, send_length, true);
if (no_reply || rc != MEMCACHED_SUCCESS)
return rc;
request.message.body.expiration= htonl((uint32_t) expiration);
if ((memcached_do(instance, request.bytes,
- sizeof(request.bytes), 0)!=MEMCACHED_SUCCESS) ||
+ sizeof(request.bytes), false) != MEMCACHED_SUCCESS) ||
(memcached_io_write(instance, key, key_length, true) == -1))
{
memcached_io_reset(instance);
typedef struct memcached_server_st memcached_server_instance_st;
/* These are private not to be installed headers */
+#include "libmemcached/do.h"
#include "libmemcached/io.h"
#include "libmemcached/internal.h"
#include "libmemcached/libmemcached_probes.h"
#define memcached_set_allocated(__object, __value) ((__object)->options.is_allocated(= (__value))
-LIBMEMCACHED_LOCAL
-memcached_return_t memcached_do(memcached_server_instance_st *ptr, const void *commmand,
- size_t command_length, uint8_t with_flush);
LIBMEMCACHED_LOCAL
memcached_return_t value_fetch(memcached_server_instance_st *ptr,
char *buffer,
uint32_t server_key,
const char *key,
size_t key_length,
- uint8_t flush);
+ bool flush);
memcached_return_t memcached_delete_by_key(memcached_st *ptr,
const char *master_key, size_t master_key_length,
const char *key, size_t key_length,
time_t expiration)
{
- uint8_t to_write;
+ bool to_write;
size_t send_length;
memcached_return_t rc;
char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
server_key= memcached_generate_hash(ptr, master_key, master_key_length);
instance= memcached_server_instance_fetch(ptr, server_key);
- to_write= (uint8_t)((ptr->flags.buffer_requests) ? 0 : 1);
+ to_write= (ptr->flags.buffer_requests) ? false : true;
bool no_reply= (ptr->flags.no_reply);
if (instance->minor_version == 0)
{
- if (no_reply || !to_write)
+ if (no_reply || ! to_write)
{
/* We might get out of sync with the server if we
* send this command to a server newer than 1.2.x..
* disable no_reply and buffered mode.
*/
- to_write= 1;
+ to_write= true;
if (no_reply)
memcached_server_response_increment(instance);
no_reply= false;
goto error;
}
- if (ptr->flags.use_udp && !to_write)
+ if (ptr->flags.use_udp && ! to_write)
{
if (send_length > MAX_UDP_DATAGRAM_LENGTH - UDP_DATAGRAM_HEADER_LENGTH)
return MEMCACHED_WRITE_FAILURE;
if (rc != MEMCACHED_SUCCESS)
goto error;
- if (!to_write)
+ if (! to_write)
rc= MEMCACHED_BUFFERED;
else if (!no_reply)
{
uint32_t server_key,
const char *key,
size_t key_length,
- uint8_t flush)
+ bool flush)
{
memcached_server_instance_st *instance;
protocol_binary_request_delete request= {.bytes= {0}};
request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES;
request.message.header.request.bodylen= htonl((uint32_t) key_length);
- if (ptr->flags.use_udp && !flush)
+ if (ptr->flags.use_udp && ! flush)
{
size_t cmd_size= sizeof(request.bytes) + key_length;
if (cmd_size > MAX_UDP_DATAGRAM_LENGTH - UDP_DATAGRAM_HEADER_LENGTH)
memcached_return_t rc= MEMCACHED_SUCCESS;
if ((memcached_do(instance, request.bytes,
- sizeof(request.bytes), 0) != MEMCACHED_SUCCESS) ||
+ sizeof(request.bytes), false) != MEMCACHED_SUCCESS) ||
(memcached_io_write(instance, key,
- key_length, (bool) flush) == -1))
+ key_length, flush) == -1))
{
memcached_io_reset(instance);
rc= MEMCACHED_WRITE_FAILURE;
replica= memcached_server_instance_fetch(ptr, server_key);
if ((memcached_do(replica, (const char*)request.bytes,
- sizeof(request.bytes), 0) != MEMCACHED_SUCCESS) ||
- (memcached_io_write(replica, key, key_length, (bool) flush) == -1))
+ sizeof(request.bytes), false) != MEMCACHED_SUCCESS) ||
+ (memcached_io_write(replica, key, key_length, flush) == -1))
{
memcached_io_reset(replica);
}
#include "common.h"
memcached_return_t memcached_do(memcached_server_st *ptr, const void *command,
- size_t command_length, uint8_t with_flush)
+ size_t command_length, bool with_flush)
{
memcached_return_t rc;
ssize_t sent_length;
if (ptr->type == MEMCACHED_CONNECTION_UDP && with_flush && ptr->write_buffer_offset > UDP_DATAGRAM_HEADER_LENGTH)
memcached_io_write(ptr, NULL, 0, true);
- sent_length= memcached_io_write(ptr, command, command_length, (bool) with_flush);
+ sent_length= memcached_io_write(ptr, command, command_length, with_flush);
if (sent_length == -1 || (size_t)sent_length != command_length)
rc= MEMCACHED_WRITE_FAILURE;
--- /dev/null
+/* LibMemcached
+ * Copyright (C) 2006-2009 Brian Aker
+ * All rights reserved.
+ *
+ * Use and distribution licensed under the BSD license. See
+ * the COPYING file in the parent directory for full text.
+ *
+ * Summary: Internal functions used by the library. Not for public use!
+ *
+ */
+
+#ifndef __LIBMEMCACHED_DO_H__
+#define __LIBMEMCACHED_DO_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+LIBMEMCACHED_LOCAL
+memcached_return_t memcached_do(memcached_server_instance_st *ptr, const void *commmand,
+ size_t command_length, bool with_flush);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __LIBMEMCACHED_DO_H__ */
send_length= (size_t) snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE,
"stats cachedump %u 0 0\r\n", x);
- rc= memcached_do(instance, buffer, send_length, 1);
+ rc= memcached_do(instance, buffer, send_length, true);
unlikely (rc != MEMCACHED_SUCCESS)
goto error;
send_length= (size_t) snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE,
"flush_all%s\r\n", no_reply ? " noreply" : "");
- rc= memcached_do(instance, buffer, send_length, 1);
+ rc= memcached_do(instance, buffer, send_length, true);
if (rc == MEMCACHED_SUCCESS && !no_reply)
(void)memcached_response(instance, buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, NULL);
}
if (memcached_do(instance, request.bytes,
- sizeof(request.bytes), 1) != MEMCACHED_SUCCESS)
+ sizeof(request.bytes), true) != MEMCACHED_SUCCESS)
{
memcached_io_reset(instance);
return MEMCACHED_WRITE_FAILURE;
size_t number_of_keys,
bool mget_mode)
{
- unsigned int x;
+ uint32_t x;
memcached_return_t rc= MEMCACHED_NOTFOUND;
const char *get_command= "get ";
uint8_t get_command_length= 4;
if ((memcached_io_write(instance, request.bytes,
sizeof(request.bytes), false) == -1) ||
(memcached_io_write(instance, keys[x],
- key_length[x], (char) flush) == -1))
+ key_length[x], flush) == -1))
{
memcached_server_response_reset(instance);
rc= MEMCACHED_SOME_ERRORS;
noinst_HEADERS+= \
libmemcached/byteorder.h \
libmemcached/common.h \
+ libmemcached/do.h \
libmemcached/internal.h \
libmemcached/io.h \
libmemcached/libmemcached_probes.h \
request.message.header.request.magic = PROTOCOL_BINARY_REQ;
request.message.header.request.opcode = PROTOCOL_BINARY_CMD_QUIT;
request.message.header.request.datatype = PROTOCOL_BINARY_RAW_BYTES;
- rc= memcached_do(ptr, request.bytes, sizeof(request.bytes), 1);
+ rc= memcached_do(ptr, request.bytes, sizeof(request.bytes), true);
}
else
{
- rc= memcached_do(ptr, "quit\r\n", 6, 1);
+ rc= memcached_do(ptr, "quit\r\n", sizeof("quit\r\n"), true);
}
WATCHPOINT_ASSERT(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_FETCH_NOTFINISHED);
request.message.header.request.bodylen= htonl((uint32_t) len);
if ((memcached_do(instance, request.bytes,
- sizeof(request.bytes), 0) != MEMCACHED_SUCCESS) ||
+ sizeof(request.bytes), false) != MEMCACHED_SUCCESS) ||
(memcached_io_write(instance, args, len, true) == -1))
{
memcached_io_reset(instance);
else
{
if (memcached_do(instance, request.bytes,
- sizeof(request.bytes), 1) != MEMCACHED_SUCCESS)
+ sizeof(request.bytes), true) != MEMCACHED_SUCCESS)
{
memcached_io_reset(instance);
return MEMCACHED_WRITE_FAILURE;
if (send_length >= MEMCACHED_DEFAULT_COMMAND_SIZE)
return MEMCACHED_WRITE_FAILURE;
- rc= memcached_do(instance, buffer, send_length, 1);
+ rc= memcached_do(instance, buffer, send_length, true);
if (rc != MEMCACHED_SUCCESS)
goto error;
uint64_t cas,
memcached_storage_action_t verb)
{
- char to_write;
+ bool to_write;
size_t write_length;
memcached_return_t rc;
char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
}
/* Send command header */
- rc= memcached_do(instance, buffer, write_length, 0);
+ rc= memcached_do(instance, buffer, write_length, false);
if (rc != MEMCACHED_SUCCESS)
goto error;
if (ptr->flags.buffer_requests && verb == SET_OP)
{
- to_write= 0;
+ to_write= false;
}
else
{
- to_write= 1;
+ to_write= true;
}
if (memcached_io_write(instance, "\r\n", 2, to_write) == -1)
}
if (ptr->flags.no_reply)
- return (to_write == 0) ? MEMCACHED_BUFFERED : MEMCACHED_SUCCESS;
+ return (to_write == false) ? MEMCACHED_BUFFERED : MEMCACHED_SUCCESS;
- if (to_write == 0)
+ if (to_write == false)
return MEMCACHED_BUFFERED;
rc= memcached_response(instance, buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, NULL);
uint64_t cas,
memcached_storage_action_t verb)
{
- uint8_t flush;
+ bool flush;
protocol_binary_request_set request= {.bytes= {0}};
size_t send_length= sizeof(request.bytes);
uint32_t server_key= memcached_generate_hash(ptr, master_key,
if (cas)
request.message.header.request.cas= htonll(cas);
- flush= (uint8_t) ((server->root->flags.buffer_requests && verb == SET_OP) ? 0 : 1);
+ flush= (bool) ((server->root->flags.buffer_requests && verb == SET_OP) ? 0 : 1);
- if (server->root->flags.use_udp && !flush)
+ if (server->root->flags.use_udp && ! flush)
{
size_t cmd_size= send_length + key_length + value_length;
}
/* write the header */
- if ((memcached_do(server, (const char*)request.bytes, send_length, 0) != MEMCACHED_SUCCESS) ||
+ if ((memcached_do(server, (const char*)request.bytes, send_length, false) != MEMCACHED_SUCCESS) ||
(memcached_io_write(server, key, key_length, false) == -1) ||
- (memcached_io_write(server, value, value_length, (char) flush) == -1))
+ (memcached_io_write(server, value, value_length, flush) == -1))
{
memcached_io_reset(server);
return MEMCACHED_WRITE_FAILURE;
instance= memcached_server_instance_fetch(ptr, server_key);
if ((memcached_do(instance, (const char*)request.bytes,
- send_length, 0) != MEMCACHED_SUCCESS) ||
+ send_length, false) != MEMCACHED_SUCCESS) ||
(memcached_io_write(instance, key, key_length, false) == -1) ||
- (memcached_io_write(instance, value, value_length, (char) flush) == -1))
+ (memcached_io_write(instance, value, value_length, flush) == -1))
{
memcached_io_reset(instance);
}
}
}
- if (flush == 0)
+ if (flush == false)
{
return MEMCACHED_BUFFERED;
}
memcached_server_instance_st *instance=
memcached_server_instance_fetch(ptr, x);
- rrc= memcached_do(instance, buffer, send_length, 1);
+ rrc= memcached_do(instance, buffer, send_length, true);
if (rrc != MEMCACHED_SUCCESS)
{
rc= MEMCACHED_SOME_ERRORS;
static inline memcached_return_t memcached_version_textual(memcached_st *ptr)
{
- unsigned int x;
size_t send_length;
memcached_return_t rc;
char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
send_length= strlen(command);
rc= MEMCACHED_SUCCESS;
- for (x= 0; x < memcached_server_count(ptr); x++)
+ for (uint32_t 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(instance, command, send_length, 1);
+ rrc= memcached_do(instance, command, send_length, true);
if (rrc != MEMCACHED_SUCCESS)
{
rc= MEMCACHED_SOME_ERRORS;
memcached_server_instance_st *instance=
memcached_server_instance_fetch(ptr, x);
- rrc= memcached_do(instance, request.bytes, sizeof(request.bytes), 1);
+ rrc= memcached_do(instance, request.bytes, sizeof(request.bytes), true);
if (rrc != MEMCACHED_SUCCESS)
{
memcached_io_reset(instance);