From: Brian Aker Date: Mon, 5 Jan 2009 21:51:48 +0000 (-0800) Subject: Refactor for host_reset, updated test. TODO in code can be safetly ignored X-Git-Tag: 0.26~30 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=defb3c5e4b25d32435b21a99eb85c016d0b1adc9;p=m6w6%2Flibmemcached Refactor for host_reset, updated test. TODO in code can be safetly ignored under current code (since no malloc is required). --- defb3c5e4b25d32435b21a99eb85c016d0b1adc9 diff --cc libmemcached/memcached_server.c index 87f2ddc9,dfb18797..fe132fe1 --- a/libmemcached/memcached_server.c +++ b/libmemcached/memcached_server.c @@@ -25,34 -26,11 +26,31 @@@ memcached_server_st *memcached_server_c return ptr; } -void memcached_server_free(memcached_server_st *ptr) +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) { - WATCHPOINT_NUMBER(ptr->port); - WATCHPOINT_ASSERT(ptr->is_allocated != MEMCACHED_NOT_ALLOCATED); + host= memcached_server_create(memc, host); + + if (host == NULL) + return NULL; + - memset(host, 0, sizeof(memcached_server_st)); + strncpy(host->hostname, hostname, MEMCACHED_MAX_HOST_LENGTH - 1); + host->root= memc ? memc : NULL; + host->port= port; + host->weight= weight; + host->fd= -1; + host->type= type; + host->read_ptr= host->read_buffer; + if (memc) + host->next_retry= memc->retry_timeout; + host->sockaddr_inited= MEMCACHED_NOT_ALLOCATED; + return host; +} + +void memcached_server_free(memcached_server_st *ptr) +{ - WATCHPOINT_ASSERT(ptr->is_allocated != MEMCACHED_NOT_ALLOCATED); - memcached_quit_server(ptr, 0); if (ptr->address_info) diff --cc tests/output.res index b1cdac08,b1cdac08..0f4b3fc7 --- a/tests/output.res +++ b/tests/output.res @@@ -566,13 -566,13 +566,130 @@@ Error 29 -> FETCH WAS NOT COMPLETE Error 30 -> A TIMEOUT OCCURRED Error 31 -> ACTION QUEUED Error 32 -> A BAD KEY WAS PROVIDED/CHARACTERS OUT OF RANGE ++Error 0 -> SUCCESS ++Error 1 -> FAILURE ++Error 2 -> HOSTNAME LOOKUP FAILURE ++Error 3 -> CONNECTION FAILURE ++Error 4 -> CONNECTION BIND FAILURE ++Error 5 -> WRITE FAILURE ++Error 6 -> READ FAILURE ++Error 7 -> UNKNOWN READ FAILURE ++Error 8 -> PROTOCOL ERROR ++Error 9 -> CLIENT ERROR ++Error 10 -> SERVER ERROR ++Error 11 -> CONNECTION SOCKET CREATE FAILURE ++Error 12 -> CONNECTION DATA EXISTS ++Error 13 -> CONNECTION DATA DOES NOT EXIST ++Error 14 -> NOT STORED ++Error 15 -> STORED ++Error 16 -> NOT FOUND ++Error 17 -> MEMORY ALLOCATION FAILURE ++Error 18 -> PARTIAL READ ++Error 19 -> SOME ERRORS WERE REPORTED ++Error 20 -> NO SERVERS DEFINED ++Error 21 -> SERVER END ++Error 22 -> SERVER DELETE ++Error 23 -> SERVER VALUE ++Error 24 -> STAT VALUE ++Error 25 -> SYSTEM ERROR ++Error 26 -> COULD NOT OPEN UNIX SOCKET ++Error 27 -> ACTION NOT SUPPORTED ++Error 28 -> A KEY LENGTH OF ZERO WAS PROVIDED ++Error 29 -> FETCH WAS NOT COMPLETED ++Error 30 -> A TIMEOUT OCCURRED ++Error 31 -> ACTION QUEUED ++Error 32 -> A BAD KEY WAS PROVIDED/CHARACTERS OUT OF RANGE ++Error 0 -> SUCCESS ++Error 1 -> FAILURE ++Error 2 -> HOSTNAME LOOKUP FAILURE ++Error 3 -> CONNECTION FAILURE ++Error 4 -> CONNECTION BIND FAILURE ++Error 5 -> WRITE FAILURE ++Error 6 -> READ FAILURE ++Error 7 -> UNKNOWN READ FAILURE ++Error 8 -> PROTOCOL ERROR ++Error 9 -> CLIENT ERROR ++Error 10 -> SERVER ERROR ++Error 11 -> CONNECTION SOCKET CREATE FAILURE ++Error 12 -> CONNECTION DATA EXISTS ++Error 13 -> CONNECTION DATA DOES NOT EXIST ++Error 14 -> NOT STORED ++Error 15 -> STORED ++Error 16 -> NOT FOUND ++Error 17 -> MEMORY ALLOCATION FAILURE ++Error 18 -> PARTIAL READ ++Error 19 -> SOME ERRORS WERE REPORTED ++Error 20 -> NO SERVERS DEFINED ++Error 21 -> SERVER END ++Error 22 -> SERVER DELETE ++Error 23 -> SERVER VALUE ++Error 24 -> STAT VALUE ++Error 25 -> SYSTEM ERROR ++Error 26 -> COULD NOT OPEN UNIX SOCKET ++Error 27 -> ACTION NOT SUPPORTED ++Error 28 -> A KEY LENGTH OF ZERO WAS PROVIDED ++Error 29 -> FETCH WAS NOT COMPLETED ++Error 30 -> A TIMEOUT OCCURRED ++Error 31 -> ACTION QUEUED ++Error 32 -> A BAD KEY WAS PROVIDED/CHARACTERS OUT OF RANGE ++ketama_weighted:localhost|11221|1|160 ++ketama_weighted:localhost|11222|1|160 ++ketama_weighted:localhost|11223|1|160 ++ketama_weighted:localhost|11224|1|160 ++ketama_weighted:localhost|11225|1|160 ++ketama_weighted:localhost|11221|1|160 ++ketama_weighted:localhost|11222|1|160 ++ketama_weighted:localhost|11223|1|160 ++ketama_weighted:localhost|11224|1|160 ++ketama_weighted:localhost|11225|1|160 ++ketama_weighted:localhost|11221|1|160 ++ketama_weighted:localhost|11222|1|160 ++ketama_weighted:localhost|11223|1|160 ++ketama_weighted:localhost|11224|1|160 ++ketama_weighted:localhost|11225|1|160 ++ketama_weighted:localhost|11221|1|160 ++ketama_weighted:localhost|11222|1|160 ++ketama_weighted:localhost|11223|1|160 ++ketama_weighted:localhost|11224|1|160 ++ketama_weighted:localhost|11225|1|160 --server 0|localhost|11221 bytes: 2805141 ++server 0|localhost|11221 bytes: 1106784 --server 1|localhost|11222 bytes: 2033190 ++server 1|localhost|11222 bytes: 965601 --server 2|localhost|11223 bytes: 1961432 ++server 2|localhost|11223 bytes: 1307502 --server 3|localhost|11224 bytes: 2202898 ++server 3|localhost|11224 bytes: 1240596 --server 4|localhost|11225 bytes: 1715263 ++server 4|localhost|11225 bytes: 1049517 ++ketama_weighted:localhost|11221|1|160 ++ketama_weighted:localhost|11222|1|160 ++ketama_weighted:localhost|11223|1|160 ++ketama_weighted:localhost|11224|1|160 ++ketama_weighted:localhost|11225|1|160 ++ketama_weighted:localhost|11221|1|160 ++ketama_weighted:localhost|11222|1|160 ++ketama_weighted:localhost|11223|1|160 ++ketama_weighted:localhost|11224|1|160 ++ketama_weighted:localhost|11225|1|160 ++ketama_weighted:localhost|11221|1|160 ++ketama_weighted:localhost|11222|1|160 ++ketama_weighted:localhost|11223|1|160 ++ketama_weighted:localhost|11224|1|160 ++ketama_weighted:localhost|11225|1|160 ++ketama_weighted:localhost|11221|1|160 ++ketama_weighted:localhost|11222|1|160 ++ketama_weighted:localhost|11223|1|160 ++ketama_weighted:localhost|11224|1|160 ++ketama_weighted:localhost|11225|1|160 ++ketama_weighted:localhost|6666|1|160 ++ketama_weighted:localhost|11221|1|160 ++ketama_weighted:localhost|11222|1|160 ++ketama_weighted:localhost|11223|1|160 ++ketama_weighted:localhost|11224|1|160 ++ketama_weighted:localhost|11225|1|160 ++ketama_weighted:localhost|11221|1|160 ++ketama_weighted:localhost|11222|1|160 ++ketama_weighted:localhost|11223|1|160 ++ketama_weighted:localhost|11224|1|160 ++ketama_weighted:localhost|11225|1|160