From: Date: Mon, 17 Nov 2008 22:13:14 +0000 (-0500) Subject: Removing purge support for the time being. X-Git-Tag: 0.25~4 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=b7f043ada7b39b3e9e244a7f6864a31cd08ad650;p=m6w6%2Flibmemcached Removing purge support for the time being. --- diff --git a/libmemcached/common.h b/libmemcached/common.h index b8c8acf5..1b1b13c3 100644 --- a/libmemcached/common.h +++ b/libmemcached/common.h @@ -129,4 +129,6 @@ void host_reset(memcached_st *ptr, memcached_server_st *host, const char *hostname, unsigned int port, uint32_t weight, memcached_connection type); +memcached_return memcached_purge(memcached_server_st *ptr); + #endif /* __COMMON_H__ */ diff --git a/libmemcached/memcached.h b/libmemcached/memcached.h index 96a4f15e..ebe5f239 100644 --- a/libmemcached/memcached.h +++ b/libmemcached/memcached.h @@ -69,6 +69,7 @@ struct memcached_stat_st { }; struct memcached_st { + uint8_t purging; memcached_allocated is_allocated; memcached_server_st *hosts; uint32_t number_of_hosts; @@ -102,7 +103,6 @@ struct memcached_st { uint32_t server_failure_limit; uint32_t io_msg_watermark; uint32_t io_bytes_watermark; - char purging; }; diff --git a/libmemcached/memcached_connect.c b/libmemcached/memcached_connect.c index 57bce101..429e8ec6 100644 --- a/libmemcached/memcached_connect.c +++ b/libmemcached/memcached_connect.c @@ -46,6 +46,8 @@ static memcached_return set_hostinfo(memcached_server_st *server) static memcached_return set_socket_options(memcached_server_st *ptr) { + WATCHPOINT_ASSERT(ptr->fd != -1); + if (ptr->type == MEMCACHED_CONNECTION_UDP) return MEMCACHED_SUCCESS; @@ -167,6 +169,8 @@ test_connect: } } } + + WATCHPOINT_ASSERT(ptr->fd != -1); return MEMCACHED_SUCCESS; } diff --git a/libmemcached/memcached_io.c b/libmemcached/memcached_io.c index 0afcc29e..0624487f 100644 --- a/libmemcached/memcached_io.c +++ b/libmemcached/memcached_io.c @@ -30,6 +30,7 @@ static memcached_return io_wait(memcached_server_st *ptr, fds[0].fd= ptr->fd; fds[0].events= flags; +#ifdef NOT_DONE /* ** We are going to block on write, but at least on Solaris we might block ** on write if we haven't read anything from our input buffer.. @@ -39,7 +40,11 @@ static memcached_return io_wait(memcached_server_st *ptr, ** the test. */ if (read_or_write == MEM_WRITE) - memcached_purge(ptr); + { + if (memcached_purge(ptr) != MEMCACHED_SUCCESS || memcached_purge(ptr) != MEMCACHED_STORED) + return MEMCACHED_FAILURE; + } +#endif error= poll(fds, 1, ptr->root->poll_timeout); @@ -176,6 +181,8 @@ ssize_t memcached_io_write(memcached_server_st *ptr, size_t original_length; const char* buffer_ptr; + WATCHPOINT_ASSERT(ptr->fd != -1); + original_length= length; buffer_ptr= buffer; @@ -199,6 +206,7 @@ ssize_t memcached_io_write(memcached_server_st *ptr, memcached_return rc; ssize_t sent_length; + WATCHPOINT_ASSERT(ptr->fd != -1); sent_length= io_flush(ptr, &rc); if (sent_length == -1) return -1; @@ -210,6 +218,7 @@ ssize_t memcached_io_write(memcached_server_st *ptr, if (with_flush) { memcached_return rc; + WATCHPOINT_ASSERT(ptr->fd != -1); if (io_flush(ptr, &rc) == -1) return -1; } @@ -255,6 +264,8 @@ static ssize_t io_flush(memcached_server_st *ptr, *error= MEMCACHED_SUCCESS; + WATCHPOINT_ASSERT(ptr->fd != -1); + if (ptr->write_buffer_offset == 0) return 0; @@ -268,6 +279,7 @@ static ssize_t io_flush(memcached_server_st *ptr, return_length= 0; while (write_length) { + WATCHPOINT_ASSERT(ptr->fd != -1); WATCHPOINT_ASSERT(write_length > 0); sent_length= 0; if (ptr->type == MEMCACHED_CONNECTION_UDP) @@ -300,15 +312,25 @@ static ssize_t io_flush(memcached_server_st *ptr, } else { +#ifdef NOT_DONE /* ** We might want to purge the input buffer if we haven't consumed ** any output yet... The test for the limits is the purge is inline ** in the purge function to avoid duplicating the logic.. */ - memcached_purge(ptr); + { + memcached_return rc; + WATCHPOINT_ASSERT(ptr->fd != -1); + rc= memcached_purge(ptr); + + if (rc != MEMCACHED_SUCCESS || rc != MEMCACHED_STORED) + return -1; + } +#endif + WATCHPOINT_ASSERT(ptr->fd != -1); if ((sent_length= write(ptr->fd, local_write_ptr, - write_length)) == -1) + write_length)) == -1) { switch (errno) { diff --git a/libmemcached/memcached_io.h b/libmemcached/memcached_io.h index 1da530ee..8361a577 100644 --- a/libmemcached/memcached_io.h +++ b/libmemcached/memcached_io.h @@ -10,5 +10,4 @@ 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); -void memcached_purge(memcached_server_st *ptr); #endif /* __MEMCACHED_IO_H__ */ diff --git a/libmemcached/memcached_purge.c b/libmemcached/memcached_purge.c index 0fbd453c..c73e97ff 100644 --- a/libmemcached/memcached_purge.c +++ b/libmemcached/memcached_purge.c @@ -3,11 +3,13 @@ #include "common.h" #include "memcached_io.h" -void memcached_purge(memcached_server_st *ptr) +memcached_return memcached_purge(memcached_server_st *ptr) { + memcached_return rc; int32_t timeout; char buffer[2048]; memcached_result_st result; + memcached_result_st *result_ptr; if (ptr->root->purging || /* already purging */ (memcached_server_response_count(ptr) < ptr->root->io_msg_watermark && @@ -15,16 +17,19 @@ void memcached_purge(memcached_server_st *ptr) (ptr->io_bytes_sent > ptr->root->io_bytes_watermark && memcached_server_response_count(ptr) < 10)) { - return; + return MEMCACHED_SUCCESS; } /* memcached_io_write and memcached_response may call memcached_purge so we need to be able stop any recursion.. */ ptr->root->purging= 1; + 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.. */ - memcached_io_write(ptr, NULL, 0, 1); + if (memcached_io_write(ptr, NULL, 0, 1) == -1) + return MEMCACHED_FAILURE; + WATCHPOINT_ASSERT(ptr->fd != -1); /* we have already incremented the response counter, and memcached_response will read out all messages.. To avoid memcached_response to wait forever @@ -36,8 +41,20 @@ void memcached_purge(memcached_server_st *ptr) timeout if there is no data yet */ timeout= ptr->root->poll_timeout; ptr->root->poll_timeout= 1; - memcached_response(ptr, buffer, sizeof(buffer), &result); + result_ptr= memcached_result_create(ptr->root, &result); + + if (result_ptr == NULL) + return MEMCACHED_FAILURE; + + WATCHPOINT_ASSERT(ptr->fd != -1); + rc= memcached_response(ptr, buffer, sizeof(buffer), &result); + WATCHPOINT_ERROR(rc); + WATCHPOINT_ASSERT(ptr->fd != -1); ptr->root->poll_timeout= timeout; memcached_server_response_increment(ptr); ptr->root->purging = 0; + + memcached_result_free(&result); + + return rc; }