X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=lib%2Fmemcached_storage.c;h=ba8835cb40ee223fac8c95e7d35bda6fb52e437e;hb=e1944ccd4d1e65f4192783fa9c564c9b747bb618;hp=af763a3ed5dd945f7b0debed1befc5cc519bfcf5;hpb=9d926b6c1b6896aa345fa301666b0f98ebf1f6cf;p=m6w6%2Flibmemcached diff --git a/lib/memcached_storage.c b/lib/memcached_storage.c index af763a3e..ba8835cb 100644 --- a/lib/memcached_storage.c +++ b/lib/memcached_storage.c @@ -62,33 +62,22 @@ static inline memcached_return memcached_send(memcached_st *ptr, if (key_length == 0) return MEMCACHED_NO_KEY_PROVIDED; - /* Leaving this WATCHPOINT_ASSERT in since only a library fubar could blow this */ -#ifdef NOT_DONE - if (!(ptr->flags & MEM_NO_BLOCK) && ptr->write_buffer_offset != 0) - WATCHPOINT_ASSERT(0); -#endif - - if (ptr->hosts == NULL || ptr->number_of_hosts == 0) + if (ptr->number_of_hosts == 0) return MEMCACHED_NO_SERVERS; - - server_key= memcached_generate_hash(ptr, key, key_length); - - rc= memcached_connect(ptr, server_key); - if (rc != MEMCACHED_SUCCESS) - return rc; + server_key= memcached_generate_hash(ptr, key, key_length); if (cas) - write_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, - "%s %.*s %u %llu %zu\r\n", storage_op_string(verb), - (int)key_length, key, flags, - (unsigned long long)expiration, value_length); - else write_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, "%s %.*s %u %llu %zu %llu\r\n", storage_op_string(verb), (int)key_length, key, flags, (unsigned long long)expiration, value_length, (unsigned long long)cas); + else + write_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, + "%s %.*s %u %llu %zu\r\n", storage_op_string(verb), + (int)key_length, key, flags, + (unsigned long long)expiration, value_length); if (write_length >= MEMCACHED_DEFAULT_COMMAND_SIZE) { @@ -96,15 +85,9 @@ static inline memcached_return memcached_send(memcached_st *ptr, goto error; } - /* - We have to flush after sending the command. Memcached is not smart enough - to just keep reading from the socket :( - */ - if ((sent_length= memcached_io_write(ptr, server_key, buffer, write_length, 0)) == -1) - { - rc= MEMCACHED_WRITE_FAILURE; + rc= memcached_do(ptr, server_key, buffer, write_length, 0); + if (rc != MEMCACHED_SUCCESS) goto error; - } if ((sent_length= memcached_io_write(ptr, server_key, value, value_length, 0)) == -1) { @@ -119,12 +102,11 @@ static inline memcached_return memcached_send(memcached_st *ptr, if ((sent_length= memcached_io_write(ptr, server_key, "\r\n", 2, to_write)) == -1) { - memcached_quit_server(ptr, server_key); rc= MEMCACHED_WRITE_FAILURE; goto error; } - if ((ptr->flags & MEM_NO_BLOCK) && verb == SET_OP) + if (to_write == 0) { rc= MEMCACHED_SUCCESS; memcached_server_response_increment(ptr, server_key);