From 9b767485048053ad0b4c2897a0d3784aa6e9fe10 Mon Sep 17 00:00:00 2001 From: Brian Aker Date: Thu, 21 Jan 2010 15:56:45 -0800 Subject: [PATCH] Fix IO call to use bool. --- libmemcached/auto.c | 2 +- libmemcached/delete.c | 8 ++++---- libmemcached/do.c | 4 ++-- libmemcached/flush_buffers.c | 2 +- libmemcached/get.c | 22 +++++++++++----------- libmemcached/io.c | 2 +- libmemcached/io.h | 2 +- libmemcached/purge.c | 2 +- libmemcached/response.c | 2 +- libmemcached/stats.c | 2 +- libmemcached/storage.c | 10 +++++----- 11 files changed, 29 insertions(+), 29 deletions(-) diff --git a/libmemcached/auto.c b/libmemcached/auto.c index 4d8cc0bd..ba7ea6d3 100644 --- a/libmemcached/auto.c +++ b/libmemcached/auto.c @@ -113,7 +113,7 @@ static memcached_return_t binary_incr_decr(memcached_st *ptr, uint8_t cmd, if ((memcached_do(instance, request.bytes, sizeof(request.bytes), 0)!=MEMCACHED_SUCCESS) || - (memcached_io_write(instance, key, key_length, 1) == -1)) + (memcached_io_write(instance, key, key_length, true) == -1)) { memcached_io_reset(instance); return MEMCACHED_WRITE_FAILURE; diff --git a/libmemcached/delete.c b/libmemcached/delete.c index b29101b4..3109c9e6 100644 --- a/libmemcached/delete.c +++ b/libmemcached/delete.c @@ -116,7 +116,7 @@ memcached_return_t memcached_delete_by_key(memcached_st *ptr, if (send_length > MAX_UDP_DATAGRAM_LENGTH - UDP_DATAGRAM_HEADER_LENGTH) return MEMCACHED_WRITE_FAILURE; if (send_length + instance->write_buffer_offset > MAX_UDP_DATAGRAM_LENGTH) - memcached_io_write(instance, NULL, 0, 1); + memcached_io_write(instance, NULL, 0, true); } rc= memcached_do(instance, buffer, send_length, to_write); @@ -168,7 +168,7 @@ static inline memcached_return_t binary_delete(memcached_st *ptr, if (cmd_size > MAX_UDP_DATAGRAM_LENGTH - UDP_DATAGRAM_HEADER_LENGTH) return MEMCACHED_WRITE_FAILURE; if (cmd_size + instance->write_buffer_offset > MAX_UDP_DATAGRAM_LENGTH) - memcached_io_write(instance, NULL, 0, 1); + memcached_io_write(instance, NULL, 0, true); } memcached_return_t rc= MEMCACHED_SUCCESS; @@ -176,7 +176,7 @@ static inline memcached_return_t binary_delete(memcached_st *ptr, if ((memcached_do(instance, request.bytes, sizeof(request.bytes), 0) != MEMCACHED_SUCCESS) || (memcached_io_write(instance, key, - key_length, (char) flush) == -1)) + key_length, (bool) flush) == -1)) { memcached_io_reset(instance); rc= MEMCACHED_WRITE_FAILURE; @@ -198,7 +198,7 @@ static inline memcached_return_t binary_delete(memcached_st *ptr, if ((memcached_do(replica, (const char*)request.bytes, sizeof(request.bytes), 0) != MEMCACHED_SUCCESS) || - (memcached_io_write(replica, key, key_length, (char) flush) == -1)) + (memcached_io_write(replica, key, key_length, (bool) flush) == -1)) { memcached_io_reset(replica); } diff --git a/libmemcached/do.c b/libmemcached/do.c index d673f187..fa33f51e 100644 --- a/libmemcached/do.c +++ b/libmemcached/do.c @@ -21,9 +21,9 @@ memcached_return_t memcached_do(memcached_server_st *ptr, const void *command, ** otherwise we might get a partial write. **/ if (ptr->type == MEMCACHED_CONNECTION_UDP && with_flush && ptr->write_buffer_offset > UDP_DATAGRAM_HEADER_LENGTH) - memcached_io_write(ptr, NULL, 0, 1); + memcached_io_write(ptr, NULL, 0, true); - sent_length= memcached_io_write(ptr, command, command_length, (char) with_flush); + sent_length= memcached_io_write(ptr, command, command_length, (bool) with_flush); if (sent_length == -1 || (size_t)sent_length != command_length) rc= MEMCACHED_WRITE_FAILURE; diff --git a/libmemcached/flush_buffers.c b/libmemcached/flush_buffers.c index c037cb7b..cf391440 100644 --- a/libmemcached/flush_buffers.c +++ b/libmemcached/flush_buffers.c @@ -17,7 +17,7 @@ memcached_return_t memcached_flush_buffers(memcached_st *memc) WATCHPOINT_ERROR(ret); return ret; } - if (memcached_io_write(instance, NULL, 0, 1) == -1) + if (memcached_io_write(instance, NULL, 0, true) == -1) ret= MEMCACHED_SOME_ERRORS; } } diff --git a/libmemcached/get.c b/libmemcached/get.c index 1261d690..051197b1 100644 --- a/libmemcached/get.c +++ b/libmemcached/get.c @@ -189,7 +189,7 @@ static memcached_return_t memcached_mget_by_key_real(memcached_st *ptr, char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; if (ptr->flags.no_block) - (void)memcached_io_write(instance, NULL, 0, 1); + (void)memcached_io_write(instance, NULL, 0, true); while(memcached_server_response_count(instance)) (void)memcached_response(instance, buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, &ptr->result); @@ -233,7 +233,7 @@ static memcached_return_t memcached_mget_by_key_real(memcached_st *ptr, if (rc != MEMCACHED_SUCCESS) continue; - if ((memcached_io_write(instance, get_command, get_command_length, 0)) == -1) + if ((memcached_io_write(instance, get_command, get_command_length, false)) == -1) { rc= MEMCACHED_SOME_ERRORS; continue; @@ -246,7 +246,7 @@ static memcached_return_t memcached_mget_by_key_real(memcached_st *ptr, /* Only called when we have a prefix key */ if (ptr->prefix_key_length) { - if ((memcached_io_write(instance, ptr->prefix_key, ptr->prefix_key_length, 0)) == -1) + if ((memcached_io_write(instance, ptr->prefix_key, ptr->prefix_key_length, false)) == -1) { memcached_server_response_reset(instance); rc= MEMCACHED_SOME_ERRORS; @@ -254,14 +254,14 @@ static memcached_return_t memcached_mget_by_key_real(memcached_st *ptr, } } - if ((memcached_io_write(instance, keys[x], key_length[x], 0)) == -1) + if ((memcached_io_write(instance, keys[x], key_length[x], false)) == -1) { memcached_server_response_reset(instance); rc= MEMCACHED_SOME_ERRORS; continue; } - if ((memcached_io_write(instance, " ", 1, 0)) == -1) + if ((memcached_io_write(instance, " ", 1, false)) == -1) { memcached_server_response_reset(instance); rc= MEMCACHED_SOME_ERRORS; @@ -280,7 +280,7 @@ static memcached_return_t memcached_mget_by_key_real(memcached_st *ptr, if (memcached_server_response_count(instance)) { /* We need to do something about non-connnected hosts in the future */ - if ((memcached_io_write(instance, "\r\n", 2, 1)) == -1) + if ((memcached_io_write(instance, "\r\n", 2, true)) == -1) { rc= MEMCACHED_SOME_ERRORS; } @@ -407,7 +407,7 @@ static memcached_return_t simple_binary_mget(memcached_st *ptr, request.message.header.request.bodylen= htonl((uint32_t) key_length[x]); if ((memcached_io_write(instance, request.bytes, - sizeof(request.bytes), 0) == -1) || + sizeof(request.bytes), false) == -1) || (memcached_io_write(instance, keys[x], key_length[x], (char) flush) == -1)) { @@ -441,7 +441,7 @@ static memcached_return_t simple_binary_mget(memcached_st *ptr, if (memcached_server_response_count(instance)) { - if (memcached_io_write(instance, NULL, 0, 1) == -1) + if (memcached_io_write(instance, NULL, 0, true) == -1) { memcached_server_response_reset(instance); memcached_io_reset(instance); @@ -449,7 +449,7 @@ static memcached_return_t simple_binary_mget(memcached_st *ptr, } if (memcached_io_write(instance, request.bytes, - sizeof(request.bytes), 1) == -1) + sizeof(request.bytes), true) == -1) { memcached_server_response_reset(instance); memcached_io_reset(instance); @@ -536,9 +536,9 @@ static memcached_return_t replication_binary_mget(memcached_st *ptr, * just make sure we work _correctly_ */ if ((memcached_io_write(instance, request.bytes, - sizeof(request.bytes), 0) == -1) || + sizeof(request.bytes), false) == -1) || (memcached_io_write(instance, keys[x], - key_length[x], 1) == -1)) + key_length[x], true) == -1)) { memcached_io_reset(instance); dead_servers[server]= true; diff --git a/libmemcached/io.c b/libmemcached/io.c index bca5ea4b..232b58d3 100644 --- a/libmemcached/io.c +++ b/libmemcached/io.c @@ -307,7 +307,7 @@ memcached_return_t memcached_io_read(memcached_server_instance_st *ptr, } ssize_t memcached_io_write(memcached_server_instance_st *ptr, - const void *buffer, size_t length, char with_flush) + const void *buffer, size_t length, bool with_flush) { size_t original_length; const char* buffer_ptr; diff --git a/libmemcached/io.h b/libmemcached/io.h index 5530d146..ca22c27d 100644 --- a/libmemcached/io.h +++ b/libmemcached/io.h @@ -42,7 +42,7 @@ struct udp_datagram_header_st LIBMEMCACHED_LOCAL ssize_t memcached_io_write(memcached_server_instance_st *ptr, - const void *buffer, size_t length, char with_flush); + const void *buffer, size_t length, bool with_flush); LIBMEMCACHED_LOCAL void memcached_io_reset(memcached_server_instance_st *ptr); diff --git a/libmemcached/purge.c b/libmemcached/purge.c index 0225e42b..bee5c921 100644 --- a/libmemcached/purge.c +++ b/libmemcached/purge.c @@ -22,7 +22,7 @@ memcached_return_t memcached_purge(memcached_server_instance_st *ptr) WATCHPOINT_ASSERT(ptr->fd != -1); /* Force a flush of the buffer to ensure that we don't have the n-1 pending requests buffered up.. */ - if (memcached_io_write(ptr, NULL, 0, 1) == -1) + if (memcached_io_write(ptr, NULL, 0, true) == -1) { memcached_set_purging(root, true); diff --git a/libmemcached/response.c b/libmemcached/response.c index 3784438e..abd92e4e 100644 --- a/libmemcached/response.c +++ b/libmemcached/response.c @@ -52,7 +52,7 @@ memcached_return_t memcached_response(memcached_server_instance_st *ptr, /* We may have old commands in the buffer not set, first purge */ if ((ptr->root->flags.no_block) && (memcached_is_processing_input(ptr->root) == false)) { - (void)memcached_io_write(ptr, NULL, 0, 1); + (void)memcached_io_write(ptr, NULL, 0, true); } /* diff --git a/libmemcached/stats.c b/libmemcached/stats.c index 6378d89e..e38445ec 100644 --- a/libmemcached/stats.c +++ b/libmemcached/stats.c @@ -251,7 +251,7 @@ static memcached_return_t binary_stats_fetch(memcached_stat_st *memc_stat, if ((memcached_do(instance, request.bytes, sizeof(request.bytes), 0) != MEMCACHED_SUCCESS) || - (memcached_io_write(instance, args, len, 1) == -1)) + (memcached_io_write(instance, args, len, true) == -1)) { memcached_io_reset(instance); return MEMCACHED_WRITE_FAILURE; diff --git a/libmemcached/storage.c b/libmemcached/storage.c index fe480fe4..6b4eb623 100644 --- a/libmemcached/storage.c +++ b/libmemcached/storage.c @@ -139,7 +139,7 @@ static inline memcached_return_t memcached_send(memcached_st *ptr, if (cmd_size > MAX_UDP_DATAGRAM_LENGTH - UDP_DATAGRAM_HEADER_LENGTH) return MEMCACHED_WRITE_FAILURE; if (cmd_size + instance->write_buffer_offset > MAX_UDP_DATAGRAM_LENGTH) - memcached_io_write(instance, NULL, 0, 1); + memcached_io_write(instance, NULL, 0, true); } if (write_length >= MEMCACHED_DEFAULT_COMMAND_SIZE) @@ -154,7 +154,7 @@ static inline memcached_return_t memcached_send(memcached_st *ptr, goto error; /* Send command body */ - if (memcached_io_write(instance, value, value_length, 0) == -1) + if (memcached_io_write(instance, value, value_length, false) == -1) { rc= MEMCACHED_WRITE_FAILURE; goto error; @@ -483,13 +483,13 @@ static memcached_return_t memcached_send_binary(memcached_st *ptr, } if (cmd_size + server->write_buffer_offset > MAX_UDP_DATAGRAM_LENGTH) { - memcached_io_write(server, NULL, 0, 1); + memcached_io_write(server, NULL, 0, true); } } /* write the header */ if ((memcached_do(server, (const char*)request.bytes, send_length, 0) != MEMCACHED_SUCCESS) || - (memcached_io_write(server, key, key_length, 0) == -1) || + (memcached_io_write(server, key, key_length, false) == -1) || (memcached_io_write(server, value, value_length, (char) flush) == -1)) { memcached_io_reset(server); @@ -512,7 +512,7 @@ static memcached_return_t memcached_send_binary(memcached_st *ptr, if ((memcached_do(instance, (const char*)request.bytes, send_length, 0) != MEMCACHED_SUCCESS) || - (memcached_io_write(instance, key, key_length, 0) == -1) || + (memcached_io_write(instance, key, key_length, false) == -1) || (memcached_io_write(instance, value, value_length, (char) flush) == -1)) { memcached_io_reset(instance); -- 2.30.2