X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=lib%2Fmemcached.c;h=a5be8e255fab93eba37af6c3de2a7b71930b27f1;hb=311bd0fafe1da7b5cc770a2ff4fac5472a801a40;hp=e40c3db4c229d1b02e984abb7daa2aba439b2c70;hpb=d283f47cade6fcd1256e738057667fbcca7b06c1;p=awesomized%2Flibmemcached diff --git a/lib/memcached.c b/lib/memcached.c index e40c3db4..a5be8e25 100644 --- a/lib/memcached.c +++ b/lib/memcached.c @@ -23,19 +23,16 @@ memcached_st *memcached_create(memcached_st *ptr) string_ptr= memcached_string_create(ptr, &ptr->result_buffer, 0); WATCHPOINT_ASSERT(string_ptr); ptr->poll_timeout= -1; + ptr->distribution= MEMCACHED_DISTRIBUTION_MODULO; return ptr; } void memcached_free(memcached_st *ptr) { - if (ptr->hosts) - { - memcached_quit(ptr); - memcached_server_list_free(ptr->hosts); - ptr->hosts= NULL; - } - + /* If we have anything open, lets close it now */ + memcached_quit(ptr); + memcached_server_list_free(ptr->hosts); memcached_string_free(&ptr->result_buffer); if (ptr->is_allocated == MEMCACHED_ALLOCATED) @@ -56,11 +53,20 @@ memcached_st *memcached_clone(memcached_st *clone, memcached_st *ptr) if (ptr == NULL) return memcached_create(clone); + + if (ptr->is_allocated == MEMCACHED_USED) + { + WATCHPOINT_ASSERT(0); + return NULL; + } new_clone= memcached_create(clone); + + if (new_clone == NULL) + return NULL; - - rc= memcached_server_push(new_clone, ptr->hosts); + if (ptr->hosts) + rc= memcached_server_push(new_clone, ptr->hosts); if (rc != MEMCACHED_SUCCESS) { @@ -75,6 +81,7 @@ memcached_st *memcached_clone(memcached_st *clone, memcached_st *ptr) new_clone->send_size= ptr->send_size; new_clone->recv_size= ptr->recv_size; new_clone->poll_timeout= ptr->poll_timeout; + new_clone->distribution= ptr->distribution; return new_clone; }