From: Brian Aker Date: Thu, 22 Dec 2011 17:02:05 +0000 (-0800) Subject: Switch verbose to vector. X-Git-Tag: 1.0.3~3^2~1^2~23 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=4fb62b21c6b652affd10b32f2aae2eb9165e782a;p=awesomized%2Flibmemcached Switch verbose to vector. --- diff --git a/libmemcached/response.cc b/libmemcached/response.cc index 775102fa..dbc4e5d4 100644 --- a/libmemcached/response.cc +++ b/libmemcached/response.cc @@ -354,7 +354,7 @@ static memcached_return_t textual_read_one_response(memcached_server_write_insta { return MEMCACHED_END; } - else if (buffer[1] == 'R') + else if (buffer[1] == 'R' and buffer[2] == 'R' and buffer[3] == 'O' and buffer[4] == 'R') { return MEMCACHED_PROTOCOL_ERROR; } @@ -380,7 +380,7 @@ static memcached_return_t textual_read_one_response(memcached_server_write_insta } return MEMCACHED_UNKNOWN_READ_FAILURE; - case 'I': /* CLIENT ERROR */ + case 'I': /* ITEM */ /* We add back in one because we will need to search for END */ memcached_server_response_increment(ptr); return MEMCACHED_ITEM; diff --git a/libmemcached/verbosity.cc b/libmemcached/verbosity.cc index 5564c7a9..e2aac3c7 100644 --- a/libmemcached/verbosity.cc +++ b/libmemcached/verbosity.cc @@ -47,7 +47,7 @@ static memcached_return_t _set_verbosity(const memcached_st *, const memcached_server_st *server, void *context) { - struct context_st *execute= (struct context_st *)context; + const libmemcached_io_vector_st *execute= (const libmemcached_io_vector_st *)context; memcached_st local_memc; memcached_st *memc_ptr= memcached_create(&local_memc); @@ -56,16 +56,15 @@ static memcached_return_t _set_verbosity(const memcached_st *, if (rc == MEMCACHED_SUCCESS) { - char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; - memcached_server_write_instance_st instance= memcached_server_instance_fetch(memc_ptr, 0); - rc= memcached_do(instance, execute->buffer, execute->length, true); + rc= memcached_vdo(instance, execute, 3, true); if (rc == MEMCACHED_SUCCESS) { - rc= memcached_response(instance, buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, NULL); + char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; + rc= memcached_response(instance, buffer, sizeof(buffer), NULL); } } @@ -76,22 +75,25 @@ static memcached_return_t _set_verbosity(const memcached_st *, memcached_return_t memcached_verbosity(memcached_st *ptr, uint32_t verbosity) { - int send_length; memcached_server_fn callbacks[1]; char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; - send_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, - "verbosity %u\r\n", verbosity); - if (send_length >= MEMCACHED_DEFAULT_COMMAND_SIZE || send_length < 0) + int send_length= snprintf(buffer, sizeof(buffer), "%u", verbosity); + if (send_length >= MEMCACHED_DEFAULT_COMMAND_SIZE or send_length < 0) { return memcached_set_error(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT, memcached_literal_param("snprintf(MEMCACHED_DEFAULT_COMMAND_SIZE)")); } - struct context_st context = { (size_t)send_length, buffer }; + struct libmemcached_io_vector_st vector[]= + { + { memcached_literal_param("verbosity ") }, + { buffer, send_length }, + { memcached_literal_param("\r\n") } + }; callbacks[0]= _set_verbosity; - return memcached_server_cursor(ptr, callbacks, &context, 1); + return memcached_server_cursor(ptr, callbacks, vector, 1); }