From: Brian Aker Date: Wed, 24 Oct 2007 07:34:49 +0000 (-0700) Subject: Removed the dead select code. X-Git-Tag: 0.7~15 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=a6fa1b62336cfddaf0d9efb7f431490a7c2f3ac9;p=awesomized%2Flibmemcached Removed the dead select code. Fixed testapp so that we can test just selections of tests. Fixed issue in IO, where in non-blocking mode it was possible not to write out a response (aka, we didn't properly flush buffers before exiting). --- diff --git a/lib/memcached_io.c b/lib/memcached_io.c index 45a12199..77541e2a 100644 --- a/lib/memcached_io.c +++ b/lib/memcached_io.c @@ -25,37 +25,6 @@ int io_wait(memcached_st *ptr, unsigned int server_key, unsigned read_or_write) return MEMCACHED_FAILURE; return MEMCACHED_SUCCESS; -#ifdef OLD - while (1) - { - int select_return; - struct timeval local_tv; - fd_set set; - - memset(&local_tv, 0, sizeof(struct timeval)); - - local_tv.tv_sec= 0; - local_tv.tv_usec= 300; - - FD_ZERO(&set); - FD_SET(ptr->hosts[server_key].fd, &set); - - if (read_or_write) - select_return= select(1, &set, NULL, NULL, &local_tv); - else - select_return= select(1, NULL, &set, NULL, &local_tv); - - if (select_return == -1) - { - ptr->my_errno= errno; - return MEMCACHED_FAILURE; - } - else if (!select_return) - break; - } - - return MEMCACHED_SUCCESS; -#endif } ssize_t memcached_io_read(memcached_st *ptr, unsigned int server_key, @@ -169,12 +138,8 @@ ssize_t memcached_io_flush(memcached_st *ptr, unsigned int server_key) } sent_length= 0; -#ifdef orig - if ((sent_length= send(ptr->hosts[server_key].fd, write_ptr, - write_length, 0)) == -1) -#endif - if ((sent_length= write(ptr->hosts[server_key].fd, write_ptr, - write_length)) == -1) + if ((sent_length= write(ptr->hosts[server_key].fd, write_ptr, + write_length)) == -1) { switch (errno) { diff --git a/lib/memcached_quit.c b/lib/memcached_quit.c index 2ceaa679..7670b06c 100644 --- a/lib/memcached_quit.c +++ b/lib/memcached_quit.c @@ -13,8 +13,11 @@ void memcached_quit_server(memcached_st *ptr, unsigned int server_key) { if (ptr->hosts[server_key].fd != -1) { - if (ptr->flags & MEM_NO_BLOCK) - memcached_io_write(ptr, server_key, "quit\r\n", 6, 1); + if (ptr->flags & MEM_NO_BLOCK && ptr->hosts[server_key].stack_responses) + memcached_io_flush(ptr, server_key); + + memcached_io_write(ptr, server_key, "quit\r\n", 6, 1); + close(ptr->hosts[server_key].fd); ptr->hosts[server_key].fd= -1; ptr->hosts[server_key].stack_responses= 0; diff --git a/tests/test.c b/tests/test.c index 25e9ac84..60c6211a 100644 --- a/tests/test.c +++ b/tests/test.c @@ -122,6 +122,9 @@ void get_test(memcached_st *memc) size_t string_length; uint16_t flags; + rc= memcached_delete(memc, key, strlen(key), (time_t)0); + assert(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_NOTFOUND); + string= memcached_get(memc, key, strlen(key), &string_length, &flags, &rc); @@ -599,7 +602,8 @@ void user_supplied_bug2(memcached_st *memc) } } -#define KEY_COUNT 2000 // * 1024576 +/* Do a large mget() over all the keys we think exist */ +#define KEY_COUNT 3000 // * 1024576 void user_supplied_bug3(memcached_st *memc) { memcached_return rc; @@ -625,7 +629,7 @@ void user_supplied_bug3(memcached_st *memc) memset(keys, 0, (sizeof(char *) * KEY_COUNT)); for (x= 0; x < KEY_COUNT; x++) { - char buffer[20]; + char buffer[30]; snprintf(buffer, 30, "%u", x); keys[x]= strdup(buffer); @@ -773,7 +777,7 @@ int main(int argc, char *argv[]) char *wildcard= NULL; memcached_server_st *servers; - if (argc > 2) + if (argc > 1) test_to_run= argv[1]; if (argc == 3) @@ -838,7 +842,7 @@ int main(int argc, char *argv[]) test_st user_tests[] ={ {"user_supplied_bug1", 0, user_supplied_bug1 }, {"user_supplied_bug2", 0, user_supplied_bug2 }, - {"user_supplied_bug3", 0, user_supplied_bug3 }, +// {"user_supplied_bug3", 0, user_supplied_bug3 }, {0, 0, 0} };