From: Date: Sat, 8 Mar 2008 20:01:48 +0000 (-0500) Subject: Incomming fixes from Charles on the replication branch. X-Git-Tag: 0.25~5^2 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=8ce1a267a6593221cdd887643517364694ea985f;p=m6w6%2Flibmemcached Incomming fixes from Charles on the replication branch. --- diff --git a/lib/memcached_delete.c b/lib/memcached_delete.c index dea5c92f..16ab0cd5 100644 --- a/lib/memcached_delete.c +++ b/lib/memcached_delete.c @@ -35,11 +35,8 @@ memcached_return memcached_delete_by_key(memcached_st *ptr, send_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, "delete %.*s\r\n", (int)key_length, key); - if (send_length >= MEMCACHED_DEFAULT_COMMAND_SIZE) - { - rc[replicas]= MEMCACHED_WRITE_FAILURE; - goto error; - } + unlikely (send_length >= MEMCACHED_DEFAULT_COMMAND_SIZE) + return MEMCACHED_WRITE_FAILURE; do { @@ -53,9 +50,9 @@ memcached_return memcached_delete_by_key(memcached_st *ptr, } else { - rc[replicas]= memcached_response(&ptr->hosts[server_key], buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, NULL); - if (rc[replicas] == MEMCACHED_DELETED) - rc[replicas]= MEMCACHED_SUCCESS; + char response_buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; + + rc[replicas]= memcached_response(&ptr->hosts[server_key], response_buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, NULL); } /* On error we just jump to the next potential server */ @@ -74,8 +71,8 @@ error: { if (rc[replicas] == MEMCACHED_DELETED) return MEMCACHED_SUCCESS; - else if (rc[replicas] == MEMCACHED_DELETED) - rc[replicas]= MEMCACHED_BUFFERED; + else if (rc[replicas] == MEMCACHED_BUFFERED) + return MEMCACHED_BUFFERED; } return rc[0]; diff --git a/lib/memcached_get.c b/lib/memcached_get.c index b3cd8e51..12d301ec 100644 --- a/lib/memcached_get.c +++ b/lib/memcached_get.c @@ -50,22 +50,22 @@ char *memcached_get_by_key(memcached_st *ptr, do { + char response_buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; + if (memcached_server_response_count(&ptr->hosts[server_key])) { - char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; - if (ptr->flags & MEM_NO_BLOCK) (void)memcached_io_write(&ptr->hosts[server_key], NULL, 0, 1); while(memcached_server_response_count(&ptr->hosts[server_key])) - (void)memcached_response(&ptr->hosts[server_key], buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, result_buffer); + (void)memcached_response(&ptr->hosts[server_key], response_buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, result_buffer); } rc[replicas]= memcached_do(&ptr->hosts[server_key], buffer, send_length, 1); if (rc[replicas] != MEMCACHED_SUCCESS) goto error; - rc[replicas]= memcached_response(&ptr->hosts[server_key], buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, result_buffer); + rc[replicas]= memcached_response(&ptr->hosts[server_key], response_buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, result_buffer); /* On no key found, we check the replica */ if (rc[replicas] == MEMCACHED_END) /* END means that we move on to the next */ @@ -79,6 +79,7 @@ char *memcached_get_by_key(memcached_st *ptr, if (result_buffer->flags) *flags= result_buffer->flags; + *error= MEMCACHED_SUCCESS; return memcached_string_c_copy(&result_buffer->value); }