From: Date: Sat, 2 Aug 2008 23:03:22 +0000 (-0700) Subject: Small cleanups X-Git-Tag: _23~13 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=335064cd46d8c7bb73b50c6bf690c595c15b7742;p=m6w6%2Flibmemcached Small cleanups --- diff --git a/libmemcached/memcached.h b/libmemcached/memcached.h index aab451cc..da4ce507 100644 --- a/libmemcached/memcached.h +++ b/libmemcached/memcached.h @@ -69,8 +69,8 @@ struct memcached_stat_st { struct memcached_st { memcached_allocated is_allocated; memcached_server_st *hosts; - unsigned int number_of_hosts; - unsigned int cursor_server; + uint32_t number_of_hosts; + uint32_t cursor_server; int cached_errno; uint32_t flags; int send_size; diff --git a/libmemcached/memcached_connect.c b/libmemcached/memcached_connect.c index 8c7ef332..d58b354f 100644 --- a/libmemcached/memcached_connect.c +++ b/libmemcached/memcached_connect.c @@ -172,8 +172,10 @@ static memcached_return network_connect(memcached_server_st *ptr) { struct addrinfo *use; - if(ptr->root->server_failure_limit != 0) { - if(ptr->server_failure_counter >= ptr->root->server_failure_limit) { + if (ptr->root->server_failure_limit != 0) + { + if (ptr->server_failure_counter >= ptr->root->server_failure_limit) + { memcached_server_remove(ptr); } } diff --git a/libmemcached/memcached_hosts.c b/libmemcached/memcached_hosts.c index 5f51d546..dd137dda 100644 --- a/libmemcached/memcached_hosts.c +++ b/libmemcached/memcached_hosts.c @@ -284,26 +284,28 @@ static memcached_return server_add(memcached_st *ptr, char *hostname, memcached_return memcached_server_remove(memcached_server_st *st_ptr) { - int x,index; + uint32_t x, index; memcached_st *ptr= st_ptr->root; - memcached_server_st *list=ptr->hosts; - index= 0; - for (x= 0; x< ptr->number_of_hosts; ++x) + memcached_server_st *list= ptr->hosts; + + for (x= 0, index= 0; x < ptr->number_of_hosts; x++) { if (strncmp(list[x].hostname, st_ptr->hostname, MEMCACHED_MAX_HOST_LENGTH)!=0 || list[x].port != st_ptr->port) { memcpy(list+index, list+x, sizeof(memcached_server_st)); index++; - } else + } + else { - ptr->number_of_hosts-=1; + ptr->number_of_hosts--; } } - if(st_ptr->address_info) - { - freeaddrinfo(st_ptr->address_info); - } + + + if (st_ptr->address_info) + freeaddrinfo(st_ptr->address_info); run_distribution(ptr); + return MEMCACHED_SUCCESS; }