X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=lib%2Fmemcached.c;h=9ee49d665f38338e0024301f3a366f82e74247df;hb=15bf3ab4b52d7971752e9b896d443771c3547df0;hp=1ed39a915feb628e759369dba68be4f5acb4079e;hpb=122f18f5a7bf1c0361ee6edca276a0cabc95ed6d;p=awesomized%2Flibmemcached diff --git a/lib/memcached.c b/lib/memcached.c index 1ed39a91..9ee49d66 100644 --- a/lib/memcached.c +++ b/lib/memcached.c @@ -22,21 +22,17 @@ 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_MODULUS; + ptr->poll_timeout= MEMCACHED_DEFAILT_TIMEOUT; + 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) @@ -52,16 +48,25 @@ void memcached_free(memcached_st *ptr) */ memcached_st *memcached_clone(memcached_st *clone, memcached_st *ptr) { - memcached_return rc; + memcached_return rc= MEMCACHED_SUCCESS; memcached_st *new_clone; 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) { @@ -72,11 +77,11 @@ memcached_st *memcached_clone(memcached_st *clone, memcached_st *ptr) new_clone->flags= ptr->flags; - new_clone->number_of_hosts= ptr->number_of_hosts; 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; + new_clone->hash= ptr->hash; return new_clone; }