X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Fresponse.cc;h=554f6dce3852fe67011b81d8e617c5fde819cb8a;hb=5dcfd8799e2ab7d60b8d3b352474d43556d37dcf;hp=7503c5a0d2da58aa8764810441775b2c1c17132f;hpb=74ee88e5faed86095e8ae53c7831e1f1d2249557;p=awesomized%2Flibmemcached diff --git a/libmemcached/response.cc b/libmemcached/response.cc index 7503c5a0..554f6dce 100644 --- a/libmemcached/response.cc +++ b/libmemcached/response.cc @@ -38,7 +38,7 @@ #include #include -static memcached_return_t textual_value_fetch(org::libmemcached::Instance* instance, +static memcached_return_t textual_value_fetch(memcached_instance_st* instance, char *buffer, memcached_result_st *result) { @@ -210,7 +210,7 @@ read_error: return MEMCACHED_PARTIAL_READ; } -static memcached_return_t textual_read_one_response(org::libmemcached::Instance* instance, +static memcached_return_t textual_read_one_response(memcached_instance_st* instance, char *buffer, const size_t buffer_length, memcached_result_st *result) { @@ -309,8 +309,9 @@ static memcached_return_t textual_read_one_response(org::libmemcached::Instance* return MEMCACHED_E2BIG; } - if (total_read >= memcached_literal_param_size("SERVER_ERROR out of memory storing object") and - (memcmp(buffer, memcached_literal_param("SERVER_ERROR out of memory storing object")) == 0)) + if (total_read >= memcached_literal_param_size("SERVER_ERROR out of memory") and + ((memcmp(buffer, memcached_literal_param("SERVER_ERROR out of memory")) == 0) or + (memcmp(buffer, memcached_literal_param("SERVER_ERROR Out of memory")) == 0))) { return MEMCACHED_SERVER_MEMORY_ALLOCATION_FAILURE; } @@ -493,13 +494,15 @@ static memcached_return_t textual_read_one_response(org::libmemcached::Instance* buffer, total_read); } -static memcached_return_t binary_read_one_response(org::libmemcached::Instance* instance, +static memcached_return_t binary_read_one_response(memcached_instance_st* instance, char *buffer, const size_t buffer_length, memcached_result_st *result) { memcached_return_t rc; protocol_binary_response_header header; + assert(memcached_is_binary(instance->root)); + if ((rc= memcached_safe_read(instance, &header.bytes, sizeof(header.bytes))) != MEMCACHED_SUCCESS) { WATCHPOINT_ERROR(rc); @@ -780,7 +783,7 @@ static memcached_return_t binary_read_one_response(org::libmemcached::Instance* case PROTOCOL_BINARY_CMD_REPLACEQ: case PROTOCOL_BINARY_CMD_APPENDQ: case PROTOCOL_BINARY_CMD_PREPENDQ: - return binary_read_one_response(instance, buffer, buffer_length, result); + return MEMCACHED_FETCH_NOTFINISHED; default: break; @@ -831,7 +834,7 @@ static memcached_return_t binary_read_one_response(org::libmemcached::Instance* return rc; } -static memcached_return_t _read_one_response(org::libmemcached::Instance* instance, +static memcached_return_t _read_one_response(memcached_instance_st* instance, char *buffer, const size_t buffer_length, memcached_result_st *result) { @@ -846,7 +849,9 @@ static memcached_return_t _read_one_response(org::libmemcached::Instance* instan memcached_return_t rc; if (memcached_is_binary(instance->root)) { - rc= binary_read_one_response(instance, buffer, buffer_length, result); + do { + rc= binary_read_one_response(instance, buffer, buffer_length, result); + } while (rc == MEMCACHED_FETCH_NOTFINISHED); } else { @@ -861,7 +866,7 @@ static memcached_return_t _read_one_response(org::libmemcached::Instance* instan return rc; } -memcached_return_t memcached_read_one_response(org::libmemcached::Instance* instance, +memcached_return_t memcached_read_one_response(memcached_instance_st* instance, memcached_result_st *result) { char buffer[SMALL_STRING_LEN]; @@ -875,7 +880,7 @@ memcached_return_t memcached_read_one_response(org::libmemcached::Instance* inst return _read_one_response(instance, buffer, sizeof(buffer), result); } -memcached_return_t memcached_response(org::libmemcached::Instance* instance, +memcached_return_t memcached_response(memcached_instance_st* instance, memcached_result_st *result) { char buffer[1024]; @@ -883,7 +888,7 @@ memcached_return_t memcached_response(org::libmemcached::Instance* instance, return memcached_response(instance, buffer, sizeof(buffer), result); } -memcached_return_t memcached_response(org::libmemcached::Instance* instance, +memcached_return_t memcached_response(memcached_instance_st* instance, char *buffer, size_t buffer_length, memcached_result_st *result) { @@ -892,12 +897,19 @@ memcached_return_t memcached_response(org::libmemcached::Instance* instance, return memcached_set_error(*instance, MEMCACHED_NOT_SUPPORTED, MEMCACHED_AT); } - /* We may have old commands in the buffer not set, first purge */ + /* We may have old commands in the buffer not sent, first purge */ if ((instance->root->flags.no_block) and (memcached_is_processing_input(instance->root) == false)) { (void)memcached_io_write(instance); } + /* Before going into loop wait to see if we have any IO waiting for us */ + if (0) + { + memcached_return_t read_rc= memcached_io_wait_for_read(instance); + fprintf(stderr, "%s:%d: %s\n", __FILE__, __LINE__, memcached_strerror(NULL, read_rc)); + } + /* * The previous implementation purged all pending requests and just * returned the last one. Purge all pending messages to ensure backwards