Skip to content

Commit 81273a4

Browse files
author
Trevor North
committed
Fetch all results in php_memc_get_impl
Previously only the first result was fetched after the memcached_mget_by_key call resulting in a RES_END result being left on the stack. As per the libmemcached documentation memcached_fetch_result should be called until it returns NULL following a multi-get. In some circumstances this is not noticeable as libmemcached takes care of flushing the receive buffers accordingly, however certain subsequent operations will incorrectly return the left-over RES_END result.
1 parent 173b49e commit 81273a4

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

php_memcached.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,13 @@ static void php_memc_get_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool by_key)
600600
return;
601601
}
602602
}
603+
604+
/* Fetch all remaining results */
605+
memcached_result_st dummy_result;
606+
memcached_return dummy_status = MEMCACHED_SUCCESS;
607+
memcached_result_create(m_obj->memc, &dummy_result);
608+
while (memcached_fetch_result(m_obj->memc, &dummy_result, &dummy_status) != NULL) {}
609+
memcached_result_free(&dummy_result);
603610

604611
payload = memcached_result_value(&result);
605612
payload_len = memcached_result_length(&result);

0 commit comments

Comments
 (0)